[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [23050] branches/blender2.5/blender: - crash fix for setting a curve smooth operator

Campbell Barton ideasman42 at gmail.com
Mon Sep 7 17:02:43 CEST 2009


Revision: 23050
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23050
Author:   campbellbarton
Date:     2009-09-07 17:02:43 +0200 (Mon, 07 Sep 2009)

Log Message:
-----------
- crash fix for setting a curve smooth operator
- added curve attribute use_twist_correction
- added nurb attribute type  - NURBS, POLY, BEZIER
- renamed a number of curve attributes with the use_ prefix.
- UI layout adjustments to only show buttons that are needed and reflect internals for nurbs.
... Note that many of the buttons only apply to NURBS, and all the "V" buttons only apply to surfaces, remove when not needed.

Modified Paths:
--------------
    branches/blender2.5/blender/release/ui/buttons_data_curve.py
    branches/blender2.5/blender/source/blender/editors/object/object_edit.c
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_curve.c

Modified: branches/blender2.5/blender/release/ui/buttons_data_curve.py
===================================================================
--- branches/blender2.5/blender/release/ui/buttons_data_curve.py	2009-09-07 14:58:08 UTC (rev 23049)
+++ branches/blender2.5/blender/release/ui/buttons_data_curve.py	2009-09-07 15:02:43 UTC (rev 23050)
@@ -7,6 +7,13 @@
 	__context__ = "data"
 	
 	def poll(self, context):
+		return (context.object and context.object.type in ('CURVE', 'SURFACE') and context.curve)
+		
+class DataButtonsPanelCurve(DataButtonsPanel):
+	'''
+	Same as above but for curves only
+	'''
+	def poll(self, context):
 		return (context.object and context.object.type == 'CURVE' and context.curve)
 
 class DATA_PT_context_curve(DataButtonsPanel):
@@ -37,17 +44,24 @@
 		ob = context.object
 		curve = context.curve
 		space = context.space_data
+		is_surf = (ob.type == 'SURFACE')
 
-		layout.itemR(curve, "curve_2d")			
+		row = layout.row()
+		row.itemR(curve, "curve_2d")			
+		row.itemR(curve, "use_twist_correction")
+		
 							
 		split = layout.split()
 		
 		col = split.column()
-		sub = col.column()
-		sub.active = curve.curve_2d
-		sub.itemL(text="Caps:")
-		sub.itemR(curve, "front")
-		sub.itemR(curve, "back")
+		
+		if not is_surf:
+			sub = col.column()
+			sub.active = curve.curve_2d
+			sub.itemL(text="Caps:")
+			row = sub.row()
+			row.itemR(curve, "front")
+			row.itemR(curve, "back")
 			
 		col.itemL(text="Textures:")
 #		col.itemR(curve, "uv_orco")
@@ -58,23 +72,26 @@
 		sub = col.column(align=True)
 		sub.itemR(curve, "resolution_u", text="Preview U")
 		sub.itemR(curve, "render_resolution_u", text="Render U")
-		sub = col.column(align=True)
-		sub.itemR(curve, "resolution_v", text="Preview V")
-		sub.itemR(curve, "render_resolution_v", text="Render V")
+		
+		if is_surf:
+			sub = col.column(align=True)
+			sub.itemR(curve, "resolution_v", text="Preview V")
+			sub.itemR(curve, "render_resolution_v", text="Render V")
+		
 
 #		col.itemL(text="Display:")
 #		col.itemL(text="HANDLES")
 #		col.itemL(text="NORMALS")
 #		col.itemR(curve, "vertex_normal_flip")
 
-class DATA_PT_geometry_curve(DataButtonsPanel):
+class DATA_PT_geometry_curve(DataButtonsPanelCurve):
 	__label__ = "Geometry "
 
 	def draw(self, context):
 		layout = self.layout
 		
 		curve = context.curve
-
+		
 		split = layout.split()
 	
 		col = split.column()
@@ -88,31 +105,32 @@
 		col.itemR(curve, "bevel_depth", text="Depth")
 		col.itemR(curve, "bevel_resolution", text="Resolution")
 		col.itemR(curve, "bevel_object", icon='ICON_OUTLINER_OB_CURVE')
+
 	
-class DATA_PT_pathanim(DataButtonsPanel):
+class DATA_PT_pathanim(DataButtonsPanelCurve):
 	__label__ = "Path Animation"
 	
 	def draw_header(self, context):
 		curve = context.curve
 
-		self.layout.itemR(curve, "path", text="")
+		self.layout.itemR(curve, "use_path", text="")
 
 	def draw(self, context):
 		layout = self.layout
 		
 		curve = context.curve
 		
-		layout.active = curve.path	
+		layout.active = curve.use_path	
 		
 		split = layout.split()		
 		
 		col = split.column()
 		col.itemR(curve, "path_length", text="Frames")
-		col.itemR(curve, "follow")
+		col.itemR(curve, "use_path_follow")
 
 		col = split.column()
-		col.itemR(curve, "stretch")
-		col.itemR(curve, "offset_path_distance", text="Offset Children")
+		col.itemR(curve, "use_stretch")
+		col.itemR(curve, "use_time_offset", text="Offset Children")
 	
 class DATA_PT_current_curve(DataButtonsPanel):
 	__label__ = "Current Curve"
@@ -120,33 +138,56 @@
 	def draw(self, context):
 		layout = self.layout
 		
+		ob = context.object
 		currentcurve = context.curve.curves[0] # XXX
-
+		is_surf = (ob.type == 'SURFACE')
+		
 		split = layout.split()
-	
+		
 		col = split.column()
 		col.itemL(text="Cyclic:")
+		if currentcurve.type == 'NURBS':
+			col.itemL(text="Bezier:")
+			col.itemL(text="Endpoint:")
+			col.itemL(text="Order:")
+		col.itemL(text="Resolution:")
+		
+		
+		col = split.column()
 		col.itemR(currentcurve, "cyclic_u", text="U")
-		col.itemR(currentcurve, "cyclic_v", text="V")
-		col.itemL(text="Order:")
-		col.itemR(currentcurve, "order_u", text="U")
-		col.itemR(currentcurve, "order_v", text="V")
-		col.itemL(text="Endpoints:")
-		col.itemR(currentcurve, "endpoint_u", text="U")
-		col.itemR(currentcurve, "endpoint_v", text="V")
 		
+		if currentcurve.type == 'NURBS':
+			sub = col.column()
+			sub.active = (not currentcurve.cyclic_u)
+			sub.itemR(currentcurve, "bezier_u", text="U")
+			sub.itemR(currentcurve, "endpoint_u", text="U")
+			
+			sub = col.column()
+			sub.itemR(currentcurve, "order_u", text="U")
+		col.itemR(currentcurve, "resolution_u", text="U")
+		
+		if is_surf:
+			col = split.column()
+			col.itemR(currentcurve, "cyclic_v", text="V")
+			
+			# its a surface, assume its a nurb.
+			sub = col.column()
+			sub.active = (not currentcurve.cyclic_v)
+			sub.itemR(currentcurve, "bezier_v", text="V")
+			sub.itemR(currentcurve, "endpoint_v", text="V")
+			sub = col.column()
+			sub.itemR(currentcurve, "resolution_v", text="V")
+			sub.itemR(currentcurve, "order_v", text="V")
+		
+		
+		split = layout.split()
 		col = split.column()
-		col.itemL(text="Bezier:")
-		col.itemR(currentcurve, "bezier_u", text="U")
-		col.itemR(currentcurve, "bezier_v", text="V")
-		col.itemL(text="Resolution:")
-		col.itemR(currentcurve, "resolution_u", text="U")
-		col.itemR(currentcurve, "resolution_v", text="V")
 		col.itemL(text="Interpolation:")
 		col.itemR(currentcurve, "tilt_interpolation", text="Tilt")
-		col.itemR(currentcurve, "radius_interpolation", text="Tilt")
+		col.itemR(currentcurve, "radius_interpolation", text="Radius")
 		col.itemR(currentcurve, "smooth")
 		
+		
 bpy.types.register(DATA_PT_context_curve)
 bpy.types.register(DATA_PT_shape_curve)
 bpy.types.register(DATA_PT_geometry_curve)

Modified: branches/blender2.5/blender/source/blender/editors/object/object_edit.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/object/object_edit.c	2009-09-07 14:58:08 UTC (rev 23049)
+++ branches/blender2.5/blender/source/blender/editors/object/object_edit.c	2009-09-07 15:02:43 UTC (rev 23050)
@@ -6816,7 +6816,6 @@
 			for(nu=cu->nurb.first; nu; nu=nu->next) {
 				if(!clear) nu->flag |= ME_SMOOTH;
 				else nu->flag &= ~ME_SMOOTH;
-				nu= nu->next;
 			}
 
 			DAG_id_flush_update(&ob->id, OB_RECALC_DATA);

Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_curve.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_curve.c	2009-09-07 14:58:08 UTC (rev 23049)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_curve.c	2009-09-07 15:02:43 UTC (rev 23050)
@@ -148,6 +148,20 @@
 	return nu->pntsv>0 ? nu->pntsu*nu->pntsv : nu->pntsu;
 }
 
+/* grr! mixing CU_2D with type is dodgy */
+static int rna_Nurb_type_get(PointerRNA *ptr)
+{
+	Nurb *nu= (Nurb*)ptr->data;
+	return nu->type & 7;
+}
+
+static void rna_Nurb_type_set(PointerRNA *ptr, int value)
+{
+	Nurb *nu= (Nurb*)ptr->data;
+	nu->type &= CU_2D;
+	nu->type |= value;
+}
+
 static void rna_BPoint_array_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
 {
 	Nurb *nu= (Nurb*)ptr->data;
@@ -161,7 +175,6 @@
 	DAG_id_flush_update(id, OB_RECALC_DATA);
 	WM_event_add_notifier(C, NC_GEOM|ND_DATA, id);
 }
-
 #else
 
 static void rna_def_bpoint(BlenderRNA *brna)
@@ -203,7 +216,7 @@
 	RNA_def_property_ui_text(prop, "Weight", "Softbody goal weight");
 	RNA_def_property_update(prop, 0, "rna_Curve_update_data");
 
-	prop= RNA_def_property(srna, "bevel_radius", PROP_FLOAT, PROP_NONE);
+	prop= RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_float_sdna(prop, NULL, "radius");
 	/*RNA_def_property_range(prop, 0.0f, 1.0f);*/
 	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
@@ -297,7 +310,7 @@
 	RNA_def_property_ui_text(prop, "Weight", "Softbody goal weight");
 	RNA_def_property_update(prop, 0, "rna_Curve_update_data");
 
-	prop= RNA_def_property(srna, "bevel_radius", PROP_FLOAT, PROP_NONE);
+	prop= RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_float_sdna(prop, NULL, "radius");
 	/*RNA_def_property_range(prop, 0.0f, 1.0f);*/
 	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
@@ -317,22 +330,22 @@
 	RNA_def_property_update(prop, 0, "rna_Curve_update_data");
 	
 	/* flags */
-	prop= RNA_def_property(srna, "path", PROP_BOOLEAN, PROP_NONE);
+	prop= RNA_def_property(srna, "use_path", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_PATH);
 	RNA_def_property_ui_text(prop, "Path", "Enable the curve to become a translation path.");
 	RNA_def_property_update(prop, 0, "rna_Curve_update_data");
 	
-	prop= RNA_def_property(srna, "follow", PROP_BOOLEAN, PROP_NONE);
+	prop= RNA_def_property(srna, "use_path_follow", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_FOLLOW);
 	RNA_def_property_ui_text(prop, "Follow", "Make curve path children to rotate along the path.");
 	RNA_def_property_update(prop, 0, "rna_Curve_update_data");
 	
-	prop= RNA_def_property(srna, "stretch", PROP_BOOLEAN, PROP_NONE);
+	prop= RNA_def_property(srna, "use_stretch", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_STRETCH);
 	RNA_def_property_ui_text(prop, "Stretch", "Option for curve-deform: makes deformed child to stretch along entire path.");
 	RNA_def_property_update(prop, 0, "rna_Curve_update_data");
 	
-	prop= RNA_def_property(srna, "offset_path_distance", PROP_BOOLEAN, PROP_NONE);
+	prop= RNA_def_property(srna, "use_time_offset", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_OFFS_PATHDIST);
 	RNA_def_property_ui_text(prop, "Offset Path Distance", "Children will use TimeOffs value as path distance offset.");
 	RNA_def_property_update(prop, 0, "rna_Curve_update_data");
@@ -677,6 +690,11 @@
 	RNA_def_property_ui_text(prop, "Back", "Draw filled back for extruded/beveled curves.");
 	RNA_def_property_update(prop, 0, "rna_Curve_update_data");
 	
+	prop= RNA_def_property(srna, "use_twist_correction", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_NO_TWIST);
+	RNA_def_property_ui_text(prop, "Minimal Twist", "Correct for twisting.");
+	RNA_def_property_update(prop, 0, "rna_Curve_update_data");
+
 	prop= RNA_def_property(srna, "retopo", PROP_BOOLEAN, PROP_NONE);

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list