Attributes: Allow calling "finish" on empty accessors
This removes some boilerplate when creating many optional attributes.
This commit is contained in:
@@ -264,7 +264,9 @@ template<typename T> struct SpanAttributeWriter {
|
||||
*/
|
||||
void finish()
|
||||
{
|
||||
this->span.save();
|
||||
if (this->span.varray()) {
|
||||
this->span.save();
|
||||
}
|
||||
if (this->tag_modified_fn) {
|
||||
this->tag_modified_fn();
|
||||
}
|
||||
@@ -339,7 +341,9 @@ struct GSpanAttributeWriter {
|
||||
|
||||
void finish()
|
||||
{
|
||||
this->span.save();
|
||||
if (this->span.varray()) {
|
||||
this->span.save();
|
||||
}
|
||||
if (this->tag_modified_fn) {
|
||||
this->tag_modified_fn();
|
||||
}
|
||||
|
@@ -1368,21 +1368,12 @@ void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *me, const CustomData_MeshMasks *
|
||||
}
|
||||
bm->elem_index_dirty &= ~(BM_FACE | BM_LOOP);
|
||||
|
||||
if (material_index_attribute) {
|
||||
material_index_attribute.finish();
|
||||
}
|
||||
|
||||
assert_bmesh_has_no_mesh_only_attributes(*bm);
|
||||
|
||||
if (hide_vert_attribute) {
|
||||
hide_vert_attribute.finish();
|
||||
}
|
||||
if (hide_edge_attribute) {
|
||||
hide_edge_attribute.finish();
|
||||
}
|
||||
if (hide_poly_attribute) {
|
||||
hide_poly_attribute.finish();
|
||||
}
|
||||
material_index_attribute.finish();
|
||||
hide_vert_attribute.finish();
|
||||
hide_edge_attribute.finish();
|
||||
hide_poly_attribute.finish();
|
||||
|
||||
me->cd_flag = BM_mesh_cd_flag_from_bmesh(bm);
|
||||
}
|
||||
|
@@ -782,9 +782,7 @@ static void execute_realize_pointcloud_tasks(const RealizeInstancesOptions &opti
|
||||
dst_attribute.finish();
|
||||
}
|
||||
positions.finish();
|
||||
if (point_ids) {
|
||||
point_ids.finish();
|
||||
}
|
||||
point_ids.finish();
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -1107,12 +1105,8 @@ static void execute_realize_mesh_tasks(const RealizeInstancesOptions &options,
|
||||
for (GSpanAttributeWriter &dst_attribute : dst_attribute_writers) {
|
||||
dst_attribute.finish();
|
||||
}
|
||||
if (vertex_ids) {
|
||||
vertex_ids.finish();
|
||||
}
|
||||
if (material_indices) {
|
||||
material_indices.finish();
|
||||
}
|
||||
vertex_ids.finish();
|
||||
material_indices.finish();
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -1406,19 +1400,11 @@ static void execute_realize_curve_tasks(const RealizeInstancesOptions &options,
|
||||
for (GSpanAttributeWriter &dst_attribute : dst_attribute_writers) {
|
||||
dst_attribute.finish();
|
||||
}
|
||||
if (point_ids) {
|
||||
point_ids.finish();
|
||||
}
|
||||
if (radius) {
|
||||
radius.finish();
|
||||
}
|
||||
if (resolution) {
|
||||
resolution.finish();
|
||||
}
|
||||
if (all_curves_info.create_handle_postion_attributes) {
|
||||
handle_left.finish();
|
||||
handle_right.finish();
|
||||
}
|
||||
point_ids.finish();
|
||||
radius.finish();
|
||||
resolution.finish();
|
||||
handle_left.finish();
|
||||
handle_right.finish();
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
@@ -382,13 +382,8 @@ BLI_NOINLINE static void compute_attribute_outputs(const Mesh &mesh,
|
||||
}
|
||||
|
||||
ids.finish();
|
||||
|
||||
if (normals) {
|
||||
normals.finish();
|
||||
}
|
||||
if (rotations) {
|
||||
rotations.finish();
|
||||
}
|
||||
normals.finish();
|
||||
rotations.finish();
|
||||
}
|
||||
|
||||
static Array<float> calc_full_density_factors_with_selection(const Mesh &mesh,
|
||||
|
Reference in New Issue
Block a user