[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22187] branches/blender2.5/blender/source /blender/makesrna/intern/rna_curve.c: * add notifications for rna updates to curve.

Nathan Letwory jesterking at letwory.net
Mon Aug 3 17:06:57 CEST 2009


Revision: 22187
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22187
Author:   jesterking
Date:     2009-08-03 17:06:56 +0200 (Mon, 03 Aug 2009)

Log Message:
-----------
* add notifications for rna updates to curve. This gives realtime updates for curves in editmode. If someone knows how to get this to work for object mode too, that'd be great.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_curve.c

Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_curve.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_curve.c	2009-08-03 14:56:46 UTC (rev 22186)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_curve.c	2009-08-03 15:06:56 UTC (rev 22187)
@@ -33,6 +33,8 @@
 #include "DNA_material_types.h"
 #include "DNA_scene_types.h"
 
+#include "BKE_font.h"
+
 EnumPropertyItem beztriple_handle_type_items[] = {
 		{HD_FREE, "FREE", 0, "Free", ""},
 		{HD_AUTO, "AUTO", 0, "Auto", ""},
@@ -52,7 +54,11 @@
 #include "DNA_object_types.h"
 
 #include "BKE_curve.h"
+#include "BKE_depsgraph.h"
 
+#include "WM_api.h"
+#include "WM_types.h"
+
 StructRNA *rna_Curve_refine(PointerRNA *ptr)
 {
 	Curve *cu= (Curve*)ptr->data;
@@ -142,6 +148,15 @@
 	rna_iterator_array_begin(iter, (void*)nu->bp, sizeof(BPoint*), nu->pntsv>0 ? nu->pntsu*nu->pntsv : nu->pntsu, 0, NULL);
 }
 
+static void rna_Curve_update(bContext *C, PointerRNA *ptr)
+{
+	Scene *scene= CTX_data_scene(C);
+	Object *obedit= CTX_data_edit_object(C);
+
+	DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
+	WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, scene);
+}
+
 #else
 
 static void rna_def_bpoint(BlenderRNA *brna)
@@ -157,32 +172,38 @@
 	prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "f1", 0);
 	RNA_def_property_ui_text(prop, "Selected", "Selection status");
+	RNA_def_property_update(prop, 0, "rna_Curve_update");
 
 	prop= RNA_def_property(srna, "hidden", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "hide", 0);
 	RNA_def_property_ui_text(prop, "Hidden", "Visibility status");
+	RNA_def_property_update(prop, 0, "rna_Curve_update");
 
 	/* Vector value */
 	prop= RNA_def_property(srna, "point", PROP_FLOAT, PROP_VECTOR);
 	RNA_def_property_array(prop, 4);
 	RNA_def_property_float_sdna(prop, NULL, "vec");
 	RNA_def_property_ui_text(prop, "Point", "Point coordinates");
+	RNA_def_property_update(prop, 0, "rna_Curve_update");
 
 	/* Number values */
 	prop= RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_float_sdna(prop, NULL, "alfa");
 	/*RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);*/
 	RNA_def_property_ui_text(prop, "Tilt", "Tilt in 3d View");
+	RNA_def_property_update(prop, 0, "rna_Curve_update");
 
 	prop= RNA_def_property(srna, "weight", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_range(prop, 0.01f, 100.0f);
 	RNA_def_property_ui_text(prop, "Weight", "Softbody goal weight");
+	RNA_def_property_update(prop, 0, "rna_Curve_update");
 
 	prop= RNA_def_property(srna, "bevel_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);
 	RNA_def_property_ui_text(prop, "Bevel Radius", "Radius for bevelling");
+	RNA_def_property_update(prop, 0, "rna_Curve_update");
 }
 
 static void rna_def_beztriple(BlenderRNA *brna)
@@ -193,72 +214,86 @@
 	srna= RNA_def_struct(brna, "BezierCurvePoint", NULL);
 	RNA_def_struct_sdna(srna, "BezTriple");
 	RNA_def_struct_ui_text(srna, "Bezier Curve Point", "Bezier curve point with two handles.");
+	RNA_def_property_update(prop, 0, "rna_Curve_update");
 
 	/* Boolean values */
 	prop= RNA_def_property(srna, "selected_handle1", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "f1", 0);
 	RNA_def_property_ui_text(prop, "Handle 1 selected", "Handle 1 selection status");
+	RNA_def_property_update(prop, 0, "rna_Curve_update");
 
 	prop= RNA_def_property(srna, "selected_handle2", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "f3", 0);
 	RNA_def_property_ui_text(prop, "Handle 2 selected", "Handle 2 selection status");
+	RNA_def_property_update(prop, 0, "rna_Curve_update");
 
 	prop= RNA_def_property(srna, "selected_control_point", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "f2", 0);
 	RNA_def_property_ui_text(prop, "Control Point selected", "Control point selection status");
+	RNA_def_property_update(prop, 0, "rna_Curve_update");
 
 	prop= RNA_def_property(srna, "hidden", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "hide", 0);
 	RNA_def_property_ui_text(prop, "Hidden", "Visibility status");
+	RNA_def_property_update(prop, 0, "rna_Curve_update");
 
 	/* Enums */
 	prop= RNA_def_property(srna, "handle1_type", PROP_ENUM, PROP_NONE);
 	RNA_def_property_enum_sdna(prop, NULL, "h1");
 	RNA_def_property_enum_items(prop, beztriple_handle_type_items);
 	RNA_def_property_ui_text(prop, "Handle 1 Type", "Handle types");
+	RNA_def_property_update(prop, 0, "rna_Curve_update");
 
 	prop= RNA_def_property(srna, "handle2_type", PROP_ENUM, PROP_NONE);
 	RNA_def_property_enum_sdna(prop, NULL, "h2");
 	RNA_def_property_enum_items(prop, beztriple_handle_type_items);
 	RNA_def_property_ui_text(prop, "Handle 2 Type", "Handle types");
+	RNA_def_property_update(prop, 0, "rna_Curve_update");
 
 	prop= RNA_def_property(srna, "interpolation", PROP_ENUM, PROP_NONE);
 	RNA_def_property_enum_sdna(prop, NULL, "ipo");
 	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 	RNA_def_property_enum_items(prop, beztriple_interpolation_mode_items);
 	RNA_def_property_ui_text(prop, "Interpolation", "(For F-Curves Only) Interpolation to use for segment of curve starting from current BezTriple.");
+	RNA_def_property_update(prop, 0, "rna_Curve_update");
 
 	/* Vector values */
 	prop= RNA_def_property(srna, "handle1", PROP_FLOAT, PROP_VECTOR);
 	RNA_def_property_array(prop, 3);
 	RNA_def_property_float_funcs(prop, "rna_BezTriple_handle1_get", "rna_BezTriple_handle1_set", NULL);
 	RNA_def_property_ui_text(prop, "Handle 1", "Coordinates of the first handle");
+	RNA_def_property_update(prop, 0, "rna_Curve_update");
 
 	prop= RNA_def_property(srna, "control_point", PROP_FLOAT, PROP_VECTOR);
 	RNA_def_property_array(prop, 3);
 	RNA_def_property_float_funcs(prop, "rna_BezTriple_ctrlpoint_get", "rna_BezTriple_ctrlpoint_set", NULL);
 	RNA_def_property_ui_text(prop, "Control Point", "Coordinates of the control point");
+	RNA_def_property_update(prop, 0, "rna_Curve_update");
 
 	prop= RNA_def_property(srna, "handle2", PROP_FLOAT, PROP_VECTOR);
 	RNA_def_property_array(prop, 3);
 	RNA_def_property_float_funcs(prop, "rna_BezTriple_handle2_get", "rna_BezTriple_handle2_set", NULL);
 	RNA_def_property_ui_text(prop, "Handle 2", "Coordinates of the second handle");
+	RNA_def_property_update(prop, 0, "rna_Curve_update");
 
 	/* Number values */
 	prop= RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_float_sdna(prop, NULL, "alfa");
 	/*RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);*/
 	RNA_def_property_ui_text(prop, "Tilt", "Tilt in 3d View");
+	RNA_def_property_update(prop, 0, "rna_Curve_update");
 
 	prop= RNA_def_property(srna, "weight", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_range(prop, 0.01f, 100.0f);
 	RNA_def_property_ui_text(prop, "Weight", "Softbody goal weight");
+	RNA_def_property_update(prop, 0, "rna_Curve_update");
 
 	prop= RNA_def_property(srna, "bevel_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);
 	RNA_def_property_ui_text(prop, "Bevel Radius", "Radius for bevelling");
+	RNA_def_property_update(prop, 0, "rna_Curve_update");
 }
 
 static void rna_def_path(BlenderRNA *brna, StructRNA *srna)
@@ -270,23 +305,28 @@
 	RNA_def_property_int_sdna(prop, NULL, "pathlen");
 	RNA_def_property_range(prop, 1, 32767);
 	RNA_def_property_ui_text(prop, "Path Length", "If no speed IPO was set, the length of path in frames.");
+	RNA_def_property_update(prop, 0, "rna_Curve_update");
 	
 	/* flags */
 	prop= RNA_def_property(srna, "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");
 	
 	prop= RNA_def_property(srna, "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");
 	
 	prop= RNA_def_property(srna, "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");
 	
 	prop= RNA_def_property(srna, "offset_path_distance", 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");
 }
 
 static void rna_def_nurbs(BlenderRNA *brna, StructRNA *srna)
@@ -297,10 +337,12 @@
 	prop= RNA_def_property(srna, "uv_orco", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_UV_ORCO);
 	RNA_def_property_ui_text(prop, "UV Orco", "Forces to use UV coordinates for texture mapping 'orco'.");
+	RNA_def_property_update(prop, 0, "rna_Curve_update");
 	
 	prop= RNA_def_property(srna, "vertex_normal_flip", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CU_NOPUNOFLIP);
 	RNA_def_property_ui_text(prop, "Vertex Normal Flip", "Flip vertex normals towards the camera during render");
+	RNA_def_property_update(prop, 0, "rna_Curve_update");
 }
 
 static void rna_def_font(BlenderRNA *brna, StructRNA *srna)
@@ -319,52 +361,62 @@
 	prop= RNA_def_property(srna, "spacemode", PROP_ENUM, PROP_NONE);
 	RNA_def_property_enum_items(prop, prop_align_items);
 	RNA_def_property_ui_text(prop, "Text Align", "Text align from the object center.");
+	RNA_def_property_update(prop, 0, "rna_Curve_update");
 	
 	/* number values */
 	prop= RNA_def_property(srna, "text_size", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_float_sdna(prop, NULL, "fsize");
 	RNA_def_property_range(prop, 0.1f, 10.0f);
 	RNA_def_property_ui_text(prop, "Font size", "");
+	RNA_def_property_update(prop, 0, "rna_Curve_update");
 	

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list