[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43510] trunk/blender/source/blender/ makesrna/intern:

Dalai Felinto dfelinto at gmail.com
Wed Jan 18 23:43:01 CET 2012


Revision: 43510
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43510
Author:   dfelinto
Date:     2012-01-18 22:42:57 +0000 (Wed, 18 Jan 2012)
Log Message:
-----------

patch [#29679] Expose connected logic bricks from python
it exposes sensor.controllers and controller.actuators
this is how the data is exposed in blender.

to have controller.sensors or actuator.controllers is not that straightforward

Modified Paths:
--------------
    trunk/blender/source/blender/makesrna/intern/rna_controller.c
    trunk/blender/source/blender/makesrna/intern/rna_sensor.c

Modified: trunk/blender/source/blender/makesrna/intern/rna_controller.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_controller.c	2012-01-18 22:36:19 UTC (rev 43509)
+++ trunk/blender/source/blender/makesrna/intern/rna_controller.c	2012-01-18 22:42:57 UTC (rev 43510)
@@ -48,6 +48,7 @@
 #ifdef RNA_RUNTIME
 
 #include "BKE_sca.h"
+#include "DNA_actuator_types.h"
 
 static struct StructRNA* rna_Controller_refine(struct PointerRNA *ptr)
 {
@@ -132,6 +133,18 @@
 	cont->state_mask = (1 << (value - 1));
 }
 
+static void rna_Controller_actuators_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
+{
+	bController *cont = (bController *)ptr->data;
+	rna_iterator_array_begin(iter, cont->links, sizeof(bActuator *), (int)cont->totlinks, 0, NULL);
+}
+
+static int rna_Controller_actuators_length(PointerRNA *ptr)
+{
+	bController *cont = (bController *)ptr->data;
+	return (int) cont->totlinks;
+}
+
 #if 0 /* editable is set to false, comment for now. */
 static void rna_Controller_state_get(PointerRNA *ptr, int *values)
 {
@@ -212,6 +225,12 @@
 	RNA_def_property_ui_icon(prop, ICON_BOOKMARKS, 1);
 	RNA_def_property_update(prop, NC_LOGIC, NULL);
 
+	prop= RNA_def_property(srna, "actuators", PROP_COLLECTION, PROP_NONE);
+	RNA_def_property_collection_sdna(prop, NULL, "links", NULL);
+	RNA_def_property_struct_type(prop, "Actuator");
+	RNA_def_property_ui_text(prop, "Actuators", "The list containing the actuators connected to the controller");
+	RNA_def_property_collection_funcs(prop, "rna_Controller_actuators_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_dereference_get", "rna_Controller_actuators_length", NULL, NULL, NULL);
+
 	/* State */
 	
 	// array of OB_MAX_STATES

Modified: trunk/blender/source/blender/makesrna/intern/rna_sensor.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_sensor.c	2012-01-18 22:36:19 UTC (rev 43509)
+++ trunk/blender/source/blender/makesrna/intern/rna_sensor.c	2012-01-18 22:42:57 UTC (rev 43510)
@@ -61,6 +61,7 @@
 #ifdef RNA_RUNTIME
 
 #include "BKE_sca.h"
+#include "DNA_controller_types.h"
 
 static StructRNA* rna_Sensor_refine(struct PointerRNA *ptr)
 {
@@ -125,6 +126,19 @@
 }
 
 /* Always keep in alphabetical order */
+
+static void rna_Sensor_controllers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
+{
+	bSensor *sens = (bSensor *)ptr->data;
+	rna_iterator_array_begin(iter, sens->links, sizeof(bController *), (int)sens->totlinks, 0, NULL);
+}
+
+static int rna_Sensor_controllers_length(PointerRNA *ptr)
+{
+	bSensor *sens = (bSensor *)ptr->data;
+	return (int) sens->totlinks;
+}
+
 EnumPropertyItem *rna_Sensor_type_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free)
 {
 	EnumPropertyItem *item= NULL;
@@ -327,6 +341,13 @@
 	RNA_def_property_ui_text(prop, "Tap", "Trigger controllers only for an instant, even while the sensor remains true");
 	RNA_def_property_update(prop, NC_LOGIC, NULL);
 
+	prop= RNA_def_property(srna, "controllers", PROP_COLLECTION, PROP_NONE);
+	RNA_def_property_collection_sdna(prop, NULL, "links", NULL);
+	RNA_def_property_struct_type(prop, "Controller");
+	RNA_def_property_ui_text(prop, "Controllers", "The list containing the controllers connected to the sensor");
+	RNA_def_property_collection_funcs(prop, "rna_Sensor_controllers_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_dereference_get", "rna_Sensor_controllers_length", NULL, NULL, NULL);
+
+
 	RNA_api_sensor(srna);
 }
 



More information about the Bf-blender-cvs mailing list