2002-10-12 11:37:38 +00:00
|
|
|
/**
|
|
|
|
* $Id$
|
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* 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
|
2008-04-16 22:40:48 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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.
|
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
|
|
|
|
2004-11-23 23:04:30 +00:00
|
|
|
#if defined (__sgi)
|
|
|
|
#include <math.h>
|
|
|
|
#else
|
2004-10-16 11:41:50 +00:00
|
|
|
#include <cmath>
|
2004-11-23 23:04:30 +00:00
|
|
|
#endif
|
2004-10-16 11:41:50 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "SCA_LogicManager.h"
|
|
|
|
#include "BL_ActionActuator.h"
|
|
|
|
#include "BL_ArmatureObject.h"
|
|
|
|
#include "BL_SkinDeformer.h"
|
|
|
|
#include "KX_GameObject.h"
|
|
|
|
#include "STR_HashedString.h"
|
2007-07-19 14:28:57 +00:00
|
|
|
#include "DNA_nla_types.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BKE_action.h"
|
2009-01-22 17:40:47 +00:00
|
|
|
#include "DNA_action_types.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "DNA_armature_types.h"
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
#include "BLI_arithb.h"
|
|
|
|
#include "MT_Matrix4x4.h"
|
|
|
|
#include "BKE_utildefines.h"
|
2008-06-23 15:32:44 +00:00
|
|
|
#include "FloatValue.h"
|
2008-09-06 14:13:31 +00:00
|
|
|
#include "PyObjectPlus.h"
|
2009-01-21 13:54:53 +00:00
|
|
|
#include "blendef.h"
|
|
|
|
|
2002-11-25 15:29:57 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
BL_ActionActuator::~BL_ActionActuator()
|
|
|
|
{
|
2008-07-30 16:15:15 +00:00
|
|
|
if (m_pose)
|
2008-09-17 01:29:54 +00:00
|
|
|
game_free_pose(m_pose);
|
2008-07-30 16:15:15 +00:00
|
|
|
if (m_userpose)
|
2008-09-17 01:29:54 +00:00
|
|
|
game_free_pose(m_userpose);
|
2008-07-30 16:15:15 +00:00
|
|
|
if (m_blendpose)
|
2008-09-17 01:29:54 +00:00
|
|
|
game_free_pose(m_blendpose);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BL_ActionActuator::ProcessReplica(){
|
2004-03-22 22:02:18 +00:00
|
|
|
// bPose *oldpose = m_pose;
|
|
|
|
// bPose *oldbpose = m_blendpose;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
m_pose = NULL;
|
|
|
|
m_blendpose = NULL;
|
2004-11-06 04:53:41 +00:00
|
|
|
m_localtime=m_startframe;
|
2002-10-12 11:37:38 +00:00
|
|
|
m_lastUpdate=-1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void BL_ActionActuator::SetBlendTime (float newtime){
|
|
|
|
m_blendframe = newtime;
|
|
|
|
}
|
|
|
|
|
|
|
|
CValue* BL_ActionActuator::GetReplica() {
|
|
|
|
BL_ActionActuator* replica = new BL_ActionActuator(*this);//m_float,GetName());
|
|
|
|
replica->ProcessReplica();
|
|
|
|
|
|
|
|
// this will copy properties and so on...
|
|
|
|
CValue::AddDataToReplica(replica);
|
|
|
|
return replica;
|
2004-11-06 04:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool BL_ActionActuator::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 BL_ActionActuator::SetStartTime(float curtime)
|
|
|
|
{
|
|
|
|
float direction = m_startframe < m_endframe ? 1.0 : -1.0;
|
|
|
|
|
|
|
|
if (!(m_flag & ACT_FLAG_REVERSE))
|
2008-06-17 10:06:38 +00:00
|
|
|
m_starttime = curtime - direction*(m_localtime - m_startframe)/KX_KetsjiEngine::GetAnimFrameRate();
|
2004-11-06 04:53:41 +00:00
|
|
|
else
|
2008-06-17 10:06:38 +00:00
|
|
|
m_starttime = curtime - direction*(m_endframe - m_localtime)/KX_KetsjiEngine::GetAnimFrameRate();
|
2004-11-06 04:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BL_ActionActuator::SetLocalTime(float curtime)
|
|
|
|
{
|
2008-06-17 10:06:38 +00:00
|
|
|
float delta_time = (curtime - m_starttime)*KX_KetsjiEngine::GetAnimFrameRate();
|
2004-11-06 04:53:41 +00:00
|
|
|
|
|
|
|
if (m_endframe < m_startframe)
|
|
|
|
delta_time = -delta_time;
|
|
|
|
|
|
|
|
if (!(m_flag & ACT_FLAG_REVERSE))
|
|
|
|
m_localtime = m_startframe + delta_time;
|
|
|
|
else
|
|
|
|
m_localtime = m_endframe - delta_time;
|
|
|
|
}
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2004-10-16 11:41:50 +00:00
|
|
|
bool BL_ActionActuator::Update(double curtime, bool frame)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
bool bNegativeEvent = false;
|
|
|
|
bool bPositiveEvent = false;
|
|
|
|
bool keepgoing = true;
|
|
|
|
bool wrap = false;
|
|
|
|
bool apply=true;
|
|
|
|
int priority;
|
|
|
|
float newweight;
|
2008-09-16 21:11:38 +00:00
|
|
|
|
|
|
|
curtime -= KX_KetsjiEngine::GetSuspendedDelta();
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
// result = true if animation has to be continued, false if animation stops
|
|
|
|
// maybe there are events for us in the queue !
|
2004-12-05 02:50:57 +00:00
|
|
|
if (frame)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2006-01-16 19:34:52 +00:00
|
|
|
for (vector<CValue*>::iterator i=m_events.begin(); !(i==m_events.end());i++)
|
2004-12-05 02:50:57 +00:00
|
|
|
{
|
|
|
|
if ((*i)->GetNumber() == 0.0f)
|
|
|
|
bNegativeEvent = true;
|
|
|
|
else
|
|
|
|
bPositiveEvent= true;
|
|
|
|
(*i)->Release();
|
2006-01-16 19:34:52 +00:00
|
|
|
|
2004-12-05 02:50:57 +00:00
|
|
|
}
|
2006-01-16 19:34:52 +00:00
|
|
|
m_events.clear();
|
2004-12-05 02:50:57 +00:00
|
|
|
|
|
|
|
if (bPositiveEvent)
|
|
|
|
m_flag |= ACT_FLAG_ACTIVE;
|
|
|
|
|
|
|
|
if (bNegativeEvent)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2008-07-10 14:23:19 +00:00
|
|
|
// dont continue where we left off when restarting
|
|
|
|
if (m_end_reset) {
|
|
|
|
m_flag &= ~ACT_FLAG_LOCKINPUT;
|
|
|
|
}
|
|
|
|
|
2004-12-05 02:50:57 +00:00
|
|
|
if (!(m_flag & ACT_FLAG_ACTIVE))
|
|
|
|
return false;
|
|
|
|
m_flag &= ~ACT_FLAG_ACTIVE;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We know that action actuators have been discarded from all non armature objects:
|
|
|
|
if we're being called, we're attached to a BL_ArmatureObject */
|
|
|
|
BL_ArmatureObject *obj = (BL_ArmatureObject*)GetParent();
|
2004-11-06 04:53:41 +00:00
|
|
|
float length = m_endframe - m_startframe;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
priority = m_priority;
|
|
|
|
|
|
|
|
/* Determine pre-incrementation behaviour and set appropriate flags */
|
|
|
|
switch (m_playtype){
|
|
|
|
case ACT_ACTION_MOTION:
|
|
|
|
if (bNegativeEvent){
|
|
|
|
keepgoing=false;
|
|
|
|
apply=false;
|
|
|
|
};
|
|
|
|
break;
|
|
|
|
case ACT_ACTION_FROM_PROP:
|
|
|
|
if (bNegativeEvent){
|
|
|
|
apply=false;
|
|
|
|
keepgoing=false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ACT_ACTION_LOOP_END:
|
|
|
|
if (bPositiveEvent){
|
|
|
|
if (!(m_flag & ACT_FLAG_LOCKINPUT)){
|
|
|
|
m_flag &= ~ACT_FLAG_KEYUP;
|
|
|
|
m_flag &= ~ACT_FLAG_REVERSE;
|
|
|
|
m_flag |= ACT_FLAG_LOCKINPUT;
|
2004-11-06 04:53:41 +00:00
|
|
|
m_localtime = m_startframe;
|
|
|
|
m_starttime = curtime;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (bNegativeEvent){
|
|
|
|
m_flag |= ACT_FLAG_KEYUP;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ACT_ACTION_LOOP_STOP:
|
|
|
|
if (bPositiveEvent){
|
|
|
|
if (!(m_flag & ACT_FLAG_LOCKINPUT)){
|
|
|
|
m_flag &= ~ACT_FLAG_REVERSE;
|
2004-11-06 04:53:41 +00:00
|
|
|
m_flag &= ~ACT_FLAG_KEYUP;
|
|
|
|
m_flag |= ACT_FLAG_LOCKINPUT;
|
|
|
|
SetStartTime(curtime);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (bNegativeEvent){
|
2004-11-06 04:53:41 +00:00
|
|
|
m_flag |= ACT_FLAG_KEYUP;
|
|
|
|
m_flag &= ~ACT_FLAG_LOCKINPUT;
|
2002-10-12 11:37:38 +00:00
|
|
|
keepgoing=false;
|
|
|
|
apply=false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ACT_ACTION_FLIPPER:
|
|
|
|
if (bPositiveEvent){
|
|
|
|
if (!(m_flag & ACT_FLAG_LOCKINPUT)){
|
|
|
|
m_flag &= ~ACT_FLAG_REVERSE;
|
2004-11-06 04:53:41 +00:00
|
|
|
m_flag |= ACT_FLAG_LOCKINPUT;
|
2004-12-05 02:50:57 +00:00
|
|
|
SetStartTime(curtime);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (bNegativeEvent){
|
|
|
|
m_flag |= ACT_FLAG_REVERSE;
|
2004-11-06 04:53:41 +00:00
|
|
|
m_flag &= ~ACT_FLAG_LOCKINPUT;
|
|
|
|
SetStartTime(curtime);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ACT_ACTION_PLAY:
|
|
|
|
if (bPositiveEvent){
|
|
|
|
if (!(m_flag & ACT_FLAG_LOCKINPUT)){
|
|
|
|
m_flag &= ~ACT_FLAG_REVERSE;
|
|
|
|
m_localtime = m_starttime;
|
2004-11-06 04:53:41 +00:00
|
|
|
m_starttime = curtime;
|
2002-10-12 11:37:38 +00:00
|
|
|
m_flag |= ACT_FLAG_LOCKINPUT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Perform increment */
|
|
|
|
if (keepgoing){
|
|
|
|
if (m_playtype == ACT_ACTION_MOTION){
|
|
|
|
MT_Point3 newpos;
|
|
|
|
MT_Point3 deltapos;
|
|
|
|
|
|
|
|
newpos = obj->NodeGetWorldPosition();
|
|
|
|
|
|
|
|
/* Find displacement */
|
|
|
|
deltapos = newpos-m_lastpos;
|
|
|
|
m_localtime += (length/m_stridelength) * deltapos.length();
|
|
|
|
m_lastpos = newpos;
|
|
|
|
}
|
|
|
|
else{
|
2004-11-06 04:53:41 +00:00
|
|
|
SetLocalTime(curtime);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if a wrapping response is needed */
|
|
|
|
if (length){
|
2004-11-06 04:53:41 +00:00
|
|
|
if (m_localtime < m_startframe || m_localtime > m_endframe)
|
2004-10-16 11:41:50 +00:00
|
|
|
{
|
2004-11-06 04:53:41 +00:00
|
|
|
m_localtime = m_startframe + fmod(m_localtime, length);
|
2004-10-16 11:41:50 +00:00
|
|
|
wrap = true;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2004-11-06 04:53:41 +00:00
|
|
|
m_localtime = m_startframe;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
/* Perform post-increment tasks */
|
|
|
|
switch (m_playtype){
|
|
|
|
case ACT_ACTION_FROM_PROP:
|
|
|
|
{
|
|
|
|
CValue* propval = GetParent()->GetProperty(m_propname);
|
2004-10-16 11:41:50 +00:00
|
|
|
if (propval)
|
2002-10-12 11:37:38 +00:00
|
|
|
m_localtime = propval->GetNumber();
|
|
|
|
|
|
|
|
if (bNegativeEvent){
|
|
|
|
keepgoing=false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ACT_ACTION_MOTION:
|
|
|
|
break;
|
|
|
|
case ACT_ACTION_LOOP_STOP:
|
|
|
|
break;
|
|
|
|
case ACT_ACTION_FLIPPER:
|
|
|
|
if (wrap){
|
|
|
|
if (!(m_flag & ACT_FLAG_REVERSE)){
|
2004-11-06 04:53:41 +00:00
|
|
|
m_localtime=m_endframe;
|
|
|
|
//keepgoing = false;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
else {
|
2004-11-06 04:53:41 +00:00
|
|
|
m_localtime=m_startframe;
|
2002-10-12 11:37:38 +00:00
|
|
|
keepgoing = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ACT_ACTION_LOOP_END:
|
|
|
|
if (wrap){
|
|
|
|
if (m_flag & ACT_FLAG_KEYUP){
|
|
|
|
keepgoing = false;
|
2004-11-06 04:53:41 +00:00
|
|
|
m_localtime = m_endframe;
|
2002-10-12 11:37:38 +00:00
|
|
|
m_flag &= ~ACT_FLAG_LOCKINPUT;
|
|
|
|
}
|
2004-12-05 02:50:57 +00:00
|
|
|
SetStartTime(curtime);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ACT_ACTION_PLAY:
|
|
|
|
if (wrap){
|
2004-11-06 04:53:41 +00:00
|
|
|
m_localtime = m_endframe;
|
2002-10-12 11:37:38 +00:00
|
|
|
keepgoing = false;
|
|
|
|
m_flag &= ~ACT_FLAG_LOCKINPUT;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
keepgoing = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-06-23 15:32:44 +00:00
|
|
|
/* Set the property if its defined */
|
2008-06-26 12:39:06 +00:00
|
|
|
if (m_framepropname[0] != '\0') {
|
2008-06-23 15:32:44 +00:00
|
|
|
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();
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2004-10-16 11:41:50 +00:00
|
|
|
if (bNegativeEvent)
|
2002-10-12 11:37:38 +00:00
|
|
|
m_blendframe=0.0;
|
|
|
|
|
|
|
|
/* Apply the pose if necessary*/
|
|
|
|
if (apply){
|
|
|
|
|
|
|
|
/* Priority test */
|
|
|
|
if (obj->SetActiveAction(this, priority, curtime)){
|
|
|
|
|
|
|
|
/* Get the underlying pose from the armature */
|
|
|
|
obj->GetPose(&m_pose);
|
|
|
|
|
|
|
|
/* Override the necessary channels with ones from the action */
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
extract_pose_from_action(m_pose, m_action, m_localtime);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
/* Perform the user override (if any) */
|
|
|
|
if (m_userpose){
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
extract_pose_from_pose(m_pose, m_userpose);
|
|
|
|
// clear_pose(m_userpose);
|
2002-10-12 11:37:38 +00:00
|
|
|
MEM_freeN(m_userpose);
|
|
|
|
m_userpose = NULL;
|
|
|
|
}
|
|
|
|
#if 1
|
|
|
|
/* Handle blending */
|
|
|
|
if (m_blendin && (m_blendframe<m_blendin)){
|
|
|
|
/* If this is the start of a blending sequence... */
|
|
|
|
if ((m_blendframe==0.0) || (!m_blendpose)){
|
|
|
|
obj->GetMRDPose(&m_blendpose);
|
2004-10-16 11:41:50 +00:00
|
|
|
m_blendstart = curtime;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Find percentages */
|
|
|
|
newweight = (m_blendframe/(float)m_blendin);
|
2007-07-19 12:29:28 +00:00
|
|
|
blend_poses(m_pose, m_blendpose, 1.0 - newweight, ACTSTRIPMODE_BLEND);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
/* Increment current blending percentage */
|
2008-06-17 10:06:38 +00:00
|
|
|
m_blendframe = (curtime - m_blendstart)*KX_KetsjiEngine::GetAnimFrameRate();
|
2002-10-12 11:37:38 +00:00
|
|
|
if (m_blendframe>m_blendin)
|
|
|
|
m_blendframe = m_blendin;
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
m_lastUpdate = m_localtime;
|
|
|
|
obj->SetPose (m_pose);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
m_blendframe = 0.0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!keepgoing){
|
|
|
|
m_blendframe = 0.0;
|
|
|
|
}
|
|
|
|
return keepgoing;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
/* Python functions */
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
/* setStart */
|
2008-09-20 11:08:35 +00:00
|
|
|
const char BL_ActionActuator::GetAction_doc[] =
|
2002-10-12 11:37:38 +00:00
|
|
|
"getAction()\n"
|
|
|
|
"\tReturns a string containing the name of the current action.\n";
|
|
|
|
|
2009-04-19 17:29:07 +00:00
|
|
|
PyObject* BL_ActionActuator::PyGetAction(PyObject* args,
|
2002-10-12 11:37:38 +00:00
|
|
|
PyObject* kwds) {
|
2009-01-21 13:54:53 +00:00
|
|
|
ShowDeprecationWarning("getAction()", "the action property");
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
if (m_action){
|
2008-08-14 03:23:36 +00:00
|
|
|
return PyString_FromString(m_action->id.name+2);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2008-08-14 03:23:36 +00:00
|
|
|
Py_RETURN_NONE;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* getProperty */
|
2008-09-20 11:08:35 +00:00
|
|
|
const char BL_ActionActuator::GetProperty_doc[] =
|
2002-10-12 11:37:38 +00:00
|
|
|
"getProperty()\n"
|
|
|
|
"\tReturns the name of the property to be used in FromProp mode.\n";
|
|
|
|
|
2009-04-19 17:29:07 +00:00
|
|
|
PyObject* BL_ActionActuator::PyGetProperty(PyObject* args,
|
2002-10-12 11:37:38 +00:00
|
|
|
PyObject* kwds) {
|
2009-01-21 13:54:53 +00:00
|
|
|
ShowDeprecationWarning("getProperty()", "the property property");
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
PyObject *result;
|
|
|
|
|
2003-01-03 21:36:16 +00:00
|
|
|
result = Py_BuildValue("s", (const char *)m_propname);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2008-06-23 15:32:44 +00:00
|
|
|
/* getProperty */
|
2008-09-20 11:08:35 +00:00
|
|
|
const char BL_ActionActuator::GetFrameProperty_doc[] =
|
2008-06-23 15:32:44 +00:00
|
|
|
"getFrameProperty()\n"
|
|
|
|
"\tReturns the name of the property, that is set to the current frame number.\n";
|
|
|
|
|
2009-04-19 17:29:07 +00:00
|
|
|
PyObject* BL_ActionActuator::PyGetFrameProperty(PyObject* args,
|
2008-06-23 15:32:44 +00:00
|
|
|
PyObject* kwds) {
|
2009-01-21 13:54:53 +00:00
|
|
|
ShowDeprecationWarning("getFrameProperty()", "the frameProperty property");
|
|
|
|
|
2008-06-23 15:32:44 +00:00
|
|
|
PyObject *result;
|
|
|
|
|
|
|
|
result = Py_BuildValue("s", (const char *)m_framepropname);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/* getFrame */
|
2008-09-20 11:08:35 +00:00
|
|
|
const char BL_ActionActuator::GetFrame_doc[] =
|
2002-10-12 11:37:38 +00:00
|
|
|
"getFrame()\n"
|
|
|
|
"\tReturns the current frame number.\n";
|
|
|
|
|
2009-04-19 17:29:07 +00:00
|
|
|
PyObject* BL_ActionActuator::PyGetFrame(PyObject* args,
|
2002-10-12 11:37:38 +00:00
|
|
|
PyObject* kwds) {
|
2009-01-21 13:54:53 +00:00
|
|
|
ShowDeprecationWarning("getFrame()", "the frame property");
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
PyObject *result;
|
|
|
|
|
|
|
|
result = Py_BuildValue("f", m_localtime);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* getEnd */
|
2008-09-20 11:08:35 +00:00
|
|
|
const char BL_ActionActuator::GetEnd_doc[] =
|
2002-10-12 11:37:38 +00:00
|
|
|
"getEnd()\n"
|
|
|
|
"\tReturns the last frame of the action.\n";
|
|
|
|
|
2009-04-19 17:29:07 +00:00
|
|
|
PyObject* BL_ActionActuator::PyGetEnd(PyObject* args,
|
2002-10-12 11:37:38 +00:00
|
|
|
PyObject* kwds) {
|
2009-01-21 13:54:53 +00:00
|
|
|
ShowDeprecationWarning("getEnd()", "the end property");
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
PyObject *result;
|
|
|
|
|
2004-11-06 04:53:41 +00:00
|
|
|
result = Py_BuildValue("f", m_endframe);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* getStart */
|
2008-09-20 11:08:35 +00:00
|
|
|
const char BL_ActionActuator::GetStart_doc[] =
|
2002-10-12 11:37:38 +00:00
|
|
|
"getStart()\n"
|
|
|
|
"\tReturns the starting frame of the action.\n";
|
|
|
|
|
2009-04-19 17:29:07 +00:00
|
|
|
PyObject* BL_ActionActuator::PyGetStart(PyObject* args,
|
2002-10-12 11:37:38 +00:00
|
|
|
PyObject* kwds) {
|
2009-01-21 13:54:53 +00:00
|
|
|
ShowDeprecationWarning("getStart()", "the start property");
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
PyObject *result;
|
|
|
|
|
2004-11-06 04:53:41 +00:00
|
|
|
result = Py_BuildValue("f", m_startframe);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* getBlendin */
|
2008-09-20 11:08:35 +00:00
|
|
|
const char BL_ActionActuator::GetBlendin_doc[] =
|
2002-10-12 11:37:38 +00:00
|
|
|
"getBlendin()\n"
|
|
|
|
"\tReturns the number of interpolation animation frames to be\n"
|
|
|
|
"\tgenerated when this actuator is triggered.\n";
|
|
|
|
|
2009-04-19 17:29:07 +00:00
|
|
|
PyObject* BL_ActionActuator::PyGetBlendin(PyObject* args,
|
2002-10-12 11:37:38 +00:00
|
|
|
PyObject* kwds) {
|
2009-01-21 13:54:53 +00:00
|
|
|
ShowDeprecationWarning("getBlendin()", "the blendin property");
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
PyObject *result;
|
|
|
|
|
|
|
|
result = Py_BuildValue("f", m_blendin);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* getPriority */
|
2008-09-20 11:08:35 +00:00
|
|
|
const char BL_ActionActuator::GetPriority_doc[] =
|
2002-10-12 11:37:38 +00:00
|
|
|
"getPriority()\n"
|
|
|
|
"\tReturns the priority for this actuator. Actuators with lower\n"
|
|
|
|
"\tPriority numbers will override actuators with higher numbers.\n";
|
|
|
|
|
2009-04-19 17:29:07 +00:00
|
|
|
PyObject* BL_ActionActuator::PyGetPriority(PyObject* args,
|
2002-10-12 11:37:38 +00:00
|
|
|
PyObject* kwds) {
|
2009-01-21 13:54:53 +00:00
|
|
|
ShowDeprecationWarning("getPriority()", "the priority property");
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
PyObject *result;
|
|
|
|
|
|
|
|
result = Py_BuildValue("i", m_priority);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* setAction */
|
2008-09-20 11:08:35 +00:00
|
|
|
const char BL_ActionActuator::SetAction_doc[] =
|
2002-10-12 11:37:38 +00:00
|
|
|
"setAction(action, (reset))\n"
|
|
|
|
"\t - action : The name of the action to set as the current action.\n"
|
|
|
|
"\t - reset : Optional parameter indicating whether to reset the\n"
|
|
|
|
"\t blend timer or not. A value of 1 indicates that the\n"
|
|
|
|
"\t timer should be reset. A value of 0 will leave it\n"
|
|
|
|
"\t unchanged. If reset is not specified, the timer will"
|
|
|
|
"\t be reset.\n";
|
|
|
|
|
2009-04-19 17:29:07 +00:00
|
|
|
PyObject* BL_ActionActuator::PySetAction(PyObject* args,
|
2002-10-12 11:37:38 +00:00
|
|
|
PyObject* kwds) {
|
2009-01-21 13:54:53 +00:00
|
|
|
ShowDeprecationWarning("setAction()", "the action property");
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
char *string;
|
|
|
|
int reset = 1;
|
|
|
|
|
2009-04-10 16:45:19 +00:00
|
|
|
if (PyArg_ParseTuple(args,"s|i:setAction",&string, &reset))
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
bAction *action;
|
|
|
|
|
|
|
|
action = (bAction*)SCA_ILogicBrick::m_sCurrentLogicManager->GetActionByName(STR_String(string));
|
|
|
|
|
|
|
|
if (!action){
|
|
|
|
/* NOTE! Throw an exception or something */
|
|
|
|
// printf ("setAction failed: Action not found\n", string);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
m_action=action;
|
|
|
|
if (reset)
|
|
|
|
m_blendframe = 0;
|
|
|
|
}
|
|
|
|
}
|
2008-07-01 13:21:37 +00:00
|
|
|
else {
|
|
|
|
return NULL;
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-08-14 03:23:36 +00:00
|
|
|
Py_RETURN_NONE;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* setStart */
|
2008-09-20 11:08:35 +00:00
|
|
|
const char BL_ActionActuator::SetStart_doc[] =
|
2002-10-12 11:37:38 +00:00
|
|
|
"setStart(start)\n"
|
|
|
|
"\t - start : Specifies the starting frame of the animation.\n";
|
|
|
|
|
2009-04-19 17:29:07 +00:00
|
|
|
PyObject* BL_ActionActuator::PySetStart(PyObject* args,
|
2002-10-12 11:37:38 +00:00
|
|
|
PyObject* kwds) {
|
2009-01-21 13:54:53 +00:00
|
|
|
ShowDeprecationWarning("setStart()", "the start property");
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
float start;
|
|
|
|
|
2009-04-10 16:45:19 +00:00
|
|
|
if (PyArg_ParseTuple(args,"f:setStart",&start))
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2004-11-06 04:53:41 +00:00
|
|
|
m_startframe = start;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2008-07-01 13:21:37 +00:00
|
|
|
else {
|
|
|
|
return NULL;
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-08-14 03:23:36 +00:00
|
|
|
Py_RETURN_NONE;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* setEnd */
|
2008-09-20 11:08:35 +00:00
|
|
|
const char BL_ActionActuator::SetEnd_doc[] =
|
2002-10-12 11:37:38 +00:00
|
|
|
"setEnd(end)\n"
|
|
|
|
"\t - end : Specifies the ending frame of the animation.\n";
|
|
|
|
|
2009-04-19 17:29:07 +00:00
|
|
|
PyObject* BL_ActionActuator::PySetEnd(PyObject* args,
|
2002-10-12 11:37:38 +00:00
|
|
|
PyObject* kwds) {
|
2009-01-21 13:54:53 +00:00
|
|
|
ShowDeprecationWarning("setEnd()", "the end property");
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
float end;
|
|
|
|
|
2009-04-10 16:45:19 +00:00
|
|
|
if (PyArg_ParseTuple(args,"f:setEnd",&end))
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2004-11-06 04:53:41 +00:00
|
|
|
m_endframe = end;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2008-07-01 13:21:37 +00:00
|
|
|
else {
|
|
|
|
return NULL;
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-08-14 03:23:36 +00:00
|
|
|
Py_RETURN_NONE;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* setBlendin */
|
2008-09-20 11:08:35 +00:00
|
|
|
const char BL_ActionActuator::SetBlendin_doc[] =
|
2002-10-12 11:37:38 +00:00
|
|
|
"setBlendin(blendin)\n"
|
|
|
|
"\t - blendin : Specifies the number of frames of animation to generate\n"
|
|
|
|
"\t when making transitions between actions.\n";
|
|
|
|
|
2009-04-19 17:29:07 +00:00
|
|
|
PyObject* BL_ActionActuator::PySetBlendin(PyObject* args,
|
2002-10-12 11:37:38 +00:00
|
|
|
PyObject* kwds) {
|
2009-01-21 13:54:53 +00:00
|
|
|
ShowDeprecationWarning("setBlendin()", "the blendin property");
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
float blendin;
|
|
|
|
|
2009-04-10 16:45:19 +00:00
|
|
|
if (PyArg_ParseTuple(args,"f:setBlendin",&blendin))
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
m_blendin = blendin;
|
|
|
|
}
|
2008-07-01 13:21:37 +00:00
|
|
|
else {
|
|
|
|
return NULL;
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-08-14 03:23:36 +00:00
|
|
|
Py_RETURN_NONE;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* setBlendtime */
|
2008-09-20 11:08:35 +00:00
|
|
|
const char BL_ActionActuator::SetBlendtime_doc[] =
|
2002-10-12 11:37:38 +00:00
|
|
|
"setBlendtime(blendtime)\n"
|
|
|
|
"\t - blendtime : Allows the script to directly modify the internal timer\n"
|
|
|
|
"\t used when generating transitions between actions. This\n"
|
|
|
|
"\t parameter must be in the range from 0.0 to 1.0.\n";
|
|
|
|
|
2009-04-19 17:29:07 +00:00
|
|
|
PyObject* BL_ActionActuator::PySetBlendtime(PyObject* args,
|
2002-10-12 11:37:38 +00:00
|
|
|
PyObject* kwds) {
|
2009-01-21 13:54:53 +00:00
|
|
|
ShowDeprecationWarning("setBlendtime()", "the blendtime property");
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
float blendframe;
|
|
|
|
|
2009-04-10 16:45:19 +00:00
|
|
|
if (PyArg_ParseTuple(args,"f:setBlendtime",&blendframe))
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
m_blendframe = blendframe * m_blendin;
|
|
|
|
if (m_blendframe<0)
|
|
|
|
m_blendframe = 0;
|
|
|
|
if (m_blendframe>m_blendin)
|
|
|
|
m_blendframe = m_blendin;
|
|
|
|
}
|
2008-07-01 13:21:37 +00:00
|
|
|
else {
|
|
|
|
return NULL;
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-08-14 03:23:36 +00:00
|
|
|
Py_RETURN_NONE;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* setPriority */
|
2008-09-20 11:08:35 +00:00
|
|
|
const char BL_ActionActuator::SetPriority_doc[] =
|
2002-10-12 11:37:38 +00:00
|
|
|
"setPriority(priority)\n"
|
|
|
|
"\t - priority : Specifies the new priority. Actuators will lower\n"
|
|
|
|
"\t priority numbers will override actuators with higher\n"
|
|
|
|
"\t numbers.\n";
|
|
|
|
|
2009-04-19 17:29:07 +00:00
|
|
|
PyObject* BL_ActionActuator::PySetPriority(PyObject* args,
|
2002-10-12 11:37:38 +00:00
|
|
|
PyObject* kwds) {
|
2009-01-21 13:54:53 +00:00
|
|
|
ShowDeprecationWarning("setPriority()", "the priority property");
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
int priority;
|
|
|
|
|
2009-04-10 16:45:19 +00:00
|
|
|
if (PyArg_ParseTuple(args,"i:setPriority",&priority))
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
m_priority = priority;
|
|
|
|
}
|
2008-07-01 13:21:37 +00:00
|
|
|
else {
|
|
|
|
return NULL;
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-08-14 03:23:36 +00:00
|
|
|
Py_RETURN_NONE;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* setFrame */
|
2008-09-20 11:08:35 +00:00
|
|
|
const char BL_ActionActuator::SetFrame_doc[] =
|
2002-10-12 11:37:38 +00:00
|
|
|
"setFrame(frame)\n"
|
|
|
|
"\t - frame : Specifies the new current frame for the animation\n";
|
|
|
|
|
2009-04-19 17:29:07 +00:00
|
|
|
PyObject* BL_ActionActuator::PySetFrame(PyObject* args,
|
2002-10-12 11:37:38 +00:00
|
|
|
PyObject* kwds) {
|
2009-01-21 13:54:53 +00:00
|
|
|
ShowDeprecationWarning("setFrame()", "the frame property");
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
float frame;
|
|
|
|
|
2009-04-10 16:45:19 +00:00
|
|
|
if (PyArg_ParseTuple(args,"f:setFrame",&frame))
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
m_localtime = frame;
|
2004-11-06 04:53:41 +00:00
|
|
|
if (m_localtime<m_startframe)
|
|
|
|
m_localtime=m_startframe;
|
|
|
|
else if (m_localtime>m_endframe)
|
|
|
|
m_localtime=m_endframe;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2008-07-01 13:21:37 +00:00
|
|
|
else {
|
|
|
|
return NULL;
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-08-14 03:23:36 +00:00
|
|
|
Py_RETURN_NONE;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* setProperty */
|
2008-09-20 11:08:35 +00:00
|
|
|
const char BL_ActionActuator::SetProperty_doc[] =
|
2002-10-12 11:37:38 +00:00
|
|
|
"setProperty(prop)\n"
|
|
|
|
"\t - prop : A string specifying the property name to be used in\n"
|
|
|
|
"\t FromProp playback mode.\n";
|
|
|
|
|
2009-04-19 17:29:07 +00:00
|
|
|
PyObject* BL_ActionActuator::PySetProperty(PyObject* args,
|
2002-10-12 11:37:38 +00:00
|
|
|
PyObject* kwds) {
|
2009-01-21 13:54:53 +00:00
|
|
|
ShowDeprecationWarning("setProperty()", "the property property");
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
char *string;
|
|
|
|
|
2009-04-10 16:45:19 +00:00
|
|
|
if (PyArg_ParseTuple(args,"s:setProperty",&string))
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
m_propname = string;
|
|
|
|
}
|
2008-07-01 13:21:37 +00:00
|
|
|
else {
|
|
|
|
return NULL;
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-08-14 03:23:36 +00:00
|
|
|
Py_RETURN_NONE;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2008-06-23 15:32:44 +00:00
|
|
|
/* setFrameProperty */
|
2008-09-20 11:08:35 +00:00
|
|
|
const char BL_ActionActuator::SetFrameProperty_doc[] =
|
2008-06-23 15:32:44 +00:00
|
|
|
"setFrameProperty(prop)\n"
|
|
|
|
"\t - prop : A string specifying the property of the frame set up update.\n";
|
|
|
|
|
2009-04-19 17:29:07 +00:00
|
|
|
PyObject* BL_ActionActuator::PySetFrameProperty(PyObject* args,
|
2008-06-23 15:32:44 +00:00
|
|
|
PyObject* kwds) {
|
2009-01-21 13:54:53 +00:00
|
|
|
ShowDeprecationWarning("setFrameProperty()", "the frameProperty property");
|
|
|
|
|
2008-06-23 15:32:44 +00:00
|
|
|
char *string;
|
|
|
|
|
2009-04-10 16:45:19 +00:00
|
|
|
if (PyArg_ParseTuple(args,"s:setFrameProperty",&string))
|
2008-06-23 15:32:44 +00:00
|
|
|
{
|
|
|
|
m_framepropname = string;
|
|
|
|
}
|
2008-07-01 13:21:37 +00:00
|
|
|
else {
|
|
|
|
return NULL;
|
|
|
|
}
|
2008-06-23 15:32:44 +00:00
|
|
|
|
2008-08-14 03:23:36 +00:00
|
|
|
Py_RETURN_NONE;
|
2008-06-23 15:32:44 +00:00
|
|
|
}
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/*
|
2009-04-19 17:29:07 +00:00
|
|
|
PyObject* BL_ActionActuator::PyGetChannel(PyObject* args,
|
2002-10-12 11:37:38 +00:00
|
|
|
PyObject* kwds) {
|
|
|
|
char *string;
|
|
|
|
|
2009-04-10 16:45:19 +00:00
|
|
|
if (PyArg_ParseTuple(args,"s:getChannel",&string))
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
m_propname = string;
|
|
|
|
}
|
2008-07-01 13:21:37 +00:00
|
|
|
else {
|
|
|
|
return NULL;
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-08-14 03:23:36 +00:00
|
|
|
Py_RETURN_NONE;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2009-01-21 13:54:53 +00:00
|
|
|
/* getType */
|
|
|
|
const char BL_ActionActuator::GetType_doc[] =
|
|
|
|
"getType()\n"
|
|
|
|
"\tReturns the operation mode of the actuator.\n";
|
2009-04-19 17:29:07 +00:00
|
|
|
PyObject* BL_ActionActuator::PyGetType(PyObject* args,
|
2009-01-21 13:54:53 +00:00
|
|
|
PyObject* kwds) {
|
|
|
|
ShowDeprecationWarning("getType()", "the type property");
|
|
|
|
|
|
|
|
return Py_BuildValue("h", m_playtype);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* setType */
|
|
|
|
const char BL_ActionActuator::SetType_doc[] =
|
|
|
|
"setType(mode)\n"
|
|
|
|
"\t - mode: Play (0), Flipper (2), LoopStop (3), LoopEnd (4) or Property (6)\n"
|
|
|
|
"\tSet the operation mode of the actuator.\n";
|
2009-04-19 17:29:07 +00:00
|
|
|
PyObject* BL_ActionActuator::PySetType(PyObject* args,
|
2009-01-21 13:54:53 +00:00
|
|
|
PyObject* kwds) {
|
|
|
|
ShowDeprecationWarning("setType()", "the type property");
|
|
|
|
|
|
|
|
short typeArg;
|
|
|
|
|
2009-04-10 16:45:19 +00:00
|
|
|
if (!PyArg_ParseTuple(args, "h:setType", &typeArg)) {
|
2009-01-21 13:54:53 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (typeArg) {
|
2009-01-22 17:40:47 +00:00
|
|
|
case ACT_ACTION_PLAY:
|
|
|
|
case ACT_ACTION_FLIPPER:
|
|
|
|
case ACT_ACTION_LOOP_STOP:
|
|
|
|
case ACT_ACTION_LOOP_END:
|
|
|
|
case ACT_ACTION_FROM_PROP:
|
2009-01-21 13:54:53 +00:00
|
|
|
m_playtype = typeArg;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("Invalid type for action actuator: %d\n", typeArg); /* error */
|
|
|
|
}
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
}
|
|
|
|
|
2009-04-19 17:29:07 +00:00
|
|
|
PyObject* BL_ActionActuator::PyGetContinue() {
|
2009-01-21 13:54:53 +00:00
|
|
|
ShowDeprecationWarning("getContinue()", "the continue property");
|
|
|
|
|
|
|
|
return PyInt_FromLong((long)(m_end_reset==0));
|
|
|
|
}
|
|
|
|
|
2009-04-19 17:29:07 +00:00
|
|
|
PyObject* BL_ActionActuator::PySetContinue(PyObject* value) {
|
2009-01-21 13:54:53 +00:00
|
|
|
ShowDeprecationWarning("setContinue()", "the continue property");
|
|
|
|
|
|
|
|
int param = PyObject_IsTrue( value );
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
//<-----Deprecated
|
|
|
|
|
|
|
|
/* setChannel */
|
|
|
|
KX_PYMETHODDEF_DOC(BL_ActionActuator, setChannel,
|
2002-10-12 11:37:38 +00:00
|
|
|
"setChannel(channel, matrix)\n"
|
|
|
|
"\t - channel : A string specifying the name of the bone channel.\n"
|
|
|
|
"\t - matrix : A 4x4 matrix specifying the overriding transformation\n"
|
2009-01-21 13:54:53 +00:00
|
|
|
"\t as an offset from the bone's rest position.\n")
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
float matrix[4][4];
|
|
|
|
char *string;
|
|
|
|
PyObject* pylist;
|
|
|
|
bool error = false;
|
|
|
|
int row,col;
|
|
|
|
int mode = 0; /* 0 for bone space, 1 for armature/world space */
|
|
|
|
|
2009-04-10 16:45:19 +00:00
|
|
|
if (!PyArg_ParseTuple(args,"sO|i:setChannel", &string, &pylist, &mode))
|
2008-07-01 13:21:37 +00:00
|
|
|
return NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
if (pylist->ob_type == &CListValue::Type)
|
|
|
|
{
|
|
|
|
CListValue* listval = (CListValue*) pylist;
|
|
|
|
if (listval->GetCount() == 4)
|
|
|
|
{
|
|
|
|
for (row=0;row<4;row++) // each row has a 4-vector [x,y,z, w]
|
|
|
|
{
|
|
|
|
CListValue* vecval = (CListValue*)listval->GetValue(row);
|
|
|
|
for (col=0;col<4;col++)
|
|
|
|
{
|
|
|
|
matrix[row][col] = vecval->GetValue(col)->GetNumber();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// assert the list is long enough...
|
|
|
|
int numitems = PyList_Size(pylist);
|
|
|
|
if (numitems == 4)
|
|
|
|
{
|
|
|
|
for (row=0;row<4;row++) // each row has a 4-vector [x,y,z, w]
|
|
|
|
{
|
|
|
|
|
|
|
|
PyObject* veclist = PyList_GetItem(pylist,row); // here we have a vector4 list
|
|
|
|
for (col=0;col<4;col++)
|
|
|
|
{
|
|
|
|
matrix[row][col] = PyFloat_AsDouble(PyList_GetItem(veclist,col));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!error)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* DO IT HERE */
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
bPoseChannel *pchan= verify_pose_channel(m_userpose, string);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
Mat4ToQuat(matrix, pchan->quat);
|
|
|
|
Mat4ToSize(matrix, pchan->size);
|
|
|
|
VECCOPY (pchan->loc, matrix[3]);
|
|
|
|
|
|
|
|
pchan->flag |= POSE_ROT|POSE_LOC|POSE_SIZE;
|
|
|
|
|
|
|
|
if (!m_userpose){
|
|
|
|
m_userpose = (bPose*)MEM_callocN(sizeof(bPose), "userPose");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-14 03:23:36 +00:00
|
|
|
Py_RETURN_NONE;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2009-01-21 13:54:53 +00:00
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
/* Python Integration Hooks */
|
|
|
|
/* ------------------------------------------------------------------------- */
|
2004-07-17 05:28:23 +00:00
|
|
|
|
2009-01-21 13:54:53 +00:00
|
|
|
PyTypeObject BL_ActionActuator::Type = {
|
2009-04-03 14:51:06 +00:00
|
|
|
PyObject_HEAD_INIT(NULL)
|
2009-01-21 13:54:53 +00:00
|
|
|
0,
|
|
|
|
"BL_ActionActuator",
|
2009-04-19 14:57:52 +00:00
|
|
|
sizeof(PyObjectPlus_Proxy),
|
2009-01-21 13:54:53 +00:00
|
|
|
0,
|
2009-04-19 14:57:52 +00:00
|
|
|
py_base_dealloc,
|
2009-01-21 13:54:53 +00:00
|
|
|
0,
|
|
|
|
0,
|
2009-04-03 14:51:06 +00:00
|
|
|
0,
|
|
|
|
0,
|
|
|
|
py_base_repr,
|
|
|
|
0,0,0,0,0,0,
|
|
|
|
py_base_getattro,
|
|
|
|
py_base_setattro,
|
|
|
|
0,0,0,0,0,0,0,0,0,
|
2009-04-03 04:12:20 +00:00
|
|
|
Methods
|
2009-01-21 13:54:53 +00:00
|
|
|
};
|
2004-07-17 05:28:23 +00:00
|
|
|
|
2009-01-21 13:54:53 +00:00
|
|
|
PyParentObject BL_ActionActuator::Parents[] = {
|
|
|
|
&BL_ActionActuator::Type,
|
|
|
|
&SCA_IActuator::Type,
|
|
|
|
&SCA_ILogicBrick::Type,
|
|
|
|
&CValue::Type,
|
|
|
|
NULL
|
|
|
|
};
|
2008-07-10 14:23:19 +00:00
|
|
|
|
2009-01-21 13:54:53 +00:00
|
|
|
PyMethodDef BL_ActionActuator::Methods[] = {
|
|
|
|
//Deprecated ----->
|
|
|
|
{"setAction", (PyCFunction) BL_ActionActuator::sPySetAction, METH_VARARGS, (PY_METHODCHAR)SetAction_doc},
|
|
|
|
{"setStart", (PyCFunction) BL_ActionActuator::sPySetStart, METH_VARARGS, (PY_METHODCHAR)SetStart_doc},
|
|
|
|
{"setEnd", (PyCFunction) BL_ActionActuator::sPySetEnd, METH_VARARGS, (PY_METHODCHAR)SetEnd_doc},
|
|
|
|
{"setBlendin", (PyCFunction) BL_ActionActuator::sPySetBlendin, METH_VARARGS, (PY_METHODCHAR)SetBlendin_doc},
|
|
|
|
{"setPriority", (PyCFunction) BL_ActionActuator::sPySetPriority, METH_VARARGS, (PY_METHODCHAR)SetPriority_doc},
|
|
|
|
{"setFrame", (PyCFunction) BL_ActionActuator::sPySetFrame, METH_VARARGS, (PY_METHODCHAR)SetFrame_doc},
|
|
|
|
{"setProperty", (PyCFunction) BL_ActionActuator::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc},
|
|
|
|
{"setFrameProperty", (PyCFunction) BL_ActionActuator::sPySetFrameProperty, METH_VARARGS, (PY_METHODCHAR)SetFrameProperty_doc},
|
|
|
|
{"setBlendtime", (PyCFunction) BL_ActionActuator::sPySetBlendtime, METH_VARARGS, (PY_METHODCHAR)SetBlendtime_doc},
|
2008-07-10 14:23:19 +00:00
|
|
|
|
2009-01-21 13:54:53 +00:00
|
|
|
{"getAction", (PyCFunction) BL_ActionActuator::sPyGetAction, METH_VARARGS, (PY_METHODCHAR)GetAction_doc},
|
|
|
|
{"getStart", (PyCFunction) BL_ActionActuator::sPyGetStart, METH_VARARGS, (PY_METHODCHAR)GetStart_doc},
|
|
|
|
{"getEnd", (PyCFunction) BL_ActionActuator::sPyGetEnd, METH_VARARGS, (PY_METHODCHAR)GetEnd_doc},
|
|
|
|
{"getBlendin", (PyCFunction) BL_ActionActuator::sPyGetBlendin, METH_VARARGS, (PY_METHODCHAR)GetBlendin_doc},
|
|
|
|
{"getPriority", (PyCFunction) BL_ActionActuator::sPyGetPriority, METH_VARARGS, (PY_METHODCHAR)GetPriority_doc},
|
|
|
|
{"getFrame", (PyCFunction) BL_ActionActuator::sPyGetFrame, METH_VARARGS, (PY_METHODCHAR)GetFrame_doc},
|
|
|
|
{"getProperty", (PyCFunction) BL_ActionActuator::sPyGetProperty, METH_VARARGS, (PY_METHODCHAR)GetProperty_doc},
|
|
|
|
{"getFrameProperty", (PyCFunction) BL_ActionActuator::sPyGetFrameProperty, METH_VARARGS, (PY_METHODCHAR)GetFrameProperty_doc},
|
|
|
|
// {"getChannel", (PyCFunction) BL_ActionActuator::sPyGetChannel, METH_VARARGS},
|
|
|
|
{"getType", (PyCFunction) BL_ActionActuator::sPyGetType, METH_VARARGS, (PY_METHODCHAR)GetType_doc},
|
|
|
|
{"setType", (PyCFunction) BL_ActionActuator::sPySetType, METH_VARARGS, (PY_METHODCHAR)SetType_doc},
|
|
|
|
{"getContinue", (PyCFunction) BL_ActionActuator::sPyGetContinue, METH_NOARGS, 0},
|
|
|
|
{"setContinue", (PyCFunction) BL_ActionActuator::sPySetContinue, METH_O, 0},
|
|
|
|
//<------
|
|
|
|
KX_PYMETHODTABLE(BL_ActionActuator, setChannel),
|
|
|
|
{NULL,NULL} //Sentinel
|
|
|
|
};
|
2008-07-10 14:23:19 +00:00
|
|
|
|
2009-01-21 13:54:53 +00:00
|
|
|
PyAttributeDef BL_ActionActuator::Attributes[] = {
|
|
|
|
KX_PYATTRIBUTE_FLOAT_RW("start", 0, MAXFRAMEF, BL_ActionActuator, m_startframe),
|
|
|
|
KX_PYATTRIBUTE_FLOAT_RW("end", 0, MAXFRAMEF, BL_ActionActuator, m_endframe),
|
|
|
|
KX_PYATTRIBUTE_FLOAT_RW("blendin", 0, MAXFRAMEF, BL_ActionActuator, m_blendin),
|
2009-04-04 02:57:35 +00:00
|
|
|
KX_PYATTRIBUTE_RW_FUNCTION("action", BL_ActionActuator, pyattr_get_action, pyattr_set_action),
|
2009-01-21 13:54:53 +00:00
|
|
|
KX_PYATTRIBUTE_SHORT_RW("priority", 0, 100, false, BL_ActionActuator, m_priority),
|
|
|
|
KX_PYATTRIBUTE_FLOAT_RW_CHECK("frame", 0, MAXFRAMEF, BL_ActionActuator, m_localtime, CheckFrame),
|
|
|
|
KX_PYATTRIBUTE_STRING_RW("property", 0, 31, false, BL_ActionActuator, m_propname),
|
|
|
|
KX_PYATTRIBUTE_STRING_RW("frameProperty", 0, 31, false, BL_ActionActuator, m_framepropname),
|
|
|
|
KX_PYATTRIBUTE_BOOL_RW("continue", BL_ActionActuator, m_end_reset),
|
|
|
|
KX_PYATTRIBUTE_FLOAT_RW_CHECK("blendTime", 0, MAXFRAMEF, BL_ActionActuator, m_blendframe, CheckBlendTime),
|
2009-01-22 17:40:47 +00:00
|
|
|
KX_PYATTRIBUTE_SHORT_RW_CHECK("type",0,100,false,BL_ActionActuator,m_playtype,CheckType),
|
2009-01-21 13:54:53 +00:00
|
|
|
{ NULL } //Sentinel
|
|
|
|
};
|
|
|
|
|
2009-04-03 14:51:06 +00:00
|
|
|
PyObject* BL_ActionActuator::py_getattro(PyObject *attr) {
|
|
|
|
py_getattro_up(SCA_IActuator);
|
2004-07-17 05:28:23 +00:00
|
|
|
}
|
|
|
|
|
2009-04-03 14:51:06 +00:00
|
|
|
int BL_ActionActuator::py_setattro(PyObject *attr, PyObject* value) {
|
2009-04-07 11:06:35 +00:00
|
|
|
py_setattro_up(SCA_IActuator);
|
2009-04-04 02:57:35 +00:00
|
|
|
}
|
2009-01-21 13:54:53 +00:00
|
|
|
|
|
|
|
|
2009-04-04 02:57:35 +00:00
|
|
|
PyObject* BL_ActionActuator::pyattr_get_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
|
|
|
{
|
|
|
|
BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v);
|
2009-04-05 14:55:50 +00:00
|
|
|
return PyString_FromString(self->GetAction() ? self->GetAction()->id.name+2 : "");
|
2009-04-04 02:57:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int BL_ActionActuator::pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
|
|
|
|
{
|
|
|
|
BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v);
|
|
|
|
|
|
|
|
if (!PyString_Check(value))
|
|
|
|
{
|
2009-04-19 21:01:12 +00:00
|
|
|
PyErr_SetString(PyExc_ValueError, "actuator.action = val: Action Actuator, expected the string name of the action");
|
2009-04-04 02:57:35 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
bAction *action= NULL;
|
|
|
|
STR_String val = PyString_AsString(value);
|
|
|
|
|
|
|
|
if (val != "")
|
|
|
|
{
|
2009-04-04 11:02:13 +00:00
|
|
|
action= (bAction*)SCA_ILogicBrick::m_sCurrentLogicManager->GetActionByName(val);
|
2009-01-21 13:54:53 +00:00
|
|
|
if (!action)
|
|
|
|
{
|
2009-04-19 21:01:12 +00:00
|
|
|
PyErr_SetString(PyExc_ValueError, "actuator.action = val: Action Actuator, action not found!");
|
2009-01-21 13:54:53 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2009-04-04 02:57:35 +00:00
|
|
|
|
|
|
|
self->SetAction(action);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|