[Bf-blender-cvs] [51e73e99569] master: Fix crash whith Simple Solidify and Bevel Convex.

Henrik Dick noreply at git.blender.org
Wed Apr 15 11:09:31 CEST 2020


Commit: 51e73e99569d92068d26327aac636fc35db9dcff
Author: Henrik Dick
Date:   Wed Apr 15 10:57:03 2020 +0200
Branches: master
https://developer.blender.org/rB51e73e99569d92068d26327aac636fc35db9dcff

Fix crash whith Simple Solidify and Bevel Convex.

After recent changes, simple solidify modifier would crash with Fill Rim
turned off and Bevel Convex emabled.

Also fixes that simple solidify would not set the bevel weight flag so the
next modifier could use the bevel weights.

Simple cleanup with do_rim is also included.

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D7428

===================================================================

M	source/blender/modifiers/intern/MOD_solidify_extrude.c

===================================================================

diff --git a/source/blender/modifiers/intern/MOD_solidify_extrude.c b/source/blender/modifiers/intern/MOD_solidify_extrude.c
index 56ec7796b0d..3ba64ce084f 100644
--- a/source/blender/modifiers/intern/MOD_solidify_extrude.c
+++ b/source/blender/modifiers/intern/MOD_solidify_extrude.c
@@ -236,8 +236,8 @@ Mesh *MOD_solidify_extrude_applyModifier(ModifierData *md,
   const bool do_clamp = (smd->offset_clamp != 0.0f);
   const bool do_angle_clamp = do_clamp && (smd->flag & MOD_SOLIDIFY_OFFSET_ANGLE_CLAMP) != 0;
   const bool do_bevel_convex = bevel_convex != 0.0f;
-  const bool do_shell = ((smd->flag & MOD_SOLIDIFY_RIM) && (smd->flag & MOD_SOLIDIFY_NOSHELL)) ==
-                        0;
+  const bool do_rim = (smd->flag & MOD_SOLIDIFY_RIM) == 0;
+  const bool do_shell = do_rim && (smd->flag & MOD_SOLIDIFY_NOSHELL) == 0;
 
   /* weights */
   MDeformVert *dvert;
@@ -274,7 +274,7 @@ Mesh *MOD_solidify_extrude_applyModifier(ModifierData *md,
   STACK_INIT(new_vert_arr, numVerts * 2);
   STACK_INIT(new_edge_arr, numEdges * 2);
 
-  if (smd->flag & MOD_SOLIDIFY_RIM) {
+  if (do_rim) {
     BLI_bitmap *orig_mvert_tag = BLI_BITMAP_NEW(numVerts, __func__);
     uint eidx;
     uint i;
@@ -373,6 +373,11 @@ Mesh *MOD_solidify_extrude_applyModifier(ModifierData *md,
   medge = result->medge;
   mvert = result->mvert;
 
+  if (do_bevel_convex) {
+    /* Make sure bweight is enabled. */
+    result->cd_flag |= ME_CDFLAG_EDGE_BWEIGHT;
+  }
+
   if (do_shell) {
     CustomData_copy_data(&mesh->vdata, &result->vdata, 0, 0, (int)numVerts);
     CustomData_copy_data(&mesh->vdata, &result->vdata, 0, (int)numVerts, (int)numVerts);
@@ -534,6 +539,9 @@ Mesh *MOD_solidify_extrude_applyModifier(ModifierData *md,
       }
       if (do_bevel_convex) {
         edge_angs = MEM_malloc_arrayN(numEdges, sizeof(float), "edge_angs");
+        if (!do_rim) {
+          edge_users = MEM_malloc_arrayN(numEdges, sizeof(*edge_users), "solid_mod edges");
+        }
       }
       uint(*edge_user_pairs)[2] = MEM_malloc_arrayN(
           numEdges, sizeof(*edge_user_pairs), "edge_user_pairs");
@@ -578,6 +586,9 @@ Mesh *MOD_solidify_extrude_applyModifier(ModifierData *md,
           }
           if (do_bevel_convex) {
             edge_angs[i] = angle;
+            if (!do_rim) {
+              edge_users[i] = INVALID_PAIR;
+            }
           }
         }
       }
@@ -698,6 +709,9 @@ Mesh *MOD_solidify_extrude_applyModifier(ModifierData *md,
           }
         }
       }
+      if (!do_rim) {
+        MEM_freeN(edge_users);
+      }
       MEM_freeN(edge_angs);
     }
 
@@ -810,6 +824,9 @@ Mesh *MOD_solidify_extrude_applyModifier(ModifierData *md,
       }
       if (do_bevel_convex) {
         edge_angs = MEM_malloc_arrayN(numEdges, sizeof(float), "edge_angs even");
+        if (!do_rim) {
+          edge_users = MEM_malloc_arrayN(numEdges, sizeof(*edge_users), "solid_mod edges");
+        }
       }
       uint(*edge_user_pairs)[2] = MEM_malloc_arrayN(
           numEdges, sizeof(*edge_user_pairs), "edge_user_pairs");
@@ -853,6 +870,9 @@ Mesh *MOD_solidify_extrude_applyModifier(ModifierData *md,
             sub_v3_v3v3(e, orig_mvert[ed->v1].co, orig_mvert[ed->v2].co);
             normalize_v3(e);
             edge_angs[i] = angle_signed_on_axis_v3v3_v3(n0, n1, e);
+            if (!do_rim) {
+              edge_users[i] = INVALID_PAIR;
+            }
           }
         }
       }
@@ -916,6 +936,9 @@ Mesh *MOD_solidify_extrude_applyModifier(ModifierData *md,
           }
         }
       }
+      if (!do_rim) {
+        MEM_freeN(edge_users);
+      }
       MEM_freeN(edge_angs);
     }
 
@@ -961,7 +984,7 @@ Mesh *MOD_solidify_extrude_applyModifier(ModifierData *md,
   }
 
   /* must recalculate normals with vgroups since they can displace unevenly [#26888] */
-  if ((mesh->runtime.cd_dirty_vert & CD_MASK_NORMAL) || (smd->flag & MOD_SOLIDIFY_RIM) || dvert) {
+  if ((mesh->runtime.cd_dirty_vert & CD_MASK_NORMAL) || do_rim || dvert) {
     result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
   }
   else if (do_shell) {
@@ -1003,7 +1026,7 @@ Mesh *MOD_solidify_extrude_applyModifier(ModifierData *md,
       }
     }
   }
-  if (smd->flag & MOD_SOLIDIFY_RIM) {
+  if (do_rim) {
     uint i;
 
     /* bugger, need to re-calculate the normals for the new edge faces.



More information about the Bf-blender-cvs mailing list