[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15519] trunk/blender/source: Adding an option for action actuator - "Continue" this means animations always play from where they left off.

Campbell Barton ideasman42 at gmail.com
Thu Jul 10 16:24:18 CEST 2008


Revision: 15519
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15519
Author:   campbellbarton
Date:     2008-07-10 16:23:19 +0200 (Thu, 10 Jul 2008)

Log Message:
-----------
Adding an option for action actuator - "Continue" this means animations always play from where they left off. Continue was the 2.46 operation too, so new functionality is the option to disable.

When using states, an action like kick or throw can often switch out before finishing playing the action, and there was no way to play from the start frame the second time round. (even setting the actions current frame through python doesn't work work)

Modified Paths:
--------------
    trunk/blender/source/blender/makesdna/DNA_actuator_types.h
    trunk/blender/source/blender/src/buttons_logic.c
    trunk/blender/source/gameengine/Converter/BL_ActionActuator.cpp
    trunk/blender/source/gameengine/Converter/BL_ActionActuator.h
    trunk/blender/source/gameengine/Converter/KX_ConvertActuators.cpp
    trunk/blender/source/gameengine/PyDoc/BL_ActionActuator.py

Modified: trunk/blender/source/blender/makesdna/DNA_actuator_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_actuator_types.h	2008-07-10 12:49:55 UTC (rev 15518)
+++ trunk/blender/source/blender/makesdna/DNA_actuator_types.h	2008-07-10 14:23:19 UTC (rev 15519)
@@ -51,8 +51,9 @@
 	int	sta, end;		/* Start & End frames */			
 	char	name[32];		/* For property-driven playback */	
 	char	frameProp[32];	/* Set this property to the actions current frame */
-	int	blendin;		/* Number of frames of blending */	
-	short	priority;		/* Execution priority */			
+	short	blendin;		/* Number of frames of blending */
+	short	priority;		/* Execution priority */
+	short	end_reset;	/* Ending the actuator (negative pulse) wont reset the the action to its starting frame */
 	short	strideaxis;		/* Displacement axis */
 	float	stridelength;	/* Displacement incurred by cycle */
 } bActionActuator;												

Modified: trunk/blender/source/blender/src/buttons_logic.c
===================================================================
--- trunk/blender/source/blender/src/buttons_logic.c	2008-07-10 12:49:55 UTC (rev 15518)
+++ trunk/blender/source/blender/src/buttons_logic.c	2008-07-10 14:23:19 UTC (rev 15519)
@@ -1769,23 +1769,27 @@
 #else
 			str= "Action types   %t|Play %x0|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x6";
 #endif
-			uiDefButS(block, MENU, B_REDR, str, xco+30, yco-24, (width-60)/2, 19, &aa->type, 0.0, 0.0, 0.0, 0.0, "Action playback type");
-			uiDefIDPoinBut(block, test_actionpoin_but, ID_AC, 1, "AC: ", xco+30 + ((width-60)/2), yco-24, (width-60)/2, 19, &aa->act, "Action name");
+			uiDefButS(block, MENU, B_REDR, str, xco+10, yco-24, width/3, 19, &aa->type, 0.0, 0.0, 0.0, 0.0, "Action playback type");
+			uiDefIDPoinBut(block, test_actionpoin_but, ID_AC, 1, "AC: ", xco+10+ (width/3), yco-24, ((width/3)*2) - (20 + 60), 19, &aa->act, "Action name");
 			
+			uiDefButBitS(block, TOGN, 1, 0, "Continue", xco+((width/3)*2)+20, yco-24, 60, 19,
+					 &aa->end_reset, 0.0, 0.0, 0, 0, "Restore last frame when switching on/off, otherwise play from the start each time");
+			
+			
 			if(aa->type == ACT_ACTION_FROM_PROP)
 			{
-				uiDefBut(block, TEX, 0, "Prop: ",xco+30, yco-44, width-60, 19, aa->name, 0.0, 31.0, 0, 0, "Use this property to define the Action position");
+				uiDefBut(block, TEX, 0, "Prop: ",xco+10, yco-44, width-20, 19, aa->name, 0.0, 31.0, 0, 0, "Use this property to define the Action position");
 			}
 			else
 			{
-				uiDefButI(block, NUM, 0, "Sta: ",xco+30, yco-44, (width-60)/2, 19, &aa->sta, 0.0, MAXFRAMEF, 0, 0, "Start frame");
-				uiDefButI(block, NUM, 0, "End: ",xco+30+(width-60)/2, yco-44, (width-60)/2, 19, &aa->end, 0.0, MAXFRAMEF, 0, 0, "End frame");
+				uiDefButI(block, NUM, 0, "Sta: ",xco+10, yco-44, (width-20)/2, 19, &aa->sta, 0.0, MAXFRAMEF, 0, 0, "Start frame");
+				uiDefButI(block, NUM, 0, "End: ",xco+10+(width-20)/2, yco-44, (width-20)/2, 19, &aa->end, 0.0, MAXFRAMEF, 0, 0, "End frame");
 			}
 						
-			uiDefButI(block, NUM, 0, "Blendin: ", xco+30, yco-64, (width-60)/2, 19, &aa->blendin, 0.0, MAXFRAMEF, 0.0, 0.0, "Number of frames of motion blending");
-			uiDefButS(block, NUM, 0, "Priority: ", xco+30+(width-60)/2, yco-64, (width-60)/2, 19, &aa->priority, 0.0, 100.0, 0.0, 0.0, "Execution priority - lower numbers will override actions with higher numbers, With 2 or more actions at once, the overriding channels must be lower in the stack");
+			uiDefButS(block, NUM, 0, "Blendin: ", xco+10, yco-64, (width-20)/2, 19, &aa->blendin, 0.0, 32767, 0.0, 0.0, "Number of frames of motion blending");
+			uiDefButS(block, NUM, 0, "Priority: ", xco+10+(width-20)/2, yco-64, (width-20)/2, 19, &aa->priority, 0.0, 100.0, 0.0, 0.0, "Execution priority - lower numbers will override actions with higher numbers, With 2 or more actions at once, the overriding channels must be lower in the stack");
 			
-			uiDefBut(block, TEX, 0, "FrameProp: ",xco+30, yco-84, width-60, 19, aa->frameProp, 0.0, 31.0, 0, 0, "Assign this property this actions current frame number");			
+			uiDefBut(block, TEX, 0, "FrameProp: ",xco+10, yco-84, width-20, 19, aa->frameProp, 0.0, 31.0, 0, 0, "Assign this property this actions current frame number");			
 
 			
 #ifdef __NLA_ACTION_BY_MOTION_ACTUATOR

Modified: trunk/blender/source/gameengine/Converter/BL_ActionActuator.cpp
===================================================================
--- trunk/blender/source/gameengine/Converter/BL_ActionActuator.cpp	2008-07-10 12:49:55 UTC (rev 15518)
+++ trunk/blender/source/gameengine/Converter/BL_ActionActuator.cpp	2008-07-10 14:23:19 UTC (rev 15519)
@@ -184,6 +184,11 @@
 		
 		if (bNegativeEvent)
 		{
+			// dont continue where we left off when restarting
+			if (m_end_reset) {
+				m_flag &= ~ACT_FLAG_LOCKINPUT;
+			}
+			
 			if (!(m_flag & ACT_FLAG_ACTIVE))
 				return false;
 			m_flag &= ~ACT_FLAG_ACTIVE;
@@ -472,8 +477,10 @@
 	{"getFrameProperty", (PyCFunction) BL_ActionActuator::sPyGetFrameProperty, METH_VARARGS, GetFrameProperty_doc},
 	{"setChannel", (PyCFunction) BL_ActionActuator::sPySetChannel, METH_VARARGS, SetChannel_doc},
 //	{"getChannel", (PyCFunction) BL_ActionActuator::sPyGetChannel, METH_VARARGS},
-	{"getType", (PyCFunction) BL_ActionActuator::sPyGetType, METH_VARARGS, GetType_doc},	
+	{"getType", (PyCFunction) BL_ActionActuator::sPyGetType, METH_VARARGS, GetType_doc},
 	{"setType", (PyCFunction) BL_ActionActuator::sPySetType, METH_VARARGS, SetType_doc},
+	{"getContinue", (PyCFunction) BL_ActionActuator::sPyGetContinue, METH_NOARGS, 0},	
+	{"setContinue", (PyCFunction) BL_ActionActuator::sPySetContinue, METH_O, 0},
 	{NULL,NULL} //Sentinel
 };
 
@@ -978,7 +985,26 @@
 	default:
 		printf("Invalid type for action actuator: %d\n", typeArg); /* error */
     }
+	Py_RETURN_NONE;
+}
+
+PyObject* BL_ActionActuator::PyGetContinue(PyObject* self) {
+    return PyInt_FromLong((long)(m_end_reset==0));
+}
+
+PyObject* BL_ActionActuator::PySetContinue(PyObject* self, PyObject* value) {
+	int param = PyObject_IsTrue( value );
 	
-    Py_Return;
+	if( param == -1 ) {
+		PyErr_SetString( PyExc_TypeError, "expected True/False or 0/1" );
+		return NULL;
+	}
+
+	if (param) {
+		m_end_reset = 0;
+	} else {
+		m_end_reset = 1;
+	}
+    Py_RETURN_NONE;
 }
 

Modified: trunk/blender/source/gameengine/Converter/BL_ActionActuator.h
===================================================================
--- trunk/blender/source/gameengine/Converter/BL_ActionActuator.h	2008-07-10 12:49:55 UTC (rev 15518)
+++ trunk/blender/source/gameengine/Converter/BL_ActionActuator.h	2008-07-10 14:23:19 UTC (rev 15519)
@@ -47,6 +47,7 @@
 						short	playtype,
 						short	blendin,
 						short	priority,
+						short	end_reset,
 						float	stride,
 						PyTypeObject* T=&Type) 
 		: SCA_IActuator(gameobj,T),
@@ -64,6 +65,7 @@
 		m_stridelength(stride),
 		m_playtype(playtype),
 		m_priority(priority),
+		m_end_reset(end_reset),
 		m_pose(NULL),
 		m_blendpose(NULL),
 		m_userpose(NULL),
@@ -101,6 +103,8 @@
 //	KX_PYMETHOD(BL_ActionActuator,GetChannel);
 	KX_PYMETHOD_DOC(BL_ActionActuator,GetType);
 	KX_PYMETHOD_DOC(BL_ActionActuator,SetType);
+	KX_PYMETHOD_NOARGS(BL_ActionActuator,GetContinue);
+	KX_PYMETHOD_O(BL_ActionActuator,SetContinue);
 
 	virtual PyObject* _getattr(const STR_String& attr);
 
@@ -137,6 +141,7 @@
 	float	m_stridelength;
 	short	m_playtype;
 	short	m_priority;
+	short	m_end_reset;
 	struct bPose* m_pose;
 	struct bPose* m_blendpose;
 	struct bPose* m_userpose;

Modified: trunk/blender/source/gameengine/Converter/KX_ConvertActuators.cpp
===================================================================
--- trunk/blender/source/gameengine/Converter/KX_ConvertActuators.cpp	2008-07-10 12:49:55 UTC (rev 15518)
+++ trunk/blender/source/gameengine/Converter/KX_ConvertActuators.cpp	2008-07-10 14:23:19 UTC (rev 15519)
@@ -193,6 +193,7 @@
 						actact->type, // + 1, because Blender starts to count at zero,
 						actact->blendin,
 						actact->priority,
+						actact->end_reset,
 						actact->stridelength
 						// Ketsji at 1, because zero is reserved for "NoDef"
 						);

Modified: trunk/blender/source/gameengine/PyDoc/BL_ActionActuator.py
===================================================================
--- trunk/blender/source/gameengine/PyDoc/BL_ActionActuator.py	2008-07-10 12:49:55 UTC (rev 15518)
+++ trunk/blender/source/gameengine/PyDoc/BL_ActionActuator.py	2008-07-10 14:23:19 UTC (rev 15519)
@@ -86,7 +86,15 @@
 		@param mode: KX_ACTIONACT_PLAY, KX_ACTIONACT_PROPERTY, KX_ACTIONACT_FLIPPER, KX_ACTIONACT_LOOPSTOP, KX_ACTIONACT_LOOPEND
 		@type mode: integer
 		"""
+	
+	def setContinue(cont):
+		"""
+		Set the actions continue option True or False. see getContinue.
 
+		@param cont: The continue option.
+		@type cont: bool
+		"""
+
 	def getType():
 		"""
 		Returns the operation mode of the actuator
@@ -94,6 +102,13 @@
 		@rtype: integer
 		@return: KX_ACTIONACT_PLAY, KX_ACTIONACT_PROPERTY, KX_ACTIONACT_FLIPPER, KX_ACTIONACT_LOOPSTOP, KX_ACTIONACT_LOOPEND
 		"""
+
+	def getContinue():
+		"""
+		When True, the action will always play from where last left off, otherwise negative events to this actuator will reset it to its start frame.
+	    
+		@rtype: bool
+		"""
 	
 	def getAction():
 		"""





More information about the Bf-blender-cvs mailing list