forked from bartvdbraak/blender
BGE: Remove KX_IPOActuator.
KX_IPOActuator is not used since 2.4. This patch removes: - KX_IPOActuator.h/cpp; - Python doc; - Write of IPO actuator in write.c; - Allocation of IPOactuator in sca.c; - Conversion in KX_ConvertActuators.cpp; - Initialization of the python proxy in KX_PythonInitTypes.cpp; - Other minor remove in logic_windows.c and in KX_PythonInit.cpp. Reviewers: sybren, campbellbarton Reviewed By: campbellbarton Subscribers: moguri Differential Revision: https://developer.blender.org/D1603
This commit is contained in:
parent
6063790732
commit
f29f4c92f2
@ -1,65 +0,0 @@
|
|||||||
KX_IpoActuator(SCA_IActuator)
|
|
||||||
=============================
|
|
||||||
|
|
||||||
.. module:: bge.types
|
|
||||||
|
|
||||||
base class --- :class:`SCA_IActuator`
|
|
||||||
|
|
||||||
.. class:: KX_IpoActuator(SCA_IActuator)
|
|
||||||
|
|
||||||
IPO actuator activates an animation.
|
|
||||||
|
|
||||||
.. attribute:: frameStart
|
|
||||||
|
|
||||||
Start frame.
|
|
||||||
|
|
||||||
:type: float
|
|
||||||
|
|
||||||
.. attribute:: frameEnd
|
|
||||||
|
|
||||||
End frame.
|
|
||||||
|
|
||||||
:type: float
|
|
||||||
|
|
||||||
.. attribute:: propName
|
|
||||||
|
|
||||||
Use this property to define the Ipo position.
|
|
||||||
|
|
||||||
:type: string
|
|
||||||
|
|
||||||
.. attribute:: framePropName
|
|
||||||
|
|
||||||
Assign this property this action current frame number.
|
|
||||||
|
|
||||||
:type: string
|
|
||||||
|
|
||||||
.. attribute:: mode
|
|
||||||
|
|
||||||
Play mode for the ipo. Can be on of :ref:`these constants <ipo-actuator>`
|
|
||||||
|
|
||||||
:type: integer
|
|
||||||
|
|
||||||
.. attribute:: useIpoAsForce
|
|
||||||
|
|
||||||
Apply Ipo as a global or local force depending on the local option (dynamic objects only).
|
|
||||||
|
|
||||||
:type: boolean
|
|
||||||
|
|
||||||
.. attribute:: useIpoAdd
|
|
||||||
|
|
||||||
Ipo is added to the current loc/rot/scale in global or local coordinate according to Local flag.
|
|
||||||
|
|
||||||
:type: boolean
|
|
||||||
|
|
||||||
.. attribute:: useIpoLocal
|
|
||||||
|
|
||||||
Let the ipo acts in local coordinates, used in Force and Add mode.
|
|
||||||
|
|
||||||
:type: boolean
|
|
||||||
|
|
||||||
.. attribute:: useChildren
|
|
||||||
|
|
||||||
Update IPO on all children Objects as well.
|
|
||||||
|
|
||||||
:type: boolean
|
|
||||||
|
|
@ -435,9 +435,6 @@ void init_actuator(bActuator *act)
|
|||||||
oa= act->data;
|
oa= act->data;
|
||||||
oa->flag= 15;
|
oa->flag= 15;
|
||||||
break;
|
break;
|
||||||
case ACT_IPO:
|
|
||||||
act->data= MEM_callocN(sizeof(bIpoActuator), "ipoact");
|
|
||||||
break;
|
|
||||||
case ACT_PROPERTY:
|
case ACT_PROPERTY:
|
||||||
act->data= MEM_callocN(sizeof(bPropertyActuator), "propact");
|
act->data= MEM_callocN(sizeof(bPropertyActuator), "propact");
|
||||||
break;
|
break;
|
||||||
@ -1059,7 +1056,6 @@ void BKE_sca_actuators_id_loop(ListBase *actlist, SCAActuatorIDFunc func, void *
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Note: some types seems to be non-implemented? ACT_LAMP, ACT_MATERIAL... */
|
/* Note: some types seems to be non-implemented? ACT_LAMP, ACT_MATERIAL... */
|
||||||
case ACT_IPO: /* DEPRECATED */
|
|
||||||
case ACT_LAMP:
|
case ACT_LAMP:
|
||||||
case ACT_MATERIAL:
|
case ACT_MATERIAL:
|
||||||
case ACT_END_OBJECT: /* DEPRECATED */
|
case ACT_END_OBJECT: /* DEPRECATED */
|
||||||
|
@ -1356,9 +1356,6 @@ static void write_actuators(WriteData *wd, ListBase *lb)
|
|||||||
case ACT_OBJECT:
|
case ACT_OBJECT:
|
||||||
writestruct(wd, DATA, "bObjectActuator", 1, act->data);
|
writestruct(wd, DATA, "bObjectActuator", 1, act->data);
|
||||||
break;
|
break;
|
||||||
case ACT_IPO:
|
|
||||||
writestruct(wd, DATA, "bIpoActuator", 1, act->data);
|
|
||||||
break;
|
|
||||||
case ACT_PROPERTY:
|
case ACT_PROPERTY:
|
||||||
writestruct(wd, DATA, "bPropertyActuator", 1, act->data);
|
writestruct(wd, DATA, "bPropertyActuator", 1, act->data);
|
||||||
break;
|
break;
|
||||||
|
@ -397,8 +397,6 @@ static const char *actuator_name(int type)
|
|||||||
return N_("Action");
|
return N_("Action");
|
||||||
case ACT_OBJECT:
|
case ACT_OBJECT:
|
||||||
return N_("Motion");
|
return N_("Motion");
|
||||||
case ACT_IPO:
|
|
||||||
return N_("F-Curve");
|
|
||||||
case ACT_LAMP:
|
case ACT_LAMP:
|
||||||
return N_("Lamp");
|
return N_("Lamp");
|
||||||
case ACT_CAMERA:
|
case ACT_CAMERA:
|
||||||
|
@ -362,12 +362,7 @@ typedef struct bActuator {
|
|||||||
#define ACT_ACTION_ADD 1
|
#define ACT_ACTION_ADD 1
|
||||||
|
|
||||||
/* ipoactuator->type */
|
/* ipoactuator->type */
|
||||||
#define ACT_IPO_PLAY 0
|
/* used for conversion from 2.01 */
|
||||||
#define ACT_IPO_PINGPONG 1
|
|
||||||
#define ACT_IPO_FLIPPER 2
|
|
||||||
#define ACT_IPO_LOOP_STOP 3
|
|
||||||
#define ACT_IPO_LOOP_END 4
|
|
||||||
#define ACT_IPO_KEY2KEY 5
|
|
||||||
#define ACT_IPO_FROM_PROP 6
|
#define ACT_IPO_FROM_PROP 6
|
||||||
|
|
||||||
/* groupactuator->type */
|
/* groupactuator->type */
|
||||||
@ -386,12 +381,6 @@ typedef struct bActuator {
|
|||||||
#define ACT_IPOCHILD (1 << 4)
|
#define ACT_IPOCHILD (1 << 4)
|
||||||
#define ACT_IPOADD (1 << 5)
|
#define ACT_IPOADD (1 << 5)
|
||||||
|
|
||||||
/* ipoactuator->flag for k2k */
|
|
||||||
#define ACT_K2K_PREV 1
|
|
||||||
#define ACT_K2K_CYCLIC 2
|
|
||||||
#define ACT_K2K_PINGPONG 4
|
|
||||||
#define ACT_K2K_HOLD 8
|
|
||||||
|
|
||||||
/* property actuator->type */
|
/* property actuator->type */
|
||||||
#define ACT_PROP_ASSIGN 0
|
#define ACT_PROP_ASSIGN 0
|
||||||
#define ACT_PROP_ADD 1
|
#define ACT_PROP_ADD 1
|
||||||
|
@ -54,7 +54,6 @@
|
|||||||
|
|
||||||
// Ketsji specific logicbricks
|
// Ketsji specific logicbricks
|
||||||
#include "KX_SceneActuator.h"
|
#include "KX_SceneActuator.h"
|
||||||
#include "KX_IpoActuator.h"
|
|
||||||
#include "KX_SoundActuator.h"
|
#include "KX_SoundActuator.h"
|
||||||
#include "KX_ObjectActuator.h"
|
#include "KX_ObjectActuator.h"
|
||||||
#include "KX_TrackToActuator.h"
|
#include "KX_TrackToActuator.h"
|
||||||
@ -262,32 +261,6 @@ void BL_ConvertActuators(const char* maggiename,
|
|||||||
else
|
else
|
||||||
printf ("Discarded shape action actuator from non-mesh object [%s]\n", blenderobject->id.name+2);
|
printf ("Discarded shape action actuator from non-mesh object [%s]\n", blenderobject->id.name+2);
|
||||||
}
|
}
|
||||||
case ACT_IPO:
|
|
||||||
{
|
|
||||||
bIpoActuator* ipoact = (bIpoActuator*) bact->data;
|
|
||||||
bool ipochild = (ipoact->flag & ACT_IPOCHILD) !=0;
|
|
||||||
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);
|
|
||||||
bool ipo_add = (ipoact->flag & ACT_IPOADD);
|
|
||||||
|
|
||||||
KX_IpoActuator* tmpbaseact = new KX_IpoActuator(
|
|
||||||
gameobj,
|
|
||||||
propname ,
|
|
||||||
frameProp,
|
|
||||||
ipoact->sta,
|
|
||||||
ipoact->end,
|
|
||||||
ipochild,
|
|
||||||
ipoact->type + 1, // + 1, because Blender starts to count at zero,
|
|
||||||
// Ketsji at 1, because zero is reserved for "NoDef"
|
|
||||||
ipo_as_force,
|
|
||||||
ipo_add,
|
|
||||||
local);
|
|
||||||
baseact = tmpbaseact;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case ACT_LAMP:
|
case ACT_LAMP:
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
@ -85,7 +85,6 @@ set(SRC
|
|||||||
KX_GameObject.cpp
|
KX_GameObject.cpp
|
||||||
KX_IpoConvert.cpp
|
KX_IpoConvert.cpp
|
||||||
KX_IPO_SGController.cpp
|
KX_IPO_SGController.cpp
|
||||||
KX_IpoActuator.cpp
|
|
||||||
KX_KetsjiEngine.cpp
|
KX_KetsjiEngine.cpp
|
||||||
KX_Light.cpp
|
KX_Light.cpp
|
||||||
KX_LightIpoSGController.cpp
|
KX_LightIpoSGController.cpp
|
||||||
@ -163,7 +162,6 @@ set(SRC
|
|||||||
KX_IScalarInterpolator.h
|
KX_IScalarInterpolator.h
|
||||||
KX_ISceneConverter.h
|
KX_ISceneConverter.h
|
||||||
KX_ISystem.h
|
KX_ISystem.h
|
||||||
KX_IpoActuator.h
|
|
||||||
KX_KetsjiEngine.h
|
KX_KetsjiEngine.h
|
||||||
KX_Light.h
|
KX_Light.h
|
||||||
KX_LightIpoSGController.h
|
KX_LightIpoSGController.h
|
||||||
|
@ -1,500 +0,0 @@
|
|||||||
/*
|
|
||||||
* Do Ipo stuff
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software Foundation,
|
|
||||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*
|
|
||||||
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* The Original Code is: all of this file.
|
|
||||||
*
|
|
||||||
* Contributor(s): none yet.
|
|
||||||
*
|
|
||||||
* ***** END GPL LICENSE BLOCK *****
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** \file gameengine/Ketsji/KX_IpoActuator.cpp
|
|
||||||
* \ingroup ketsji
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <cmath>
|
|
||||||
|
|
||||||
#include "KX_IpoActuator.h"
|
|
||||||
#include "KX_GameObject.h"
|
|
||||||
#include "EXP_FloatValue.h"
|
|
||||||
|
|
||||||
#include "KX_KetsjiEngine.h"
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------- */
|
|
||||||
/* Type strings */
|
|
||||||
/* ------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
const char *KX_IpoActuator::S_KX_ACT_IPO_PLAY_STRING = "Play";
|
|
||||||
const char *KX_IpoActuator::S_KX_ACT_IPO_PINGPONG_STRING = "PingPong";
|
|
||||||
const char *KX_IpoActuator::S_KX_ACT_IPO_FLIPPER_STRING = "Flipper";
|
|
||||||
const char *KX_IpoActuator::S_KX_ACT_IPO_LOOPSTOP_STRING = "LoopStop";
|
|
||||||
const char *KX_IpoActuator::S_KX_ACT_IPO_LOOPEND_STRING = "LoopEnd";
|
|
||||||
const char *KX_IpoActuator::S_KX_ACT_IPO_KEY2KEY_STRING = "Key2key";
|
|
||||||
const char *KX_IpoActuator::S_KX_ACT_IPO_FROM_PROP_STRING = "FromProp";
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------- */
|
|
||||||
/* Native functions */
|
|
||||||
/* ------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
KX_IpoActuator::KX_IpoActuator(SCA_IObject* gameobj,
|
|
||||||
const STR_String& propname,
|
|
||||||
const STR_String& framePropname,
|
|
||||||
float starttime,
|
|
||||||
float endtime,
|
|
||||||
bool recurse,
|
|
||||||
int acttype,
|
|
||||||
bool ipo_as_force,
|
|
||||||
bool ipo_add,
|
|
||||||
bool ipo_local)
|
|
||||||
: SCA_IActuator(gameobj, KX_ACT_IPO),
|
|
||||||
m_bNegativeEvent(false),
|
|
||||||
m_startframe (starttime),
|
|
||||||
m_endframe(endtime),
|
|
||||||
m_recurse(recurse),
|
|
||||||
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),
|
|
||||||
m_type(acttype)
|
|
||||||
{
|
|
||||||
this->ResetStartTime();
|
|
||||||
m_bIpoPlaying = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void KX_IpoActuator::SetStart(float starttime)
|
|
||||||
{
|
|
||||||
m_startframe=starttime;
|
|
||||||
}
|
|
||||||
|
|
||||||
void KX_IpoActuator::SetEnd(float endtime)
|
|
||||||
{
|
|
||||||
m_endframe=endtime;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool KX_IpoActuator::ClampLocalTime()
|
|
||||||
{
|
|
||||||
if (m_startframe < m_endframe)
|
|
||||||
{
|
|
||||||
if (m_localtime < m_startframe)
|
|
||||||
{
|
|
||||||
m_localtime = m_startframe;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (m_localtime > m_endframe)
|
|
||||||
{
|
|
||||||
m_localtime = m_endframe;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (m_localtime > m_startframe)
|
|
||||||
{
|
|
||||||
m_localtime = m_startframe;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (m_localtime < m_endframe)
|
|
||||||
{
|
|
||||||
m_localtime = m_endframe;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void KX_IpoActuator::SetStartTime(float curtime)
|
|
||||||
{
|
|
||||||
float direction = m_startframe < m_endframe ? 1.0f : -1.0f;
|
|
||||||
|
|
||||||
if (m_direction > 0)
|
|
||||||
m_starttime = curtime - direction*(m_localtime - m_startframe)/KX_KetsjiEngine::GetAnimFrameRate();
|
|
||||||
else
|
|
||||||
m_starttime = curtime - direction*(m_endframe - m_localtime)/KX_KetsjiEngine::GetAnimFrameRate();
|
|
||||||
}
|
|
||||||
|
|
||||||
void KX_IpoActuator::SetLocalTime(float curtime)
|
|
||||||
{
|
|
||||||
float delta_time = (curtime - m_starttime)*KX_KetsjiEngine::GetAnimFrameRate();
|
|
||||||
|
|
||||||
// negative delta_time is caused by floating point inaccuracy
|
|
||||||
// perhaps the inaccuracy could be reduced a bit
|
|
||||||
if ((m_localtime==m_startframe || m_localtime==m_endframe) && delta_time<0.0)
|
|
||||||
{
|
|
||||||
delta_time = 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_endframe < m_startframe)
|
|
||||||
delta_time = -delta_time;
|
|
||||||
|
|
||||||
if (m_direction > 0)
|
|
||||||
m_localtime = m_startframe + delta_time;
|
|
||||||
else
|
|
||||||
m_localtime = m_endframe - delta_time;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool KX_IpoActuator::Update(double curtime, bool frame)
|
|
||||||
{
|
|
||||||
// result = true if animation has to be continued, false if animation stops
|
|
||||||
// maybe there are events for us in the queue !
|
|
||||||
bool bNegativeEvent = false;
|
|
||||||
bool numevents = false;
|
|
||||||
bool bIpoStart = false;
|
|
||||||
|
|
||||||
curtime -= KX_KetsjiEngine::GetSuspendedDelta();
|
|
||||||
|
|
||||||
if (frame)
|
|
||||||
{
|
|
||||||
numevents = m_posevent || m_negevent;
|
|
||||||
bNegativeEvent = IsNegativeEvent();
|
|
||||||
RemoveAllEvents();
|
|
||||||
}
|
|
||||||
|
|
||||||
float start_smaller_then_end = ( m_startframe < m_endframe ? 1.0f : -1.0f);
|
|
||||||
|
|
||||||
bool result=true;
|
|
||||||
if (!bNegativeEvent)
|
|
||||||
{
|
|
||||||
if (m_starttime < -2.0f*fabs(m_endframe - m_startframe))
|
|
||||||
{
|
|
||||||
// start for all Ipo, initial start for LOOP_STOP
|
|
||||||
m_starttime = curtime;
|
|
||||||
m_bIpoPlaying = true;
|
|
||||||
bIpoStart = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch ((IpoActType)m_type)
|
|
||||||
{
|
|
||||||
|
|
||||||
case KX_ACT_IPO_PLAY:
|
|
||||||
{
|
|
||||||
// Check if playing forwards. result = ! finished
|
|
||||||
|
|
||||||
if (start_smaller_then_end > 0.f)
|
|
||||||
result = (m_localtime < m_endframe && m_bIpoPlaying);
|
|
||||||
else
|
|
||||||
result = (m_localtime > m_endframe && m_bIpoPlaying);
|
|
||||||
|
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
SetLocalTime(curtime);
|
|
||||||
|
|
||||||
/* Perform clamping */
|
|
||||||
ClampLocalTime();
|
|
||||||
|
|
||||||
if (bIpoStart)
|
|
||||||
((KX_GameObject*)GetParent())->InitIPO(m_ipo_as_force, m_ipo_add, m_ipo_local);
|
|
||||||
((KX_GameObject*)GetParent())->UpdateIPO(m_localtime,m_recurse);
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
m_localtime=m_startframe;
|
|
||||||
m_direction=1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case KX_ACT_IPO_PINGPONG:
|
|
||||||
{
|
|
||||||
result = true;
|
|
||||||
if (bNegativeEvent && !m_bIpoPlaying)
|
|
||||||
result = false;
|
|
||||||
else
|
|
||||||
SetLocalTime(curtime);
|
|
||||||
|
|
||||||
if (ClampLocalTime())
|
|
||||||
{
|
|
||||||
result = false;
|
|
||||||
m_direction = -m_direction;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bIpoStart && m_direction > 0)
|
|
||||||
((KX_GameObject*)GetParent())->InitIPO(m_ipo_as_force, m_ipo_add, m_ipo_local);
|
|
||||||
((KX_GameObject*)GetParent())->UpdateIPO(m_localtime,m_recurse);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case KX_ACT_IPO_FLIPPER:
|
|
||||||
{
|
|
||||||
if (bNegativeEvent && !m_bIpoPlaying)
|
|
||||||
result = false;
|
|
||||||
if (numevents)
|
|
||||||
{
|
|
||||||
float oldDirection = m_direction;
|
|
||||||
if (bNegativeEvent)
|
|
||||||
m_direction = -1;
|
|
||||||
else
|
|
||||||
m_direction = 1;
|
|
||||||
if (m_direction != oldDirection)
|
|
||||||
// changing direction, reset start time
|
|
||||||
SetStartTime(curtime);
|
|
||||||
}
|
|
||||||
|
|
||||||
SetLocalTime(curtime);
|
|
||||||
|
|
||||||
if (ClampLocalTime() && m_localtime == m_startframe)
|
|
||||||
result = false;
|
|
||||||
|
|
||||||
if (bIpoStart)
|
|
||||||
((KX_GameObject*)GetParent())->InitIPO(m_ipo_as_force, m_ipo_add, m_ipo_local);
|
|
||||||
((KX_GameObject*)GetParent())->UpdateIPO(m_localtime,m_recurse);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case KX_ACT_IPO_LOOPSTOP:
|
|
||||||
{
|
|
||||||
if (numevents)
|
|
||||||
{
|
|
||||||
if (bNegativeEvent)
|
|
||||||
{
|
|
||||||
result = false;
|
|
||||||
m_bNegativeEvent = false;
|
|
||||||
numevents = false;
|
|
||||||
}
|
|
||||||
if (!m_bIpoPlaying)
|
|
||||||
{
|
|
||||||
// Ipo was stopped, make sure we will restart from where it stopped
|
|
||||||
SetStartTime(curtime);
|
|
||||||
if (!bNegativeEvent)
|
|
||||||
// positive signal will restart the Ipo
|
|
||||||
m_bIpoPlaying = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // fall through to loopend, and quit the ipo animation immediatly
|
|
||||||
}
|
|
||||||
case KX_ACT_IPO_LOOPEND:
|
|
||||||
{
|
|
||||||
if (numevents) {
|
|
||||||
if (bNegativeEvent && m_bIpoPlaying) {
|
|
||||||
m_bNegativeEvent = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bNegativeEvent && !m_bIpoPlaying) {
|
|
||||||
result = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (m_localtime*start_smaller_then_end < m_endframe*start_smaller_then_end)
|
|
||||||
{
|
|
||||||
SetLocalTime(curtime);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (!m_bNegativeEvent) {
|
|
||||||
/* Perform wraparound */
|
|
||||||
SetLocalTime(curtime);
|
|
||||||
if (start_smaller_then_end > 0.f)
|
|
||||||
m_localtime = m_startframe + fmod(m_localtime - m_startframe, m_endframe - m_startframe);
|
|
||||||
else
|
|
||||||
m_localtime = m_startframe - fmod(m_startframe - m_localtime, m_startframe - m_endframe);
|
|
||||||
SetStartTime(curtime);
|
|
||||||
bIpoStart = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Perform clamping */
|
|
||||||
m_localtime=m_endframe;
|
|
||||||
result = false;
|
|
||||||
m_bNegativeEvent = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_bIpoPlaying && bIpoStart)
|
|
||||||
((KX_GameObject*)GetParent())->InitIPO(m_ipo_as_force, m_ipo_add, m_ipo_local);
|
|
||||||
((KX_GameObject*)GetParent())->UpdateIPO(m_localtime,m_recurse);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case KX_ACT_IPO_KEY2KEY:
|
|
||||||
{
|
|
||||||
// not implemented yet
|
|
||||||
result = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case KX_ACT_IPO_FROM_PROP:
|
|
||||||
{
|
|
||||||
result = !bNegativeEvent;
|
|
||||||
|
|
||||||
CValue* propval = GetParent()->GetProperty(m_propname);
|
|
||||||
if (propval)
|
|
||||||
{
|
|
||||||
m_localtime = propval->GetNumber();
|
|
||||||
|
|
||||||
if (bIpoStart)
|
|
||||||
((KX_GameObject*)GetParent())->InitIPO(m_ipo_as_force, m_ipo_add, m_ipo_local);
|
|
||||||
((KX_GameObject*)GetParent())->UpdateIPO(m_localtime,m_recurse);
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
result = false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
this->ResetStartTime();
|
|
||||||
m_bIpoPlaying = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void KX_IpoActuator::ResetStartTime()
|
|
||||||
{
|
|
||||||
this->m_starttime = -2.0f * fabsf(this->m_endframe - this->m_startframe) - 1.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
int KX_IpoActuator::string2mode(const char *modename)
|
|
||||||
{
|
|
||||||
IpoActType res = KX_ACT_IPO_NODEF;
|
|
||||||
|
|
||||||
if (strcmp(modename, S_KX_ACT_IPO_PLAY_STRING)==0) {
|
|
||||||
res = KX_ACT_IPO_PLAY;
|
|
||||||
} else if (strcmp(modename, S_KX_ACT_IPO_PINGPONG_STRING)==0) {
|
|
||||||
res = KX_ACT_IPO_PINGPONG;
|
|
||||||
} else if (strcmp(modename, S_KX_ACT_IPO_FLIPPER_STRING)==0) {
|
|
||||||
res = KX_ACT_IPO_FLIPPER;
|
|
||||||
} else if (strcmp(modename, S_KX_ACT_IPO_LOOPSTOP_STRING)==0) {
|
|
||||||
res = KX_ACT_IPO_LOOPSTOP;
|
|
||||||
} else if (strcmp(modename, S_KX_ACT_IPO_LOOPEND_STRING)==0) {
|
|
||||||
res = KX_ACT_IPO_LOOPEND;
|
|
||||||
} else if (strcmp(modename, S_KX_ACT_IPO_KEY2KEY_STRING)==0) {
|
|
||||||
res = KX_ACT_IPO_KEY2KEY;
|
|
||||||
} else if (strcmp(modename, S_KX_ACT_IPO_FROM_PROP_STRING)==0) {
|
|
||||||
res = KX_ACT_IPO_FROM_PROP;
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef WITH_PYTHON
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------- */
|
|
||||||
/* Python functions */
|
|
||||||
/* ------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
|
|
||||||
/* Integration hooks ------------------------------------------------------- */
|
|
||||||
PyTypeObject KX_IpoActuator::Type = {
|
|
||||||
PyVarObject_HEAD_INIT(NULL, 0)
|
|
||||||
"KX_IpoActuator",
|
|
||||||
sizeof(PyObjectPlus_Proxy),
|
|
||||||
0,
|
|
||||||
py_base_dealloc,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
py_base_repr,
|
|
||||||
0,0,0,0,0,0,0,0,0,
|
|
||||||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
|
|
||||||
0,0,0,0,0,0,0,
|
|
||||||
Methods,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
&SCA_IActuator::Type,
|
|
||||||
0,0,0,0,0,0,
|
|
||||||
py_base_new
|
|
||||||
};
|
|
||||||
|
|
||||||
PyMethodDef KX_IpoActuator::Methods[] = {
|
|
||||||
{NULL,NULL} //Sentinel
|
|
||||||
};
|
|
||||||
|
|
||||||
PyAttributeDef KX_IpoActuator::Attributes[] = {
|
|
||||||
KX_PYATTRIBUTE_RW_FUNCTION("frameStart", KX_IpoActuator, pyattr_get_frame_start, pyattr_set_frame_start),
|
|
||||||
KX_PYATTRIBUTE_RW_FUNCTION("frameEnd", KX_IpoActuator, pyattr_get_frame_end, pyattr_set_frame_end),
|
|
||||||
KX_PYATTRIBUTE_STRING_RW("propName", 0, MAX_PROP_NAME, false, KX_IpoActuator, m_propname),
|
|
||||||
KX_PYATTRIBUTE_STRING_RW("framePropName", 0, MAX_PROP_NAME, false, KX_IpoActuator, m_framepropname),
|
|
||||||
KX_PYATTRIBUTE_INT_RW("mode", KX_ACT_IPO_NODEF+1, KX_ACT_IPO_MAX-1, true, KX_IpoActuator, m_type),
|
|
||||||
KX_PYATTRIBUTE_BOOL_RW("useIpoAsForce", KX_IpoActuator, m_ipo_as_force),
|
|
||||||
KX_PYATTRIBUTE_BOOL_RW("useIpoAdd", KX_IpoActuator, m_ipo_add),
|
|
||||||
KX_PYATTRIBUTE_BOOL_RW("useIpoLocal", KX_IpoActuator, m_ipo_local),
|
|
||||||
KX_PYATTRIBUTE_BOOL_RW("useChildren", KX_IpoActuator, m_recurse),
|
|
||||||
|
|
||||||
{ NULL } //Sentinel
|
|
||||||
};
|
|
||||||
|
|
||||||
PyObject *KX_IpoActuator::pyattr_get_frame_start(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
|
||||||
{
|
|
||||||
KX_IpoActuator* self = static_cast<KX_IpoActuator*>(self_v);
|
|
||||||
return PyFloat_FromDouble(self->m_startframe);
|
|
||||||
}
|
|
||||||
|
|
||||||
int KX_IpoActuator::pyattr_set_frame_start(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
|
|
||||||
{
|
|
||||||
KX_IpoActuator* self = static_cast<KX_IpoActuator*>(self_v);
|
|
||||||
float param = PyFloat_AsDouble(value);
|
|
||||||
|
|
||||||
if (PyErr_Occurred()) {
|
|
||||||
PyErr_SetString(PyExc_AttributeError, "frameStart = float: KX_IpoActuator, expected a float value");
|
|
||||||
return PY_SET_ATTR_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
self->m_startframe = param;
|
|
||||||
self->ResetStartTime();
|
|
||||||
return PY_SET_ATTR_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
PyObject *KX_IpoActuator::pyattr_get_frame_end(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
|
||||||
{
|
|
||||||
KX_IpoActuator* self = static_cast<KX_IpoActuator*>(self_v);
|
|
||||||
return PyFloat_FromDouble(self->m_endframe);
|
|
||||||
}
|
|
||||||
|
|
||||||
int KX_IpoActuator::pyattr_set_frame_end(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
|
|
||||||
{
|
|
||||||
KX_IpoActuator* self = static_cast<KX_IpoActuator*>(self_v);
|
|
||||||
float param = PyFloat_AsDouble(value);
|
|
||||||
|
|
||||||
if (PyErr_Occurred()) {
|
|
||||||
PyErr_SetString(PyExc_AttributeError, "frameEnd = float: KX_IpoActuator, expected a float value");
|
|
||||||
return PY_SET_ATTR_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
self->m_endframe = param;
|
|
||||||
self->ResetStartTime();
|
|
||||||
return PY_SET_ATTR_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // WITH_PYTHON
|
|
||||||
|
|
||||||
/* eof */
|
|
@ -1,153 +0,0 @@
|
|||||||
/*
|
|
||||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software Foundation,
|
|
||||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*
|
|
||||||
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* The Original Code is: all of this file.
|
|
||||||
*
|
|
||||||
* Contributor(s): none yet.
|
|
||||||
*
|
|
||||||
* ***** END GPL LICENSE BLOCK *****
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** \file KX_IpoActuator.h
|
|
||||||
* \ingroup ketsji
|
|
||||||
* \brief Do an object ipo
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __KX_IPOACTUATOR_H__
|
|
||||||
#define __KX_IPOACTUATOR_H__
|
|
||||||
|
|
||||||
#include "SCA_IActuator.h"
|
|
||||||
|
|
||||||
class KX_IpoActuator : public SCA_IActuator
|
|
||||||
{
|
|
||||||
Py_Header
|
|
||||||
private:
|
|
||||||
/** Computes the IPO start time from the current time
|
|
||||||
* and the current frame. */
|
|
||||||
void SetStartTime(float curtime);
|
|
||||||
/** Computes the current frame from the current time
|
|
||||||
* and the IPO start time. */
|
|
||||||
void SetLocalTime(float curtime);
|
|
||||||
/** Ensures the current frame is between the start and
|
|
||||||
* end frames. */
|
|
||||||
bool ClampLocalTime();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool m_bNegativeEvent;
|
|
||||||
|
|
||||||
/** Begin frame of the ipo. */
|
|
||||||
float m_startframe;
|
|
||||||
|
|
||||||
/** End frame of the ipo. */
|
|
||||||
float m_endframe;
|
|
||||||
|
|
||||||
/** Include children in the transforms? */
|
|
||||||
bool m_recurse;
|
|
||||||
|
|
||||||
/** Current active frame of the ipo. */
|
|
||||||
float m_localtime;
|
|
||||||
|
|
||||||
/** The time this ipo started at. */
|
|
||||||
float m_starttime;
|
|
||||||
|
|
||||||
/** play backwards or forwards? (positive means forward). */
|
|
||||||
float m_direction;
|
|
||||||
|
|
||||||
/** 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;
|
|
||||||
|
|
||||||
/** Add Ipo curve to current loc/rot/scale */
|
|
||||||
bool m_ipo_add;
|
|
||||||
|
|
||||||
/** The Ipo curve is applied in local coordinates */
|
|
||||||
bool m_ipo_local;
|
|
||||||
|
|
||||||
bool m_bIpoPlaying;
|
|
||||||
|
|
||||||
/** Reset/Update the start time*/
|
|
||||||
void ResetStartTime();
|
|
||||||
|
|
||||||
public:
|
|
||||||
enum IpoActType
|
|
||||||
{
|
|
||||||
KX_ACT_IPO_NODEF = 0,
|
|
||||||
KX_ACT_IPO_PLAY,
|
|
||||||
KX_ACT_IPO_PINGPONG,
|
|
||||||
KX_ACT_IPO_FLIPPER,
|
|
||||||
KX_ACT_IPO_LOOPSTOP,
|
|
||||||
KX_ACT_IPO_LOOPEND,
|
|
||||||
KX_ACT_IPO_KEY2KEY,
|
|
||||||
KX_ACT_IPO_FROM_PROP,
|
|
||||||
KX_ACT_IPO_MAX
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef WITH_PYTHON
|
|
||||||
static PyObject* pyattr_get_frame_start(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
|
||||||
static int pyattr_set_frame_start(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
|
||||||
static PyObject* pyattr_get_frame_end(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
|
||||||
static int pyattr_set_frame_end(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
|
||||||
#endif
|
|
||||||
static const char *S_KX_ACT_IPO_PLAY_STRING;
|
|
||||||
static const char *S_KX_ACT_IPO_PINGPONG_STRING;
|
|
||||||
static const char *S_KX_ACT_IPO_FLIPPER_STRING;
|
|
||||||
static const char *S_KX_ACT_IPO_LOOPSTOP_STRING;
|
|
||||||
static const char *S_KX_ACT_IPO_LOOPEND_STRING;
|
|
||||||
static const char *S_KX_ACT_IPO_KEY2KEY_STRING;
|
|
||||||
static const char *S_KX_ACT_IPO_FROM_PROP_STRING;
|
|
||||||
|
|
||||||
int string2mode(const char *modename);
|
|
||||||
|
|
||||||
int m_type;
|
|
||||||
|
|
||||||
KX_IpoActuator(SCA_IObject* gameobj,
|
|
||||||
const STR_String& propname,
|
|
||||||
const STR_String& framePropname,
|
|
||||||
float starttime,
|
|
||||||
float endtime,
|
|
||||||
bool recurse,
|
|
||||||
int acttype,
|
|
||||||
bool ipo_as_force,
|
|
||||||
bool ipo_add,
|
|
||||||
bool ipo_local);
|
|
||||||
virtual ~KX_IpoActuator() {};
|
|
||||||
|
|
||||||
virtual CValue* GetReplica() {
|
|
||||||
KX_IpoActuator* replica = new KX_IpoActuator(*this);//m_float,GetName());
|
|
||||||
replica->ProcessReplica();
|
|
||||||
return replica;
|
|
||||||
};
|
|
||||||
|
|
||||||
void SetStart(float starttime);
|
|
||||||
void SetEnd(float endtime);
|
|
||||||
virtual bool Update(double curtime, bool frame);
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------- */
|
|
||||||
/* Python interface ---------------------------------------------------- */
|
|
||||||
/* --------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* __KX_IPOACTUATOR_H__ */
|
|
@ -98,7 +98,6 @@ extern "C" {
|
|||||||
#include "SCA_PythonKeyboard.h"
|
#include "SCA_PythonKeyboard.h"
|
||||||
#include "SCA_PythonMouse.h"
|
#include "SCA_PythonMouse.h"
|
||||||
#include "KX_ConstraintActuator.h"
|
#include "KX_ConstraintActuator.h"
|
||||||
#include "KX_IpoActuator.h"
|
|
||||||
#include "KX_SoundActuator.h"
|
#include "KX_SoundActuator.h"
|
||||||
#include "KX_StateActuator.h"
|
#include "KX_StateActuator.h"
|
||||||
#include "BL_ActionActuator.h"
|
#include "BL_ActionActuator.h"
|
||||||
|
@ -84,7 +84,6 @@
|
|||||||
#include "SCA_PythonJoystick.h"
|
#include "SCA_PythonJoystick.h"
|
||||||
#include "SCA_PythonKeyboard.h"
|
#include "SCA_PythonKeyboard.h"
|
||||||
#include "SCA_PythonMouse.h"
|
#include "SCA_PythonMouse.h"
|
||||||
#include "KX_IpoActuator.h"
|
|
||||||
#include "KX_NearSensor.h"
|
#include "KX_NearSensor.h"
|
||||||
#include "KX_RadarSensor.h"
|
#include "KX_RadarSensor.h"
|
||||||
#include "KX_RaySensor.h"
|
#include "KX_RaySensor.h"
|
||||||
@ -214,7 +213,6 @@ PyMODINIT_FUNC initGameTypesPythonBinding(void)
|
|||||||
PyType_Ready_Attr(dict, KX_ConstraintWrapper, init_getset);
|
PyType_Ready_Attr(dict, KX_ConstraintWrapper, init_getset);
|
||||||
PyType_Ready_Attr(dict, KX_GameActuator, init_getset);
|
PyType_Ready_Attr(dict, KX_GameActuator, init_getset);
|
||||||
PyType_Ready_Attr(dict, KX_GameObject, init_getset);
|
PyType_Ready_Attr(dict, KX_GameObject, init_getset);
|
||||||
PyType_Ready_Attr(dict, KX_IpoActuator, init_getset);
|
|
||||||
PyType_Ready_Attr(dict, KX_LibLoadStatus, init_getset);
|
PyType_Ready_Attr(dict, KX_LibLoadStatus, init_getset);
|
||||||
PyType_Ready_Attr(dict, KX_LightObject, init_getset);
|
PyType_Ready_Attr(dict, KX_LightObject, init_getset);
|
||||||
PyType_Ready_Attr(dict, KX_FontObject, init_getset);
|
PyType_Ready_Attr(dict, KX_FontObject, init_getset);
|
||||||
|
Loading…
Reference in New Issue
Block a user