diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index 296deca67cd..80d2c3e0549 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -397,9 +397,6 @@ typedef struct MLoopNorSpace { * - BMLoop pointers. */ struct LinkNode *loops; char flags; - - /** To be used for extended processing related to loop normal spaces (aka smooth fans). */ - void *user_data; } MLoopNorSpace; /** * MLoopNorSpace.flags diff --git a/source/blender/modifiers/intern/MOD_weighted_normal.cc b/source/blender/modifiers/intern/MOD_weighted_normal.cc index b03f2b2317c..d47b0847226 100644 --- a/source/blender/modifiers/intern/MOD_weighted_normal.cc +++ b/source/blender/modifiers/intern/MOD_weighted_normal.cc @@ -214,6 +214,7 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd, blender::Array loop_normals; WeightedNormalDataAggregateItem *items_data = nullptr; + Array item_index_per_corner(corner_verts.size(), 0); int items_num = 0; if (keep_sharp) { BLI_bitmap *done_loops = BLI_BITMAP_NEW(corner_verts.size(), __func__); @@ -255,7 +256,7 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd, itdt->curr_strength = FACE_STRENGTH_WEAK; MLoopNorSpace *lnor_space = lnors_spacearr.lspacearr[ml_index]; - lnor_space->user_data = itdt; + item_index_per_corner[ml_index] = item_index; if (!(lnor_space->flags & MLNOR_SPACE_IS_SINGLE)) { for (LinkNode *lnode = lnor_space->loops; lnode; lnode = lnode->next) { @@ -294,9 +295,7 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd, for (const int ml_index : polys[poly_index]) { const int mv_index = corner_verts[ml_index]; WeightedNormalDataAggregateItem *item_data = - keep_sharp ? static_cast( - lnors_spacearr.lspacearr[ml_index]->user_data) : - &items_data[mv_index]; + keep_sharp ? &items_data[item_index_per_corner[ml_index]] : &items_data[mv_index]; aggregate_item_normal( wnmd, wn_data, item_data, mv_index, poly_index, mp_val, use_face_influence); @@ -312,9 +311,7 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd, const int poly_index = loop_to_poly[ml_index]; const int mv_index = corner_verts[ml_index]; WeightedNormalDataAggregateItem *item_data = - keep_sharp ? static_cast( - lnors_spacearr.lspacearr[ml_index]->user_data) : - &items_data[mv_index]; + keep_sharp ? &items_data[item_index_per_corner[ml_index]] : &items_data[mv_index]; aggregate_item_normal( wnmd, wn_data, item_data, mv_index, poly_index, ml_val, use_face_influence); @@ -337,8 +334,7 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd, * (before this modifier is applied, at start of this function), * so no need to recompute them here. */ for (int ml_index = 0; ml_index < corner_verts.size(); ml_index++) { - WeightedNormalDataAggregateItem *item_data = static_cast( - lnors_spacearr.lspacearr[ml_index]->user_data); + WeightedNormalDataAggregateItem *item_data = &items_data[item_index_per_corner[ml_index]]; if (!is_zero_v3(item_data->normal)) { copy_v3_v3(loop_normals[ml_index], item_data->normal); } @@ -366,7 +362,7 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd, /* NOTE: in theory, we could avoid this extra allocation & copying... * But think we can live with it for now, * and it makes code simpler & cleaner. */ - blender::Array vert_normals(verts_num, float3(0)); + blender::Array vert_normals(verts_num, float3(0.0f)); for (int ml_index = 0; ml_index < corner_verts.size(); ml_index++) { const int mv_index = corner_verts[ml_index];