[Bf-blender-cvs] [1d32aa2] gsoc2016-improved_extrusion: Curves: Improved Bezier Curve Extrusion

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


Commit: 1d32aa2b7f71eaa7b05c924c42d846960acabaf5
Author: João Araújo
Date:   Fri Jun 3 22:09:08 2016 +0100
Branches: gsoc2016-improved_extrusion
https://developer.blender.org/rB1d32aa2b7f71eaa7b05c924c42d846960acabaf5

Curves: Improved Bezier Curve Extrusion

After implementing the changes suggested, backwards compatibility was broken. In order to fix that, the whole feature had to be reimplemented, replacing the symmetric extrusion option (which has been the default until now in Blender) with an unidirectional extrude one.

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

M	release/scripts/startup/bl_ui/properties_data_curve.py
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/release/scripts/startup/bl_ui/properties_data_curve.py b/release/scripts/startup/bl_ui/properties_data_curve.py
index e80dd20..58e7004 100644
--- a/release/scripts/startup/bl_ui/properties_data_curve.py
+++ b/release/scripts/startup/bl_ui/properties_data_curve.py
@@ -173,9 +173,9 @@ class DATA_PT_geometry_curve(CurveButtonsPanelCurve, Panel):
         col.prop(curve, "offset")
         col.prop(curve, "extrude")
         sub = col.row()
-        sub.prop(curve, "extrude_bezier_symmetric")
+        sub.prop(curve, "extrude_bezier_unidirectional")
         sub = col.row()
-        sub.active = curve.extrude_bezier_symmetric is False
+        sub.active = curve.extrude_bezier_unidirectional is True
         sub.prop(curve, "reverse_direction")
         col.label(text="Taper Object:")
         col.prop(curve, "taper_object", text="")
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index 9d6359a..601206a 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_SYM_EXTRUDE;
+	cu->flag = CU_FRONT | CU_BACK | CU_DEFORM_BOUNDS_OFF | CU_PATH_RADIUS;
 	cu->pathlen = 100;
 	cu->resolu = cu->resolv = (cu->type == OB_SURF) ? 4 : 12;
 	cu->width = 1.0;
@@ -1781,19 +1781,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 */
-            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;
+
+		if (cu->flag & CU_EXTRUDE_REV && cu->flag & CU_UNI_EXTRUDE) { /* if user wants to extrude in the negative direction */
+			fp[2] = 0.0;
+			fp[5] = -cu->ext1;
+		}
+		else if (cu->flag & CU_UNI_EXTRUDE) { /* simple Bezier curve extrusion by the specified amount in the positive local z direction */
+			fp[2] = cu->ext1;
 			fp[5] = 0.0;
-        }
+		}
+		else { /* extrusion in both directions */
+			fp[2] = -cu->ext1;
+			fp[5] = cu->ext1;
+		}
         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
@@ -1849,15 +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_EXTRUDE_REV && cu->flag & CU_UNI_EXTRUDE) { /* if user wants to extrude in the negative direction */
 					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 */
+				else if (cu->flag & CU_UNI_EXTRUDE) { /* simple Bezier curve extrusion by the specified amount in the positive local z direction */
 					fp[2] -= 0.0;
 				}
+				else { /* extrusion in both directions */
+					fp[2] -= cu->ext1;
+				}
 				angle += dangle;
 				fp += 3;
 			}
@@ -1880,18 +1880,18 @@ 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 */
-				fp[2] = -cu->ext1;
-				fp[5] = cu->ext1;
-			}
-			else if (cu->flag & CU_EXTRUDE_REV) { /* if user wants to extrude in the negative direction */
+			if (cu->flag & CU_EXTRUDE_REV && cu->flag & CU_UNI_EXTRUDE) { /* 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 */
+			else if (cu->flag & CU_UNI_EXTRUDE) { /* simple Bezier curve extrusion by the specified amount in the positive local z direction */
 				fp[2] = cu->ext1;
 				fp[5] = 0.0;
 			}
+			else { /* extrusion in both directions */
+				fp[2] = -cu->ext1;
+				fp[5] = cu->ext1;
+			}
 
 			if ( (cu->flag & (CU_FRONT | CU_BACK)) == 0) {
 				dl = MEM_dupallocN(dl);
@@ -1904,18 +1904,18 @@ 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 */
-					fp[2] = -fp[2];
-					fp[5] = -fp[5];
-				}
-				else if (cu->flag & CU_EXTRUDE_REV) { /* if user wants to extrude in the negative direction */
+				if (cu->flag & CU_EXTRUDE_REV && cu->flag & CU_UNI_EXTRUDE) { /* 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 */
+				else if (cu->flag & CU_UNI_EXTRUDE) { /* simple Bezier curve extrusion by the specified amount in the positive local z direction */
 					fp[2] = cu->ext1;
 					fp[5] = 0.0;
 				}
+				else { /* extrusion in both directions */
+					fp[2] = -fp[2];
+					fp[5] = -fp[5];
+				}
 			}
 		}
 
@@ -1943,14 +1943,13 @@ 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 */
-					fp[2] += cu->ext1;
-				}
-				else if (cu->flag & CU_EXTRUDE_REV) { /* if user wants to extrude in the negative direction */
+				if (cu->flag & CU_EXTRUDE_REV && cu->flag & CU_UNI_EXTRUDE) { /* 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 */
+				else if (cu->flag & CU_UNI_EXTRUDE) { /* simple Bezier curve extrusion by the specified amount in the positive local z direction */
+					fp[2] += cu->ext1;
+				}
+				else { /* extrusion in both directions */
 					fp[2] += cu->ext1;
 				}
 				angle += dangle;
diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h
index e514f84..3ad427d 100644
--- a/source/blender/makesdna/DNA_curve_types.h
+++ b/source/blender/makesdna/DNA_curve_types.h
@@ -302,7 +302,7 @@ 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_UNI_EXTRUDE        = 1 << 16,  /* in case the user wants the Bezier curve to be extruded in only one direction */
 	CU_EXTRUDE_REV        = 1 << 17   /* equivalent to a negative extrude */
 };
 
diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c
index e7d1973..6f1734b 100644
--- a/source/blender/makesrna/intern/rna_curve.c
+++ b/source/blender/makesrna/intern/rna_curve.c
@@ -1511,9 +1511,9 @@ 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_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");
+	prop = RNA_def_property(srna, "extrude_bezier_unidirectional", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_UNI_EXTRUDE);
+	RNA_def_property_ui_text(prop, "Unidirectional Extrude", "Extrude the Bezier curve only in one direction");
 	RNA_def_property_update(prop, 0, "rna_Curve_update_data");
     
     prop = RNA_def_property(srna, "reverse_direction", PROP_BOOLEAN, PROP_NONE);




More information about the Bf-blender-cvs mailing list