[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29587] trunk/blender/source/blender: Logic UI: Pin option for sensor and actuators (from 2.49)

Dalai Felinto dfelinto at gmail.com
Mon Jun 21 09:51:40 CEST 2010


Revision: 29587
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29587
Author:   dfelinto
Date:     2010-06-21 09:51:40 +0200 (Mon, 21 Jun 2010)

Log Message:
-----------
Logic UI: Pin option for sensor and actuators (from 2.49)

- implemented the old functionality of pin a sensor or actuator when "show state" is on.
- fixed code for setting/resetting VISIBLE and LINKED flags for sensors and actuators
(so states buttons is working for actuators and sensors)
- move the flag setting code (^^^) to a pre-processing part of the logic ui code.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_logic/logic_window.c
    trunk/blender/source/blender/makesrna/intern/rna_actuator.c
    trunk/blender/source/blender/makesrna/intern/rna_sensor.c
    trunk/blender/source/blender/makesrna/intern/rna_space.c

Modified: trunk/blender/source/blender/editors/space_logic/logic_window.c
===================================================================
--- trunk/blender/source/blender/editors/space_logic/logic_window.c	2010-06-21 06:55:18 UTC (rev 29586)
+++ trunk/blender/source/blender/editors/space_logic/logic_window.c	2010-06-21 07:51:40 UTC (rev 29587)
@@ -3172,7 +3172,7 @@
 
 /* Sensors code */
 
-static void draw_sensor_header(uiLayout *layout, PointerRNA *ptr)
+static void draw_sensor_header(uiLayout *layout, PointerRNA *ptr, PointerRNA *logic_ptr)
 {
 	uiLayout *box, *row;
 	
@@ -3182,6 +3182,11 @@
 	uiItemR(row, ptr, "expanded", UI_ITEM_R_NO_BG, "", 0);
 	uiItemR(row, ptr, "type", 0, "", 0);
 	uiItemR(row, ptr, "name", 0, "", 0);
+
+	// XXX in 2.49 we make the pin to dis/appear. In 2.50 may be better to simply enable/disable it
+	if (RNA_boolean_get(logic_ptr, "sensors_show_active_states") && (RNA_boolean_get(ptr, "expanded") || RNA_boolean_get(ptr, "pinned")))
+		uiItemR(row, ptr, "pinned", UI_ITEM_R_NO_BG, "", 0);
+
 	uiItemO(row, "", ICON_X, "LOGIC_OT_sensor_remove");
 }
 
@@ -3584,7 +3589,7 @@
 }
 
 /* Actuator code */
-static void draw_actuator_header(uiLayout *layout, PointerRNA *ptr)
+static void draw_actuator_header(uiLayout *layout, PointerRNA *ptr, PointerRNA *logic_ptr)
 {
 	uiLayout *box, *row;
 	
@@ -3594,6 +3599,11 @@
 	uiItemR(row, ptr, "expanded", UI_ITEM_R_NO_BG, "", 0);
 	uiItemR(row, ptr, "type", 0, "", 0);
 	uiItemR(row, ptr, "name", 0, "", 0);
+
+	// XXX in 2.49 we make the pin to dis/appear. In 2.50 may be better to simply enable/disable it
+	if (RNA_boolean_get(logic_ptr, "actuators_show_active_states") && (RNA_boolean_get(ptr, "expanded") || RNA_boolean_get(ptr, "pinned")))
+		uiItemR(row, ptr, "pinned", UI_ITEM_R_NO_BG, "", 0);
+
 	uiItemO(row, "", ICON_X, "LOGIC_OT_actuator_remove");
 }
 
@@ -4367,13 +4377,17 @@
 	block= uiBeginBlock(C, ar, name, UI_EMBOSS);
 	uiBlockSetHandleFunc(block, do_logic_buts, NULL);
 	
-	/* clean ACT_LINKED and ACT_VISIBLE of all potentially visible actuators so that 
-	 we can determine which is actually linked/visible */
+	/* loop over all objects and set visible/linked flags for the logic bricks */
 	for(a=0; a<count; a++) {
 		bActuator *act;
 		bSensor *sens;
+		bController *cont;
+		int iact;
+		short flag;
+
 		ob= (Object *)idar[a];
 		
+		/* clean ACT_LINKED and ACT_VISIBLE of all potentially visible actuators so that we can determine which is actually linked/visible */
 		act = ob->actuators.first;
 		while(act) {
 			act->flag &= ~(ACT_LINKED|ACT_VISIBLE);
@@ -4385,6 +4399,23 @@
 			sens->flag &= ~(SENS_VISIBLE);
 			sens = sens->next;
 		}
+
+		/* mark the linked and visible actuators */
+		cont= ob->controllers.first;
+		while(cont) {
+			flag = ACT_LINKED;
+
+			/* this controller is visible, mark all its actuator */
+			if ((ob->scaflag & OB_ALLSTATE) || (ob->state & cont->state_mask))
+				flag |= ACT_VISIBLE;
+
+			for (iact=0; iact<cont->totlinks; iact++) {
+				act = cont->links[iact];
+				if (act)
+					act->flag |= flag;
+			}
+			cont = cont->next;
+		}
 	}
 	
 	/* ****************** Controllers ****************** */
@@ -4452,17 +4483,7 @@
 			
 			if (!(ob->scaflag & OB_ALLSTATE) && !(ob->state & cont->state_mask))
 				continue;
-			//if (!(cont->state_mask & (1<<stbit))) 
-			//	continue;
 			
-			/* this controller is visible, mark all its actuator */
-			/* XXX: perhaps move this to a preprocessing stage if possible? */
-			for (iact=0; iact<cont->totlinks; iact++) {
-				bActuator *act = cont->links[iact];
-				if (act)
-					act->flag |= ACT_VISIBLE;
-			}
-			
 			/* use two nested splits to align inlinks/links properly */
 			split = uiLayoutSplit(layout, 0.05, 0);
 			
@@ -4526,7 +4547,7 @@
 			RNA_pointer_create((ID *)ob, &RNA_Sensor, sens, &ptr);
 			
 			if ((ob->scaflag & OB_ALLSTATE) ||
-				(slogic->scaflag & BUTS_SENS_STATE) ||
+				!(slogic->scaflag & BUTS_SENS_STATE) ||
 				(sens->totlinks == 0) ||											/* always display sensor without links so that is can be edited */
 				(sens->flag & SENS_PIN && slogic->scaflag & BUTS_SENS_STATE) ||	/* states can hide some sensors, pinned sensors ignore the visible state */
 				(is_sensor_linked(block, sens))
@@ -4539,7 +4560,7 @@
 				uiLayoutSetContextPointer(col, "sensor", &ptr);
 				
 				/* should make UI template for sensor header.. function will do for now */
-				draw_sensor_header(col, &ptr);
+				draw_sensor_header(col, &ptr, &logic_ptr);
 				
 				/* draw the brick contents */
 				draw_brick_sensor(col, &ptr, C);
@@ -4586,7 +4607,7 @@
 			RNA_pointer_create((ID *)ob, &RNA_Actuator, act, &ptr);
 			
 			if ((ob->scaflag & OB_ALLSTATE) ||
-				(slogic->scaflag & BUTS_ACT_STATE) ||
+				!(slogic->scaflag & BUTS_ACT_STATE) ||
 				!(act->flag & ACT_LINKED) ||		/* always display actuators without links so that is can be edited */
 				(act->flag & ACT_VISIBLE) ||		/* this actuator has visible connection, display it */
 				(act->flag & ACT_PIN && slogic->scaflag & BUTS_ACT_STATE)	/* states can hide some sensors, pinned sensors ignore the visible state */
@@ -4604,7 +4625,7 @@
 				uiLayoutSetContextPointer(col, "actuator", &ptr);
 				
 				/* should make UI template for actuator header.. function will do for now */
-				draw_actuator_header(col, &ptr);
+				draw_actuator_header(col, &ptr, &logic_ptr);
 				
 				/* draw the brick contents */
 				draw_brick_actuator(col, &ptr, C);

Modified: trunk/blender/source/blender/makesrna/intern/rna_actuator.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_actuator.c	2010-06-21 06:55:18 UTC (rev 29586)
+++ trunk/blender/source/blender/makesrna/intern/rna_actuator.c	2010-06-21 07:51:40 UTC (rev 29587)
@@ -476,6 +476,12 @@
 	RNA_def_property_enum_funcs(prop, NULL, "rna_Actuator_type_set", "rna_Actuator_type_itemf");
 	RNA_def_property_ui_text(prop, "Type", "");
 
+	prop= RNA_def_property(srna, "pinned", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_PIN);
+	RNA_def_property_ui_text(prop, "Pinned", "Display when not linked to a visible states controller");
+	RNA_def_property_ui_icon(prop, ICON_UNPINNED, 1);
+	RNA_def_property_update(prop, NC_LOGIC, NULL);
+
 	prop= RNA_def_property(srna, "expanded", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_SHOW);
 	RNA_def_property_ui_text(prop, "Expanded", "Set actuator expanded in the user interface");

Modified: trunk/blender/source/blender/makesrna/intern/rna_sensor.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_sensor.c	2010-06-21 06:55:18 UTC (rev 29586)
+++ trunk/blender/source/blender/makesrna/intern/rna_sensor.c	2010-06-21 07:51:40 UTC (rev 29587)
@@ -260,6 +260,12 @@
 	RNA_def_property_ui_text(prop, "Type", "");
 	RNA_def_property_update(prop, NC_LOGIC, NULL);
 
+	prop= RNA_def_property(srna, "pinned", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", SENS_PIN);
+	RNA_def_property_ui_text(prop, "Pinned", "Display when not linked to a visible states controller");
+	RNA_def_property_ui_icon(prop, ICON_UNPINNED, 1);
+	RNA_def_property_update(prop, NC_LOGIC, NULL);
+
 	prop= RNA_def_property(srna, "expanded", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", SENS_SHOW);
 	RNA_def_property_ui_text(prop, "Expanded", "Set sensor expanded in the user interface");

Modified: trunk/blender/source/blender/makesrna/intern/rna_space.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_space.c	2010-06-21 06:55:18 UTC (rev 29586)
+++ trunk/blender/source/blender/makesrna/intern/rna_space.c	2010-06-21 07:51:40 UTC (rev 29587)
@@ -2202,7 +2202,7 @@
 	RNA_def_property_update(prop, NC_LOGIC, NULL);
 
 	prop= RNA_def_property(srna, "sensors_show_active_states", PROP_BOOLEAN, PROP_NONE);
-	RNA_def_property_boolean_negative_sdna(prop, NULL, "scaflag", BUTS_SENS_STATE);
+	RNA_def_property_boolean_sdna(prop, NULL, "scaflag", BUTS_SENS_STATE);
 	RNA_def_property_ui_text(prop, "Show Active States", "Show only sensors connected to active states");
 	RNA_def_property_update(prop, NC_LOGIC, NULL);
 
@@ -2239,7 +2239,7 @@
 	RNA_def_property_update(prop, NC_LOGIC, NULL);
 
 	prop= RNA_def_property(srna, "actuators_show_active_states", PROP_BOOLEAN, PROP_NONE);
-	RNA_def_property_boolean_negative_sdna(prop, NULL, "scaflag", BUTS_ACT_STATE);
+	RNA_def_property_boolean_sdna(prop, NULL, "scaflag", BUTS_ACT_STATE);
 	RNA_def_property_ui_text(prop, "Show Active States", "Show only actuators connected to active states");
 	RNA_def_property_update(prop, NC_LOGIC, NULL);
 





More information about the Bf-blender-cvs mailing list