[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30870] branches/soc-2010-aligorith-2: Bullet SoC - Manipulator API - Operator Linking working

Joshua Leung aligorith at gmail.com
Thu Jul 29 09:29:31 CEST 2010


Revision: 30870
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30870
Author:   aligorith
Date:     2010-07-29 09:29:31 +0200 (Thu, 29 Jul 2010)

Log Message:
-----------
Bullet SoC - Manipulator API - Operator Linking working

I've restored an earlier attempt at fixing this problem, but using the id-name of the operator instead of a reference to the operator/operator type when defining the operator used by the manipulator.

Not really my preferred option (is much less direct), but RNA refused to allow the other version:
"TypeError: validating class error: Manipulator.bl_operator expected a Operator type"

Modified Paths:
--------------
    branches/soc-2010-aligorith-2/release/scripts/manipulators/manips_transform.py
    branches/soc-2010-aligorith-2/source/blender/makesrna/intern/rna_wm.c
    branches/soc-2010-aligorith-2/source/blender/windowmanager/WM_types.h

Modified: branches/soc-2010-aligorith-2/release/scripts/manipulators/manips_transform.py
===================================================================
--- branches/soc-2010-aligorith-2/release/scripts/manipulators/manips_transform.py	2010-07-29 07:22:43 UTC (rev 30869)
+++ branches/soc-2010-aligorith-2/release/scripts/manipulators/manips_transform.py	2010-07-29 07:29:31 UTC (rev 30870)
@@ -35,7 +35,7 @@
 class MANIPULATOR_MANIP_test(bpy.types.Manipulator):
 	bl_label = "Test Manipulator"
 	bl_description = "A manipulator to run us through our paces"
-	#bl_operator = MANIPULATOR_OT_activeop_test
+	bl_operator = "MANIPULATOR_OT_activeop_test"
 	bl_icon = 'RADIO'
 	bl_draw_space = 'POST_PIXEL'
 	

Modified: branches/soc-2010-aligorith-2/source/blender/makesrna/intern/rna_wm.c
===================================================================
--- branches/soc-2010-aligorith-2/source/blender/makesrna/intern/rna_wm.c	2010-07-29 07:22:43 UTC (rev 30869)
+++ branches/soc-2010-aligorith-2/source/blender/makesrna/intern/rna_wm.c	2010-07-29 07:29:31 UTC (rev 30870)
@@ -1039,6 +1039,7 @@
 static char _manipulator_idname[MANIP_MAX_TYPENAME];
 static char _manipulator_name[MANIP_MAX_TYPENAME];
 static char _manipulator_descr[1024];
+static char _manipulator_otname[OP_MAX_TYPENAME];
 static StructRNA *rna_Manipulator_register(const bContext *C, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
 {
 	wmManipulatorType dummyType = {0};
@@ -1052,6 +1053,7 @@
 	dummyType.idname= _manipulator_idname; /* only assigne the pointer, string is NULL'd */
 	dummyType.name= _manipulator_name; /* only assigne the pointer, string is NULL'd */
 	dummyType.description= _manipulator_descr; /* only assigne the pointer, string is NULL'd */
+	dummyType.ot_idname = _manipulator_otname; /* only assigne the pointer, string is NULL'd */
 	RNA_pointer_create(NULL, &RNA_Manipulator, &dummyMan, &dummyTypeR);
 
 	/* validate the python class */
@@ -1063,8 +1065,9 @@
 		int idlen = strlen(_manipulator_idname) + 7;
 		int namelen = strlen(_manipulator_name) + 1;
 		int desclen = strlen(_manipulator_descr) + 1;
+		int otlen = strlen(_manipulator_otname) + 3;
 		char *ch, *ch_arr;
-		ch_arr= ch= MEM_callocN(sizeof(char) * (idlen + namelen + desclen), "_manipulator_idname"); /* 2 terminators and 3 to convert a.b -> A_OT_b */
+		ch_arr= ch= MEM_callocN(sizeof(char) * (idlen + namelen + desclen + otlen), "_manipulator_idname"); /* 2 terminators and 3 to convert a.b -> A_OT_b */
 		WM_manipulator_bl_idname(ch, _manipulator_idname); /* convert the idname from python */
 		dummyType.idname= ch;
 		ch += idlen;
@@ -1073,6 +1076,9 @@
 		ch += namelen;
 		strcpy(ch, _manipulator_descr);
 		dummyType.description = ch;
+		ch += desclen;
+		WM_operator_bl_idname(ch, _manipulator_otname); /* convert the idname from python */
+		dummyType.ot_idname= ch;
 	}
 
 	if (strlen(identifier) >= sizeof(dummyMan.idname)) {
@@ -1098,6 +1104,8 @@
 	dummyType.draw_idle 		= (have_function[2])? manipulator_draw_idle: NULL;
 	dummyType.draw_active 		= (have_function[3])? manipulator_draw_active: NULL;
 	
+	dummyType.ot = WM_operatortype_find(dummyType.ot_idname, 1);
+	
 	WM_manipulatortype_append_ptr(manipulator_wrapper, (void *)&dummyType);
 
 	/* update while blender is running */
@@ -1493,12 +1501,10 @@
 	RNA_def_property_string_maxlength(prop, 1024); /* else it uses the pointer size! */
 	RNA_def_property_flag(prop, PROP_REGISTER);
 	
-#if 0 // xxx - temp testing only!
-	prop= RNA_def_property(srna, "bl_operator", PROP_POINTER, PROP_NONE);
-	RNA_def_property_struct_type(prop, "Operator"); // XXX: complains about being wrong type!
-	RNA_def_property_pointer_sdna(prop, NULL, "type->ot");
+	prop= RNA_def_property(srna, "bl_operator", PROP_STRING, PROP_NONE);
+	RNA_def_property_string_sdna(prop, NULL, "type->ot_idname");
+	RNA_def_property_string_maxlength(prop, OP_MAX_TYPENAME); /* else it uses the pointer size! */
 	RNA_def_property_flag(prop, PROP_REGISTER);
-#endif	
 	
 	prop= RNA_def_property(srna, "bl_icon", PROP_ENUM, PROP_NONE);
 	RNA_def_property_enum_sdna(prop, NULL, "type->icon");

Modified: branches/soc-2010-aligorith-2/source/blender/windowmanager/WM_types.h
===================================================================
--- branches/soc-2010-aligorith-2/source/blender/windowmanager/WM_types.h	2010-07-29 07:22:43 UTC (rev 30869)
+++ branches/soc-2010-aligorith-2/source/blender/windowmanager/WM_types.h	2010-07-29 07:29:31 UTC (rev 30870)
@@ -442,7 +442,8 @@
 	short draw_space;		/* REGION_DRAW_* settings used for ED_region_draw_cb_* stuff */
 	
 	/* 'Active' State Modal Operator (Type) */
-	struct wmOperatorType *ot;
+	char *ot_idname;			/* ID-Name of Operator Type (for Py-Registration) */
+	struct wmOperatorType *ot;	/* Operator Type */
 	
 	/* rna for properties */
 	struct StructRNA *srna;





More information about the Bf-blender-cvs mailing list