[Bf-blender-cvs] [a768fd1] gsoc2016-improved_extrusion: Curves: Improved Bezier curve extrusion

João Araújo noreply at git.blender.org
Fri Jun 3 23:18:16 CEST 2016


Commit: a768fd17e0be667879d70d1d883af91d3eb36979
Author: João Araújo
Date:   Mon May 23 19:52:06 2016 +0100
Branches: gsoc2016-improved_extrusion
https://developer.blender.org/rBa768fd17e0be667879d70d1d883af91d3eb36979

Curves: Improved Bezier curve extrusion

This commit incorporates the changes that were suggested in Revision D2017.

The code was made clearer (unnecessary negations were removed) and whitespace was fixed.

This commit was amended to due to some whitespace being left behind.

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

M	source/blender/blenkernel/intern/curve.c
M	source/blender/makesdna/DNA_curve_types.h
M	source/blender/makesrna/intern/rna_curve.c

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

diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index 45fdf73..9d6359a 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -163,7 +163,7 @@ void BKE_curve_init(Curve *cu)
 	/* BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(cu, id)); */  /* cu->type is already initialized... */
 
 	copy_v3_fl(cu->size, 1.0f);
-	cu->flag = CU_FRONT | CU_BACK | CU_DEFORM_BOUNDS_OFF | CU_PATH_RADIUS;
+	cu->flag = CU_FRONT | CU_BACK | CU_DEFORM_BOUNDS_OFF | CU_PATH_RADIUS | CU_SYM_EXTRUDE;
 	cu->pathlen = 100;
 	cu->resolu = cu->resolv = (cu->type == OB_SURF) ? 4 : 12;
 	cu->width = 1.0;
@@ -1782,26 +1782,19 @@ void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp,
         fp = dl->verts;
         fp[0] = fp[1] = 0.0;
         
-        if (!(cu->flag & CU_SYM_EXTRUDE)) { /* if user wants to extrude in both directions */
-            
+        if (cu->flag & CU_SYM_EXTRUDE) { /* if user wants to extrude in both directions */
             fp[2] = -cu->ext1;
             fp[5] = cu->ext1;
         }
         else if (cu->flag & CU_EXTRUDE_REV) { /* if user wants to extrude in the negative direction */
-            
             fp[2] = 0.0;
             fp[5] = -cu->ext1;
-            
         }
         else { /* simple Bezier curve extrusion by the specified amount in the positive local z direction */
-            
             fp[2] = cu->ext1;
 			fp[5] = 0.0;
-            
         }
-        
         fp[3] = fp[4] = 0.0;
-        
 	}
 	else if ( (cu->flag & (CU_FRONT | CU_BACK)) == 0 && cu->ext1 == 0.0f) { // we make a full round bevel in that case
 		nr = 4 + 2 * cu->bevresol;
@@ -1856,21 +1849,15 @@ void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp,
 				fp[1] = (float)(cosf(angle) * (cu->ext2));
 				fp[2] = (float)(sinf(angle) * (cu->ext2));
 
-				if (!(cu->flag & CU_SYM_EXTRUDE)) { /* if user wants to extrude in both directions */
-
+				if (cu->flag & CU_SYM_EXTRUDE) { /* if user wants to extrude in both directions */
 					fp[2] -= cu->ext1;
 				}
 				else if (cu->flag & CU_EXTRUDE_REV) { /* if user wants to extrude in the negative direction */
-
 					fp[2] -= cu->ext1;
-
 				}
 				else { /* simple Bezier curve extrusion by the specified amount in the positive local z direction */
-
 					fp[2] -= 0.0;
-
 				}
-
 				angle += dangle;
 				fp += 3;
 			}
@@ -1893,22 +1880,17 @@ void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp,
 			fp[4] = cu->ext2;
 			fp[5] = cu->ext1;
 
-			if (!(cu->flag & CU_SYM_EXTRUDE)) { /* if user wants to extrude in both directions */
-
+			if (cu->flag & CU_SYM_EXTRUDE) { /* if user wants to extrude in both directions */
 				fp[2] = -cu->ext1;
 				fp[5] = cu->ext1;
 			}
 			else if (cu->flag & CU_EXTRUDE_REV) { /* if user wants to extrude in the negative direction */
-
 				fp[2] = 0.0;
 				fp[5] = -cu->ext1;
-
 			}
 			else { /* simple Bezier curve extrusion by the specified amount in the positive local z direction */
-
 				fp[2] = cu->ext1;
 				fp[5] = 0.0;
-
 			}
 
 			if ( (cu->flag & (CU_FRONT | CU_BACK)) == 0) {
@@ -1922,22 +1904,17 @@ void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp,
 				fp[4] = -fp[4];
 				fp[5] = -fp[5];
 
-				if (!(cu->flag & CU_SYM_EXTRUDE)) { /* if user wants to extrude in both directions */
-
+				if (cu->flag & CU_SYM_EXTRUDE) { /* if user wants to extrude in both directions */
 					fp[2] = -fp[2];
 					fp[5] = -fp[5];
 				}
 				else if (cu->flag & CU_EXTRUDE_REV) { /* if user wants to extrude in the negative direction */
-
 					fp[2] = 0.0;
 					fp[5] = -cu->ext1;
-
 				}
 				else { /* simple Bezier curve extrusion by the specified amount in the positive local z direction */
-
 					fp[2] = cu->ext1;
 					fp[5] = 0.0;
-					
 				}
 			}
 		}
@@ -1966,20 +1943,16 @@ void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp,
 				fp[1] = (float)(cosf(angle) * (cu->ext2));
 				fp[2] = (float)(sinf(angle) * (cu->ext2));
 
-				if (!(cu->flag & CU_SYM_EXTRUDE)) { /* if user wants to extrude in both directions */
-
+				if (cu->flag & CU_SYM_EXTRUDE) { /* if user wants to extrude in both directions */
 					fp[2] += cu->ext1;
 				}
 				else if (cu->flag & CU_EXTRUDE_REV) { /* if user wants to extrude in the negative direction */
-
 					fp[2] += 0.0;
 
 				}
 				else { /* simple Bezier curve extrusion by the specified amount in the positive local z direction */
-
 					fp[2] += cu->ext1;
 				}
-
 				angle += dangle;
 				fp += 3;
 			}
diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h
index 8f10546..e514f84 100644
--- a/source/blender/makesdna/DNA_curve_types.h
+++ b/source/blender/makesdna/DNA_curve_types.h
@@ -302,8 +302,8 @@ enum {
 	CU_DEFORM_FILL        = 1 << 13,  /* fill 2d curve after deformation */
 	CU_FILL_CAPS          = 1 << 14,  /* fill bevel caps */
 	CU_MAP_TAPER          = 1 << 15,  /* map taper object to beveled area */
-    CU_SYM_EXTRUDE        = 1 << 16,  /* in case the user wants the Bezier curve to be extruded in both directions */
-    CU_EXTRUDE_REV        = 1 << 17   /* equivalent to a negative extrude */
+	CU_SYM_EXTRUDE        = 1 << 16,  /* in case the user wants the Bezier curve to be extruded in both directions */
+	CU_EXTRUDE_REV        = 1 << 17   /* equivalent to a negative extrude */
 };
 
 /* Curve.twist_mode */
diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c
index 3a46e09..e7d1973 100644
--- a/source/blender/makesrna/intern/rna_curve.c
+++ b/source/blender/makesrna/intern/rna_curve.c
@@ -1511,11 +1511,10 @@ static void rna_def_curve(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Map Taper", "Map effect of taper object on actually beveled curve");
 	RNA_def_property_update(prop, 0, "rna_Curve_update_data");
     
-    prop = RNA_def_property(srna, "extrude_bezier_symmetric", PROP_BOOLEAN, PROP_NONE);
-    RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CU_SYM_EXTRUDE);
-    // RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_SYM_EXTRUDE);
-    RNA_def_property_ui_text(prop, "Extrude Symmetricaly", "Extrude the Bezier curve the same number of Blender Units in both directions");
-    RNA_def_property_update(prop, 0, "rna_Curve_update_data");
+	prop = RNA_def_property(srna, "extrude_bezier_symmetric", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_SYM_EXTRUDE);
+	RNA_def_property_ui_text(prop, "Extrude Symmetricaly", "Extrude the Bezier curve the same number of Blender Units in both directions");
+	RNA_def_property_update(prop, 0, "rna_Curve_update_data");
     
     prop = RNA_def_property(srna, "reverse_direction", PROP_BOOLEAN, PROP_NONE);
     RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_EXTRUDE_REV);




More information about the Bf-blender-cvs mailing list