[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16361] trunk/blender/source/blender: pin option for sensors and actuators,

Campbell Barton ideasman42 at gmail.com
Thu Sep 4 14:11:48 CEST 2008


Revision: 16361
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16361
Author:   campbellbarton
Date:     2008-09-04 14:11:47 +0200 (Thu, 04 Sep 2008)

Log Message:
-----------
pin option for sensors and actuators,
this helps in cases where you want to use a logic brick in 2 states, linking the sensor to a second state's controller can be tricky.
This way you can pin a sensor or actuator, change the visible state and link it to another controller.

The pin button will only be displayed when states view is enabled and the logic brick is expanded or when it is alredy pinned.

Modified Paths:
--------------
    trunk/blender/source/blender/makesdna/DNA_actuator_types.h
    trunk/blender/source/blender/makesdna/DNA_sensor_types.h
    trunk/blender/source/blender/src/buttons_logic.c

Modified: trunk/blender/source/blender/makesdna/DNA_actuator_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_actuator_types.h	2008-09-04 10:29:41 UTC (rev 16360)
+++ trunk/blender/source/blender/makesdna/DNA_actuator_types.h	2008-09-04 12:11:47 UTC (rev 16361)
@@ -300,6 +300,7 @@
 #define ACT_NEW			4
 #define ACT_LINKED		8	
 #define ACT_VISIBLE		16	
+#define ACT_PIN			32
 
 /* link codes */
 #define LINK_SENSOR		0

Modified: trunk/blender/source/blender/makesdna/DNA_sensor_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_sensor_types.h	2008-09-04 10:29:41 UTC (rev 16360)
+++ trunk/blender/source/blender/makesdna/DNA_sensor_types.h	2008-09-04 12:11:47 UTC (rev 16361)
@@ -218,6 +218,7 @@
 #define SENS_NEW		4
 #define SENS_NOT		8
 #define SENS_VISIBLE	16
+#define SENS_PIN		32
 
 /* sensor->pulse */
 #define SENS_PULSE_CONT 	0

Modified: trunk/blender/source/blender/src/buttons_logic.c
===================================================================
--- trunk/blender/source/blender/src/buttons_logic.c	2008-09-04 10:29:41 UTC (rev 16360)
+++ trunk/blender/source/blender/src/buttons_logic.c	2008-09-04 12:11:47 UTC (rev 16361)
@@ -3105,6 +3105,9 @@
 	int a, iact, stbit, offset;
 	short xco, yco, count, width, ycoo;
 	char *pupstr, name[32];
+	/* pin is a bool used for actuator and sensor drawing with states
+	 * pin so changing states dosnt hide the logic brick */
+	char pin;
 
 	wrld= G.scene->world;
 
@@ -3365,18 +3368,25 @@
 			sens= ob->sensors.first;
 			while(sens) {
 				if (!(G.buts->scaflag & BUTS_SENS_STATE) ||
-					sens->totlinks == 0 ||		/* always display sensor without links so that is can be edited */
-					is_sensor_linked(block, sens)) {
+					 (sens->totlinks == 0) ||		/* always display sensor without links so that is can be edited */
+					 (sens->flag & SENS_PIN && G.buts->scaflag & BUTS_SENS_STATE) || /* states can hide some sensors, pinned sensors ignore the visible state */
+					 (is_sensor_linked(block, sens))
+				) {
+					/* should we draw the pin? - for now always draw when there is a state */
+					pin = (G.buts->scaflag & BUTS_SENS_STATE && (sens->flag & SENS_SHOW || sens->flag & SENS_PIN)) ? 1:0 ;
+					
 					sens->flag |= SENS_VISIBLE;
 					uiBlockSetEmboss(block, UI_EMBOSSM);
 					uiDefIconButBitS(block, TOG, SENS_DEL, B_DEL_SENS, ICON_X,	xco, yco, 22, 19, &sens->flag, 0, 0, 0, 0, "Delete Sensor");
+					if (pin)
+						uiDefIconButBitS(block, ICONTOG, SENS_PIN, B_REDR, (sens->flag & SENS_PIN) ? ICON_PIN_DEHLT:ICON_PIN_HLT, (short)(xco+width-44), yco, 22, 19, &sens->flag, 0, 0, 0, 0, "Display when not linked to a visible states controller");
 					uiDefIconButBitS(block, ICONTOG, SENS_SHOW, B_REDR, ICON_RIGHTARROW, (short)(xco+width-22), yco, 22, 19, &sens->flag, 0, 0, 0, 0, "Sensor settings");
 
 					ycoo= yco;
 					if(sens->flag & SENS_SHOW)
 					{
 						uiDefButS(block, MENU, B_CHANGE_SENS, sensor_pup(),	(short)(xco+22), yco, 80, 19, &sens->type, 0, 0, 0, 0, "Sensor type");
-						but= uiDefBut(block, TEX, 1, "", (short)(xco+102), yco, (short)(width-124), 19, sens->name, 0, 31, 0, 0, "Sensor name");
+						but= uiDefBut(block, TEX, 1, "", (short)(xco+102), yco, (short)(width-(pin?146:124)), 19, sens->name, 0, 31, 0, 0, "Sensor name");
 						uiButSetFunc(but, make_unique_prop_names_cb, sens->name, (void*) 0);
 
 						sens->otype= sens->type;
@@ -3437,16 +3447,22 @@
 			while(act) {
 				if (!(G.buts->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_VISIBLE) ||		/* this actuator has visible connection, display it */
+					 (act->flag & ACT_PIN && G.buts->scaflag & BUTS_ACT_STATE)) {
+					
+					pin = (G.buts->scaflag & BUTS_ACT_STATE && (act->flag & SENS_SHOW || act->flag & SENS_PIN)) ? 1:0 ;
+					
 					act->flag |= ACT_VISIBLE;	/* mark the actuator as visible to help implementing the up/down action */
 					uiBlockSetEmboss(block, UI_EMBOSSM);
 					uiDefIconButBitS(block, TOG, ACT_DEL, B_DEL_ACT, ICON_X,	xco, yco, 22, 19, &act->flag, 0, 0, 0, 0, "Delete Actuator");
-					uiDefIconButBitS(block, ICONTOG, ACT_SHOW, B_REDR, ICON_RIGHTARROW, (short)(xco+width-22), yco, 22, 19, &act->flag, 0, 0, 0, 0, "Actuator settings");
-
+					if (pin)
+						uiDefIconButBitS(block, ICONTOG, ACT_PIN, B_REDR, (act->flag & ACT_PIN) ? ICON_PIN_DEHLT:ICON_PIN_HLT, (short)(xco+width-44), yco, 22, 19, &act->flag, 0, 0, 0, 0, "Display when not linked to a visible states controller");
+					uiDefIconButBitS(block, ICONTOG, ACT_SHOW, B_REDR, ICON_RIGHTARROW, (short)(xco+width-22), yco, 22, 19, &act->flag, 0, 0, 0, 0, "Display the actuator");
+					
 					if(act->flag & ACT_SHOW) {
 						act->otype= act->type;
 						uiDefButS(block, MENU, B_CHANGE_ACT, actuator_pup(ob),	(short)(xco+22), yco, 90, 19, &act->type, 0, 0, 0, 0, "Actuator type");
-						but= uiDefBut(block, TEX, 1, "", (short)(xco+112), yco, (short)(width-134), 19, act->name, 0, 31, 0, 0, "Actuator name");
+						but= uiDefBut(block, TEX, 1, "", (short)(xco+112), yco, (short)(width-(pin?156:134)), 19, act->name, 0, 31, 0, 0, "Actuator name");
 						uiButSetFunc(but, make_unique_prop_names_cb, act->name, (void*) 0);
 
 						ycoo= yco;
@@ -3458,7 +3474,7 @@
 						glRecti((short)(xco+22), yco, (short)(xco+width-22),(short)(yco+19));
 						but= uiDefBut(block, LABEL, 0, actuator_name(act->type), (short)(xco+22), yco, 90, 19, act, 0, 0, 0, 0, "Actuator type");
 						uiButSetFunc(but, sca_move_actuator, act, NULL);
-						but= uiDefBut(block, LABEL, 0, act->name, (short)(xco+112), yco, (short)(width-134), 19, act, 0, 0, 0, 0, "Actuator name");
+						but= uiDefBut(block, LABEL, 0, act->name, (short)(xco+112), yco, (short)(width-156), 19, act, 0, 0, 0, 0, "Actuator name");
 						uiButSetFunc(but, sca_move_actuator, act, NULL);
 						ycoo= yco;
 					}





More information about the Bf-blender-cvs mailing list