Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitchell Stokes <mogurijin@gmail.com>2011-06-16 05:18:52 +0400
committerMitchell Stokes <mogurijin@gmail.com>2011-06-16 05:18:52 +0400
commitc02006bc2b8566ae96af1e9e9630f0ecd5a1d05e (patch)
treecb8e6182e5186389a3c041c60d67f2c90f97bcef /source/gameengine
parent49f7a4d8f8001465388977e50c8a439ad53ef8ae (diff)
BGE Animations: Adding the ipo flag options to the action actuator. This still needs more testing.
Diffstat (limited to 'source/gameengine')
-rw-r--r--source/gameengine/Converter/BL_ActionActuator.cpp2
-rw-r--r--source/gameengine/Converter/BL_ActionActuator.h3
-rw-r--r--source/gameengine/Converter/KX_ConvertActuators.cpp10
-rw-r--r--source/gameengine/Ketsji/BL_Action.cpp16
-rw-r--r--source/gameengine/Ketsji/BL_Action.h11
-rw-r--r--source/gameengine/Ketsji/BL_ActionManager.cpp3
-rw-r--r--source/gameengine/Ketsji/BL_ActionManager.h1
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.cpp14
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.h1
9 files changed, 46 insertions, 15 deletions
diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp
index 6230f03c4ed..b57eaadaea6 100644
--- a/source/gameengine/Converter/BL_ActionActuator.cpp
+++ b/source/gameengine/Converter/BL_ActionActuator.cpp
@@ -180,7 +180,7 @@ bool BL_ActionActuator::Update(double curtime, bool frame)
if (!m_is_going && bPositiveEvent)
{
m_is_going = true;
- obj->PlayAction(m_action->id.name+2, start, end, m_layer, m_blendin, play_mode);
+ obj->PlayAction(m_action->id.name+2, start, end, m_layer, m_blendin, play_mode, 0, m_ipo_flags);
if (m_end_reset)
obj->SetActionFrame(m_layer, m_localtime);
}
diff --git a/source/gameengine/Converter/BL_ActionActuator.h b/source/gameengine/Converter/BL_ActionActuator.h
index 6daf412d9a3..96b9b5e2551 100644
--- a/source/gameengine/Converter/BL_ActionActuator.h
+++ b/source/gameengine/Converter/BL_ActionActuator.h
@@ -53,6 +53,7 @@ public:
short blendin,
short priority,
short layer,
+ short ipo_flags,
short end_reset,
float stride)
: SCA_IActuator(gameobj, KX_ACT_ACTION),
@@ -71,6 +72,7 @@ public:
m_playtype(playtype),
m_priority(priority),
m_layer(layer),
+ m_ipo_flags(ipo_flags),
m_end_reset(end_reset),
m_is_going(false),
m_pose(NULL),
@@ -166,6 +168,7 @@ protected:
short m_playtype;
short m_priority;
short m_layer;
+ short m_ipo_flags;
bool m_end_reset;
bool m_is_going;
struct bPose* m_pose;
diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp
index 1a8368a12fa..c7b873de5e4 100644
--- a/source/gameengine/Converter/KX_ConvertActuators.cpp
+++ b/source/gameengine/Converter/KX_ConvertActuators.cpp
@@ -95,6 +95,7 @@
#include "BL_ActionActuator.h"
#include "BL_ShapeActionActuator.h"
#include "BL_ArmatureActuator.h"
+#include "BL_Action.h"
/* end of blender include block */
#include "BL_BlenderDataConversion.h"
@@ -195,6 +196,14 @@ void BL_ConvertActuators(char* maggiename,
bActionActuator* actact = (bActionActuator*) bact->data;
STR_String propname = (actact->name ? actact->name : "");
STR_String propframe = (actact->frameProp ? actact->frameProp : "");
+
+ short ipo_flags = 0;
+
+ // Convert flags
+ if (actact->flag & ACT_IPOFORCE) ipo_flags |= BL_Action::ACT_IPOFLAG_FORCE;
+ if (actact->flag & ACT_IPOLOCAL) ipo_flags |= BL_Action::ACT_IPOFLAG_LOCAL;
+ if (actact->flag & ACT_IPOADD) ipo_flags |= BL_Action::ACT_IPOFLAG_ADD;
+ if (actact->flag & ACT_IPOCHILD) ipo_flags |= BL_Action::ACT_IPOFLAG_CHILD;
BL_ActionActuator* tmpbaseact = new BL_ActionActuator(
gameobj,
@@ -207,6 +216,7 @@ void BL_ConvertActuators(char* maggiename,
actact->blendin,
actact->priority,
actact->layer,
+ ipo_flags,
actact->end_reset,
actact->stridelength
// Ketsji at 1, because zero is reserved for "NoDef"
diff --git a/source/gameengine/Ketsji/BL_Action.cpp b/source/gameengine/Ketsji/BL_Action.cpp
index bd65c7d45d8..836bc24ffcd 100644
--- a/source/gameengine/Ketsji/BL_Action.cpp
+++ b/source/gameengine/Ketsji/BL_Action.cpp
@@ -58,6 +58,7 @@ BL_Action::BL_Action(class KX_GameObject* gameobj)
m_blendframe(0.f),
m_blendstart(0.f),
m_speed(0.f),
+ m_ipo_flags(0),
m_pose(NULL),
m_blendpose(NULL),
m_sg_contr(NULL),
@@ -85,6 +86,7 @@ void BL_Action::Play(const char* name,
float blendin,
short play_mode,
short blend_mode,
+ short ipo_flags,
float playback_speed)
{
bAction* prev_action = m_action;
@@ -105,8 +107,10 @@ void BL_Action::Play(const char* name,
m_sg_contr = BL_CreateIPO(m_action, m_obj, KX_GetActiveScene()->GetSceneConverter());
m_obj->GetSGNode()->AddSGController(m_sg_contr);
m_sg_contr->SetObject(m_obj->GetSGNode());
- InitIPO();
}
+
+ m_ipo_flags = ipo_flags;
+ InitIPO();
// Now that we have an action, we have something we can play
m_starttime = KX_GetActiveEngine()->GetFrameTime();
@@ -131,9 +135,9 @@ void BL_Action::InitIPO()
{
// Initialize the IPO
m_sg_contr->SetOption(SG_Controller::SG_CONTR_IPO_RESET, true);
- m_sg_contr->SetOption(SG_Controller::SG_CONTR_IPO_IPO_AS_FORCE, false);
- m_sg_contr->SetOption(SG_Controller::SG_CONTR_IPO_IPO_ADD, false);
- m_sg_contr->SetOption(SG_Controller::SG_CONTR_IPO_LOCAL, false);
+ m_sg_contr->SetOption(SG_Controller::SG_CONTR_IPO_IPO_AS_FORCE, m_ipo_flags & ACT_IPOFLAG_FORCE);
+ m_sg_contr->SetOption(SG_Controller::SG_CONTR_IPO_IPO_ADD, m_ipo_flags & ACT_IPOFLAG_ADD);
+ m_sg_contr->SetOption(SG_Controller::SG_CONTR_IPO_LOCAL, m_ipo_flags & ACT_IPOFLAG_LOCAL);
}
float BL_Action::GetFrame()
@@ -259,8 +263,6 @@ void BL_Action::Update(float curtime)
else
{
InitIPO();
- m_sg_contr->SetSimulatedTime(m_localtime);
- m_obj->GetSGNode()->UpdateWorldData(m_localtime);
- m_obj->UpdateTransform();
+ m_obj->UpdateIPO(m_localtime, m_ipo_flags & ACT_IPOFLAG_CHILD);
}
}
diff --git a/source/gameengine/Ketsji/BL_Action.h b/source/gameengine/Ketsji/BL_Action.h
index 1eb4483eb37..fc80d9bea34 100644
--- a/source/gameengine/Ketsji/BL_Action.h
+++ b/source/gameengine/Ketsji/BL_Action.h
@@ -59,6 +59,8 @@ private:
short m_playmode;
short m_blendmode;
+ short m_ipo_flags;
+
bool m_done;
void InitIPO();
@@ -73,6 +75,7 @@ public:
float blendin,
short play_mode,
short blend_mode,
+ short ipo_flags,
float playback_speed);
void Stop();
bool IsDone() {return m_done;}
@@ -99,6 +102,14 @@ public:
ACT_BLEND_MAX,
};
+ enum
+ {
+ ACT_IPOFLAG_FORCE = 1,
+ ACT_IPOFLAG_LOCAL = 2,
+ ACT_IPOFLAG_ADD = 4,
+ ACT_IPOFLAG_CHILD = 8,
+ };
+
#ifdef WITH_CXX_GUARDEDALLOC
public:
void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_Action"); }
diff --git a/source/gameengine/Ketsji/BL_ActionManager.cpp b/source/gameengine/Ketsji/BL_ActionManager.cpp
index 0a99a5a43a9..935e9129d21 100644
--- a/source/gameengine/Ketsji/BL_ActionManager.cpp
+++ b/source/gameengine/Ketsji/BL_ActionManager.cpp
@@ -63,6 +63,7 @@ void BL_ActionManager::PlayAction(const char* name,
float blendin,
short play_mode,
short blend_mode,
+ short ipo_flags,
float playback_speed)
{
// Remove a currently running action on this layer if there is one
@@ -70,7 +71,7 @@ void BL_ActionManager::PlayAction(const char* name,
StopAction(layer);
// Create a new action
- m_layers[layer]->Play(name, start, end, blendin, play_mode, blend_mode, playback_speed);
+ m_layers[layer]->Play(name, start, end, blendin, play_mode, blend_mode, ipo_flags, playback_speed);
}
void BL_ActionManager::StopAction(short layer)
diff --git a/source/gameengine/Ketsji/BL_ActionManager.h b/source/gameengine/Ketsji/BL_ActionManager.h
index b769db02bf9..f4ef43d3801 100644
--- a/source/gameengine/Ketsji/BL_ActionManager.h
+++ b/source/gameengine/Ketsji/BL_ActionManager.h
@@ -49,6 +49,7 @@ public:
float blendin=0.f,
short play_mode=0,
short blend_mode=0,
+ short ipo_flags=0,
float playback_speed=1.f);
float GetActionFrame(short layer);
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index 27f4a72ccdf..aa0ce14a3cc 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -367,9 +367,10 @@ void KX_GameObject::PlayAction(const char* name,
float blendin,
short play_mode,
short blend_mode,
+ short ipo_flags,
float playback_speed)
{
- GetActionManager()->PlayAction(name, start, end, layer, blendin, play_mode, blend_mode, playback_speed);
+ GetActionManager()->PlayAction(name, start, end, layer, blendin, play_mode, blend_mode, ipo_flags, playback_speed);
}
void KX_GameObject::StopAction(short layer)
@@ -3033,18 +3034,19 @@ KX_PYMETHODDEF_DOC_VARARGS(KX_GameObject, sendMessage,
}
KX_PYMETHODDEF_DOC(KX_GameObject, playAction,
- "playAction(name, start_frame, end_frame, layer=0, blendin=0, play_mode=ACT_MODE_PLAY, blend_mode=ACT_BLEND_NONE, speed=1.0)\n"
+ "playAction(name, start_frame, end_frame, layer=0, blendin=0, play_mode=ACT_MODE_PLAY, blend_mode=ACT_BLEND_NONE, ipo_flags=0, speed=1.0)\n"
"plays an action\n")
{
const char* name;
float start, end, blendin=0.f, speed=1.f;
short layer=0;
+ short ipo_flags=0;
short play_mode=0, blend_mode=0;
- static const char *kwlist[] = {"name", "start_frame", "end_frame", "layer", "blendin", "play_mode", "blend_mode", "speed", NULL};
+ static const char *kwlist[] = {"name", "start_frame", "end_frame", "layer", "blendin", "play_mode", "blend_mode", "ipo_flags", "speed", NULL};
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "sff|hfhhf", const_cast<char**>(kwlist),
- &name, &start, &end, &layer, &blendin, &play_mode, &blend_mode, &speed))
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "sff|hfhhhf", const_cast<char**>(kwlist),
+ &name, &start, &end, &layer, &blendin, &play_mode, &blend_mode, &ipo_flags, &speed))
return NULL;
if (layer < 0 || layer > MAX_ACTION_LAYERS)
@@ -3065,7 +3067,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, playAction,
blend_mode = BL_Action::ACT_BLEND_NONE;
}
- PlayAction(name, start, end, layer, blendin, play_mode, blend_mode, speed);
+ PlayAction(name, start, end, layer, blendin, play_mode, blend_mode, ipo_flags, speed);
Py_RETURN_NONE;
}
diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h
index 0ff0ec84529..b97dad1a35e 100644
--- a/source/gameengine/Ketsji/KX_GameObject.h
+++ b/source/gameengine/Ketsji/KX_GameObject.h
@@ -218,6 +218,7 @@ public:
float blendin=0.f,
short play_mode=0,
short blend_mode=0,
+ short ipo_flags=0,
float playback_speed=1.f);
/**