[Bf-blender-cvs] [30158b6ed06] master: Fix T74256, crash in bmesh.ops.bevel if segments not set.

Howard Trickey noreply at git.blender.org
Thu Feb 27 22:36:48 CET 2020


Commit: 30158b6ed0648a875fd7d2c98b3377d4bbe1e5fb
Author: Howard Trickey
Date:   Thu Feb 27 16:36:17 2020 -0500
Branches: master
https://developer.blender.org/rB30158b6ed0648a875fd7d2c98b3377d4bbe1e5fb

Fix T74256, crash in bmesh.ops.bevel if segments not set.

Also changed signature of bevel function to take integer
for segments instead of float, which is just wrong.

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

M	source/blender/bmesh/tools/bmesh_bevel.c
M	source/blender/bmesh/tools/bmesh_bevel.h

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

diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c
index d8c2057bb56..0ff89aa3127 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -7145,7 +7145,7 @@ static void bevel_limit_offset(BevelParams *bp, BMesh *bm)
 void BM_mesh_bevel(BMesh *bm,
                    const float offset,
                    const int offset_type,
-                   const float segments,
+                   const int segments,
                    const float profile,
                    const bool vertex_only,
                    const bool use_weights,
@@ -7176,7 +7176,7 @@ void BM_mesh_bevel(BMesh *bm,
 
   bp.offset = offset;
   bp.offset_type = offset_type;
-  bp.seg = (int)segments;
+  bp.seg = segments;
   bp.profile = profile;
   bp.pro_super_r = -logf(2.0) / logf(sqrtf(profile)); /* Convert to superellipse exponent. */
   bp.vertex_only = vertex_only;
@@ -7207,6 +7207,10 @@ void BM_mesh_bevel(BMesh *bm,
     bp.miter_inner = BEVEL_MITER_SHARP;
   }
 
+  if (bp.seg <= 1) {
+    bp.seg = 1;
+  }
+
   if (profile >= 0.950f) { /* r ~ 692, so PRO_SQUARE_R is 1e4 */
     bp.pro_super_r = PRO_SQUARE_R;
   }
diff --git a/source/blender/bmesh/tools/bmesh_bevel.h b/source/blender/bmesh/tools/bmesh_bevel.h
index 45bebbb33ce..479a8a3f6d6 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.h
+++ b/source/blender/bmesh/tools/bmesh_bevel.h
@@ -27,7 +27,7 @@ struct MDeformVert;
 void BM_mesh_bevel(BMesh *bm,
                    const float offset,
                    const int offset_type,
-                   const float segments,
+                   const int segments,
                    const float profile,
                    const bool vertex_only,
                    const bool use_weights,



More information about the Bf-blender-cvs mailing list