Commit: f78ca97cfcce148eba96e656a235442d3e3e37d1
Author: Hans Goudey
Date:   Sun Mar 1 22:19:17 2020 -0600
Branches: master
https://developer.blender.org/rBf78ca97cfcce148eba96e656a235442d3e3e37d1

Bevel: Z-Up Custom Profile Orientation

When beveling architectural objects like baseboards or crown mouldings that
may consist of multiple islands, it's useful if the orientation is at least
conistent.

This changes the arbitrary decision of how the orientation should start at a
chain beginning to use the highest side of the profile in the Z direction.

Reviewed By: howardt

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

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

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

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

diff --git a/source/blender/bmesh/tools/bmesh_bevel.c 
b/source/blender/bmesh/tools/bmesh_bevel.c
index 0ff89aa3127..e99f6699173 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -3132,22 +3132,22 @@ static EdgeHalf *next_edgehalf_bev(BevelParams *bp,
  */
 static void regularize_profile_orientation(BevelParams *bp, BMEdge *bme)
 {
-  BevVert *start_bv;
-  BevVert *bv;
-  EdgeHalf *start_edgehalf, *edgehalf;
-  bool toward_bv;
-
-  start_bv = find_bevvert(bp, bme->v1);
-  start_edgehalf = find_edge_half(start_bv, bme);
+  BevVert *start_bv = find_bevvert(bp, bme->v1);
+  EdgeHalf *start_edgehalf = find_edge_half(start_bv, bme);
   if (!start_edgehalf->is_bev || start_edgehalf->visited_rpo) {
     return;
   }
 
-  /* Pick a BoundVert on one side of the profile to use for the start of the 
profile. */
-  start_edgehalf->leftv->is_profile_start = false;
+  /* Pick a BoundVert on one side of the profile to use for the starting side. 
Use the one highest
+   * on the Z axis because even any rule is better than an arbitrary decision. 
*/
+  bool right_highest = start_edgehalf->leftv->nv.co[2] < 
start_edgehalf->rightv->nv.co[2];
+  start_edgehalf->leftv->is_profile_start = right_highest;
   start_edgehalf->visited_rpo = true;
 
   /* First loop starts in the away from BevVert direction and the second 
starts toward it. */
+  bool toward_bv;
+  BevVert *bv;
+  EdgeHalf *edgehalf;
   for (int i = 0; i < 2; i++) {
     edgehalf = start_edgehalf;
     bv = start_bv;
@@ -3160,11 +3160,11 @@ static void regularize_profile_orientation(BevelParams 
*bp, BMEdge *bme)
        * The direction relative to the BevVert switches every step, so also 
switch
        * the orientation every step. */
       if (i == 0) {
-        edgehalf->leftv->is_profile_start = toward_bv;
+        edgehalf->leftv->is_profile_start = toward_bv ^ right_highest;
       }
       else {
         /* The opposite side as the first direction because we're moving the 
other way. */
-        edgehalf->leftv->is_profile_start = !toward_bv;
+        edgehalf->leftv->is_profile_start = !toward_bv ^ right_highest;
       }
 
       /* The next jump will in the opposite direction relative to the BevVert. 
*/

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to