BGE patch: add frameProp to Ipo actuator (Carsten's request).

This commit is contained in:
Benoit Bolsee 2008-10-01 21:17:00 +00:00
parent 8550c2b594
commit c2b8702a83
5 changed files with 30 additions and 3 deletions

@ -113,6 +113,7 @@ typedef struct bIpoActuator {
short flag, type;
int sta, end;
char name[32];
char frameProp[32]; /* Set this property to the actions current frame */
short pad1, cur, butsta, butend;

@ -1866,7 +1866,7 @@ static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, sh
{
ia= act->data;
ysize= 52;
ysize= 72;
glRects(xco, yco-ysize, xco+width, yco);
uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
@ -1915,6 +1915,10 @@ static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, sh
"Child", xco+10+(width-80), yco-44, 60, 19,
&ia->flag, 0, 0, 0, 0,
"Update IPO on all children Objects as well");
uiDefBut(block, TEX, 0,
"FrameProp: ", xco+10, yco-64, width-20, 19,
ia->frameProp, 0.0, 31.0, 0, 0,
"Assign this property this action current frame number");
yco-= ysize;
break;

@ -235,7 +235,8 @@ void BL_ConvertActuators(char* maggiename,
{
bIpoActuator* ipoact = (bIpoActuator*) bact->data;
bool ipochild = (ipoact->flag & ACT_IPOCHILD) !=0;
STR_String propname = ( ipoact->name ? ipoact->name : "");
STR_String propname = ipoact->name;
STR_String frameProp = ipoact->frameProp;
// first bit?
bool ipo_as_force = (ipoact->flag & ACT_IPOFORCE);
bool local = (ipoact->flag & ACT_IPOLOCAL);
@ -244,6 +245,7 @@ void BL_ConvertActuators(char* maggiename,
KX_IpoActuator* tmpbaseact = new KX_IpoActuator(
gameobj,
propname ,
frameProp,
ipoact->sta,
ipoact->end,
ipochild,

@ -37,6 +37,7 @@
#include "KX_IpoActuator.h"
#include "KX_GameObject.h"
#include "FloatValue.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
@ -62,6 +63,7 @@ STR_String KX_IpoActuator::S_KX_ACT_IPO_FROM_PROP_STRING = "FromProp";
KX_IpoActuator::KX_IpoActuator(SCA_IObject* gameobj,
const STR_String& propname,
const STR_String& framePropname,
float starttime,
float endtime,
bool recurse,
@ -78,6 +80,7 @@ KX_IpoActuator::KX_IpoActuator(SCA_IObject* gameobj,
m_localtime(starttime),
m_direction(1),
m_propname(propname),
m_framepropname(framePropname),
m_ipo_as_force(ipo_as_force),
m_ipo_add(ipo_add),
m_ipo_local(ipo_local),
@ -356,7 +359,20 @@ bool KX_IpoActuator::Update(double curtime, bool frame)
default:
result = false;
}
/* Set the property if its defined */
if (m_framepropname[0] != '\0') {
CValue* propowner = GetParent();
CValue* oldprop = propowner->GetProperty(m_framepropname);
CValue* newval = new CFloatValue(m_localtime);
if (oldprop) {
oldprop->SetValue(newval);
} else {
propowner->SetProperty(m_framepropname, newval);
}
newval->Release();
}
if (!result)
{
if (m_type != KX_ACT_IPO_LOOPSTOP)

@ -72,6 +72,9 @@ protected:
/** Name of the property (only used in from_prop mode). */
STR_String m_propname;
/** Name of the property where we write the current frame number */
STR_String m_framepropname;
/** Interpret the ipo as a force? */
bool m_ipo_as_force;
@ -111,6 +114,7 @@ public:
KX_IpoActuator(SCA_IObject* gameobj,
const STR_String& propname,
const STR_String& framePropname,
float starttime,
float endtime,
bool recurse,