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:
Diffstat (limited to 'source/gameengine/Converter')
-rw-r--r--source/gameengine/Converter/BL_ActionActuator.cpp534
-rw-r--r--source/gameengine/Converter/BL_ActionActuator.h69
-rw-r--r--source/gameengine/Converter/BL_ArmatureObject.cpp7
-rw-r--r--source/gameengine/Converter/BL_ArmatureObject.h6
-rw-r--r--source/gameengine/Converter/BL_BlenderDataConversion.cpp14
-rw-r--r--source/gameengine/Converter/BL_DeformableGameObject.cpp9
-rw-r--r--source/gameengine/Converter/BL_DeformableGameObject.h17
-rw-r--r--source/gameengine/Converter/BL_ShapeActionActuator.cpp55
-rw-r--r--source/gameengine/Converter/BL_ShapeActionActuator.h23
-rw-r--r--source/gameengine/Converter/BL_ShapeDeformer.cpp87
-rw-r--r--source/gameengine/Converter/BL_ShapeDeformer.h24
-rw-r--r--source/gameengine/Converter/BL_SkinDeformer.cpp167
-rw-r--r--source/gameengine/Converter/BL_SkinDeformer.h5
-rw-r--r--source/gameengine/Converter/CMakeLists.txt1
-rw-r--r--source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp6
-rw-r--r--source/gameengine/Converter/KX_BlenderScalarInterpolator.h2
-rw-r--r--source/gameengine/Converter/KX_BlenderSceneConverter.cpp10
-rw-r--r--source/gameengine/Converter/KX_BlenderSceneConverter.h4
-rw-r--r--source/gameengine/Converter/KX_ConvertActuators.cpp58
-rw-r--r--source/gameengine/Converter/KX_IpoConvert.cpp341
-rw-r--r--source/gameengine/Converter/KX_IpoConvert.h12
-rw-r--r--source/gameengine/Converter/SConscript1
22 files changed, 735 insertions, 717 deletions
diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp
index 7e353d590bb..50afac6992e 100644
--- a/source/gameengine/Converter/BL_ActionActuator.cpp
+++ b/source/gameengine/Converter/BL_ActionActuator.cpp
@@ -36,6 +36,7 @@
#include "BL_ActionActuator.h"
#include "BL_ArmatureObject.h"
#include "BL_SkinDeformer.h"
+#include "BL_Action.h"
#include "KX_GameObject.h"
#include "STR_HashedString.h"
#include "MEM_guardedalloc.h"
@@ -60,6 +61,49 @@ extern "C" {
#include "RNA_define.h"
}
+BL_ActionActuator::BL_ActionActuator(SCA_IObject* gameobj,
+ const STR_String& propname,
+ const STR_String& framepropname,
+ float starttime,
+ float endtime,
+ struct bAction *action,
+ short playtype,
+ short blendin,
+ short priority,
+ short layer,
+ float layer_weight,
+ short ipo_flags,
+ short end_reset,
+ float stride)
+ : SCA_IActuator(gameobj, KX_ACT_ACTION),
+
+ m_lastpos(0, 0, 0),
+ m_blendframe(0),
+ m_flag(0),
+ m_startframe (starttime),
+ m_endframe(endtime) ,
+ m_starttime(0),
+ m_localtime(starttime),
+ m_lastUpdate(-1),
+ m_blendin(blendin),
+ m_blendstart(0),
+ m_stridelength(stride),
+ m_playtype(playtype),
+ m_priority(priority),
+ m_layer(layer),
+ m_layer_weight(layer_weight),
+ m_ipo_flags(ipo_flags),
+ m_pose(NULL),
+ m_blendpose(NULL),
+ m_userpose(NULL),
+ m_action(action),
+ m_propname(propname),
+ m_framepropname(framepropname)
+{
+ if (!end_reset)
+ m_flag |= ACT_FLAG_CONTINUE;
+};
+
BL_ActionActuator::~BL_ActionActuator()
{
if (m_pose)
@@ -91,364 +135,153 @@ CValue* BL_ActionActuator::GetReplica() {
return replica;
}
-bool BL_ActionActuator::ClampLocalTime()
+bool BL_ActionActuator::Update(double curtime, bool frame)
{
- if (m_startframe < m_endframe)
+ bool bNegativeEvent = false;
+ bool bPositiveEvent = false;
+ bool bUseContinue = false;
+ KX_GameObject *obj = (KX_GameObject*)GetParent();
+ short playtype = BL_Action::ACT_MODE_PLAY;
+ float start = m_startframe;
+ float end = m_endframe;
+
+ // If we don't have an action, we can't do anything
+ if (!m_action)
+ return false;
+
+ // Convert our playtype to one that BL_Action likes
+ switch(m_playtype)
{
- 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))
- m_starttime = curtime - direction*(m_localtime - m_startframe)/KX_KetsjiEngine::GetAnimFrameRate();
- else
- m_starttime = curtime - direction*(m_endframe - m_localtime)/KX_KetsjiEngine::GetAnimFrameRate();
-}
-
-void BL_ActionActuator::SetLocalTime(float curtime)
-{
- float delta_time = (curtime - m_starttime)*KX_KetsjiEngine::GetAnimFrameRate();
-
- if (m_endframe < m_startframe)
- delta_time = -delta_time;
+ case ACT_ACTION_LOOP_END:
+ case ACT_ACTION_LOOP_STOP:
+ playtype = BL_Action::ACT_MODE_LOOP;
+ break;
+
+ case ACT_ACTION_PINGPONG:
+ // We handle ping pong ourselves to increase compabitility
+ // with files made prior to animation changes from GSoC 2011.
+ playtype = BL_Action::ACT_MODE_PLAY;
+
+ if (m_flag & ACT_FLAG_REVERSE)
+ {
+ m_localtime = start;
+ start = end;
+ end = m_localtime;
+ }
- if (!(m_flag & ACT_FLAG_REVERSE))
- m_localtime = m_startframe + delta_time;
- else
- m_localtime = m_endframe - delta_time;
-}
+ break;
+ case ACT_ACTION_FROM_PROP:
+ CValue* prop = GetParent()->GetProperty(m_propname);
+ playtype = BL_Action::ACT_MODE_PLAY;
+ start = end = prop->GetNumber();
-bool BL_ActionActuator::Update(double curtime, bool frame)
-{
- bool bNegativeEvent = false;
- bool bPositiveEvent = false;
- bool keepgoing = true;
- bool wrap = false;
- bool apply=true;
- int priority;
- float newweight;
+ break;
+ }
- curtime -= KX_KetsjiEngine::GetSuspendedDelta();
+ // Continue only really makes sense for play stop and flipper. All other modes go until they are complete.
+ if (m_flag & ACT_FLAG_CONTINUE &&
+ (m_playtype == ACT_ACTION_LOOP_STOP ||
+ m_playtype == ACT_ACTION_FLIPPER))
+ bUseContinue = true;
- // result = true if animation has to be continued, false if animation stops
- // maybe there are events for us in the queue !
+
+ // Handle events
if (frame)
{
bNegativeEvent = m_negevent;
bPositiveEvent = m_posevent;
RemoveAllEvents();
-
- if (bPositiveEvent)
- m_flag |= ACT_FLAG_ACTIVE;
-
- if (bNegativeEvent)
- {
- // dont continue where we left off when restarting
- if (m_end_reset) {
- m_flag &= ~ACT_FLAG_LOCKINPUT;
- }
-
- if (!(m_flag & ACT_FLAG_ACTIVE))
- return false;
- m_flag &= ~ACT_FLAG_ACTIVE;
- }
- }
-
- /* 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();
- float length = m_endframe - m_startframe;
-
- 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;
- m_localtime = m_startframe;
- m_starttime = curtime;
- }
- }
- 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;
- m_flag &= ~ACT_FLAG_KEYUP;
- m_flag |= ACT_FLAG_LOCKINPUT;
- SetStartTime(curtime);
- }
- }
- if (bNegativeEvent){
- m_flag |= ACT_FLAG_KEYUP;
- m_flag &= ~ACT_FLAG_LOCKINPUT;
- keepgoing=false;
- apply=false;
- }
- break;
- case ACT_ACTION_PINGPONG:
- if (bPositiveEvent){
- if (!(m_flag & ACT_FLAG_LOCKINPUT)){
- m_flag &= ~ACT_FLAG_KEYUP;
- m_localtime = m_starttime;
- m_starttime = curtime;
- m_flag |= ACT_FLAG_LOCKINPUT;
- }
- }
- break;
- case ACT_ACTION_FLIPPER:
- if (bPositiveEvent){
- if (!(m_flag & ACT_FLAG_LOCKINPUT)){
- m_flag &= ~ACT_FLAG_REVERSE;
- m_flag |= ACT_FLAG_LOCKINPUT;
- SetStartTime(curtime);
- }
- }
- else if (bNegativeEvent){
- m_flag |= ACT_FLAG_REVERSE;
- m_flag &= ~ACT_FLAG_LOCKINPUT;
- SetStartTime(curtime);
- }
- break;
- case ACT_ACTION_PLAY:
- if (bPositiveEvent){
- if (!(m_flag & ACT_FLAG_LOCKINPUT)){
- m_flag &= ~ACT_FLAG_REVERSE;
- m_localtime = m_starttime;
- m_starttime = curtime;
- 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{
- SetLocalTime(curtime);
- }
}
+
+ if (bUseContinue && (m_flag & ACT_FLAG_ACTIVE))
+ m_localtime = obj->GetActionFrame(m_layer);
- /* Check if a wrapping response is needed */
- if (length){
- if (m_localtime < m_startframe || m_localtime > m_endframe)
+ if (bPositiveEvent)
+ {
+ if (obj->PlayAction(m_action->id.name+2, start, end, m_layer, m_priority, m_blendin, playtype, m_layer_weight, m_ipo_flags))
{
- m_localtime = m_startframe + fmod(m_localtime, length);
- wrap = true;
+ m_flag |= ACT_FLAG_ACTIVE;
+ if (bUseContinue)
+ obj->SetActionFrame(m_layer, m_localtime);
+
+ if (m_playtype == ACT_ACTION_PLAY)
+ m_flag |= ACT_FLAG_PLAY_END;
+ else
+ m_flag &= ~ACT_FLAG_PLAY_END;
}
+ else
+ return false;
}
- else
- m_localtime = m_startframe;
-
- /* Perform post-increment tasks */
- switch (m_playtype){
- case ACT_ACTION_FROM_PROP:
+ else if ((m_flag & ACT_FLAG_ACTIVE) && bNegativeEvent)
+ {
+ bAction *curr_action = obj->GetCurrentAction(m_layer);
+ if (curr_action && curr_action != m_action)
{
- CValue* propval = GetParent()->GetProperty(m_propname);
- if (propval)
- m_localtime = propval->GetNumber();
-
- if (bNegativeEvent){
- keepgoing=false;
- }
- }
- break;
- case ACT_ACTION_MOTION:
- break;
- case ACT_ACTION_LOOP_STOP:
- break;
- case ACT_ACTION_PINGPONG:
- if (wrap){
- if (!(m_flag & ACT_FLAG_REVERSE))
- m_localtime = m_endframe;
- else
- m_localtime = m_startframe;
-
- m_flag &= ~ACT_FLAG_LOCKINPUT;
- m_flag ^= ACT_FLAG_REVERSE; //flip direction
- keepgoing = false;
- }
- break;
- case ACT_ACTION_FLIPPER:
- if (wrap){
- if (!(m_flag & ACT_FLAG_REVERSE)){
- m_localtime=m_endframe;
- //keepgoing = false;
- }
- else {
- m_localtime=m_startframe;
- keepgoing = false;
- }
- }
- break;
- case ACT_ACTION_LOOP_END:
- if (wrap){
- if (m_flag & ACT_FLAG_KEYUP){
- keepgoing = false;
- m_localtime = m_endframe;
- m_flag &= ~ACT_FLAG_LOCKINPUT;
- }
- SetStartTime(curtime);
+ // Someone changed the action on us, so we wont mess with it
+ // Hopefully there wont be too many problems with two actuators using
+ // the same action...
+ m_flag &= ~ACT_FLAG_ACTIVE;
+ return false;
}
- break;
- case ACT_ACTION_PLAY:
- if (wrap){
- m_localtime = m_endframe;
- keepgoing = false;
- m_flag &= ~ACT_FLAG_LOCKINPUT;
+
+
+ m_localtime = obj->GetActionFrame(m_layer);
+ if (m_localtime < min(m_startframe, m_endframe) || m_localtime > max(m_startframe, m_endframe))
+ m_localtime = m_startframe;
+
+ switch(m_playtype)
+ {
+ case ACT_ACTION_LOOP_STOP:
+ obj->StopAction(m_layer); // Stop the action after getting the frame
+
+ // We're done
+ m_flag &= ~ACT_FLAG_ACTIVE;
+ return false;
+ case ACT_ACTION_PINGPONG:
+ m_flag ^= ACT_FLAG_REVERSE;
+ // Now fallthrough to LOOP_END code
+ case ACT_ACTION_LOOP_END:
+ // Convert into a play and let it finish
+ obj->SetPlayMode(m_layer, BL_Action::ACT_MODE_PLAY);
+
+ m_flag |= ACT_FLAG_PLAY_END;
+ break;
+
+ case ACT_ACTION_FLIPPER:
+ // Convert into a play action and play back to the beginning
+ end = start;
+ start = obj->GetActionFrame(m_layer);
+ obj->PlayAction(m_action->id.name+2, start, end, m_layer, m_priority, 0, BL_Action::ACT_MODE_PLAY, m_layer_weight, m_ipo_flags);
+
+ m_flag |= ACT_FLAG_PLAY_END;
+ break;
}
- break;
- default:
- keepgoing = false;
- break;
}
-
- /* 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) {
+
+ // Handle a frame property if it's defined
+ if ((m_flag & ACT_FLAG_ACTIVE) && m_framepropname[0] != 0)
+ {
+ CValue* oldprop = obj->GetProperty(m_framepropname);
+ CValue* newval = new CFloatValue(obj->GetActionFrame(m_layer));
+ if (oldprop)
oldprop->SetValue(newval);
- } else {
- propowner->SetProperty(m_framepropname, newval);
- }
+ else
+ obj->SetProperty(m_framepropname, newval);
+
newval->Release();
}
-
- if (bNegativeEvent)
- 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);
-
-// 2.4x function,
- /* Override the necessary channels with ones from the action */
- // XXX extract_pose_from_action(m_pose, m_action, m_localtime);
-
-
-// 2.5x - replacement for extract_pose_from_action(...) above.
- {
- struct PointerRNA id_ptr;
- Object *arm= obj->GetArmatureObject();
- bPose *pose_back= arm->pose;
-
- arm->pose= m_pose;
- RNA_id_pointer_create((ID *)arm, &id_ptr);
- animsys_evaluate_action(&id_ptr, m_action, NULL, m_localtime);
-
- arm->pose= pose_back;
-
-// 2.5x - could also do this but looks too high level, constraints use this, it works ok.
-// Object workob; /* evaluate using workob */
-// what_does_obaction(obj->GetArmatureObject(), &workob, m_pose, m_action, NULL, m_localtime);
- }
- // done getting the pose from the action
-
- /* Perform the user override (if any) */
- if (m_userpose){
- extract_pose_from_pose(m_pose, m_userpose);
- game_free_pose(m_userpose); //cant use MEM_freeN(m_userpose) because the channels need freeing too.
- 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);
- m_blendstart = curtime;
- }
-
- /* Find percentages */
- newweight = (m_blendframe/(float)m_blendin);
- game_blend_poses(m_pose, m_blendpose, 1.0 - newweight);
-
- /* Increment current blending percentage */
- m_blendframe = (curtime - m_blendstart)*KX_KetsjiEngine::GetAnimFrameRate();
- 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;
+ // Handle a finished animation
+ if ((m_flag & ACT_FLAG_PLAY_END) && obj->IsActionDone(m_layer))
+ {
+ m_flag &= ~ACT_FLAG_ACTIVE;
+ obj->StopAction(m_layer);
+ return false;
}
- return keepgoing;
-};
+
+ return true;
+}
#ifdef WITH_PYTHON
@@ -633,10 +466,10 @@ PyAttributeDef BL_ActionActuator::Attributes[] = {
KX_PYATTRIBUTE_RW_FUNCTION("action", BL_ActionActuator, pyattr_get_action, pyattr_set_action),
KX_PYATTRIBUTE_RO_FUNCTION("channelNames", BL_ActionActuator, pyattr_get_channel_names),
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_RW_FUNCTION("frame", BL_ActionActuator, pyattr_get_frame, pyattr_set_frame),
KX_PYATTRIBUTE_STRING_RW("propName", 0, 31, false, BL_ActionActuator, m_propname),
KX_PYATTRIBUTE_STRING_RW("framePropName", 0, 31, false, BL_ActionActuator, m_framepropname),
- KX_PYATTRIBUTE_BOOL_RW("useContinue", BL_ActionActuator, m_end_reset),
+ KX_PYATTRIBUTE_RW_FUNCTION("useContinue", BL_ActionActuator, pyattr_get_use_continue, pyattr_set_use_continue),
KX_PYATTRIBUTE_FLOAT_RW_CHECK("blendTime", 0, MAXFRAMEF, BL_ActionActuator, m_blendframe, CheckBlendTime),
KX_PYATTRIBUTE_SHORT_RW_CHECK("mode",0,100,false,BL_ActionActuator,m_playtype,CheckType),
{ NULL } //Sentinel
@@ -696,4 +529,37 @@ PyObject* BL_ActionActuator::pyattr_get_channel_names(void *self_v, const KX_PYA
return ret;
}
+PyObject* BL_ActionActuator::pyattr_get_use_continue(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v);
+ return PyBool_FromLong(self->m_flag & ACT_FLAG_CONTINUE);
+}
+
+int BL_ActionActuator::pyattr_set_use_continue(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
+{
+ BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v);
+
+ if (PyObject_IsTrue(value))
+ self->m_flag |= ACT_FLAG_CONTINUE;
+ else
+ self->m_flag &= ~ACT_FLAG_CONTINUE;
+
+ return PY_SET_ATTR_SUCCESS;
+}
+
+PyObject* BL_ActionActuator::pyattr_get_frame(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v);
+ return PyFloat_FromDouble(((KX_GameObject*)self->m_gameobj)->GetActionFrame(self->m_layer));
+}
+
+int BL_ActionActuator::pyattr_set_frame(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
+{
+ BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v);
+
+ ((KX_GameObject*)self->m_gameobj)->SetActionFrame(self->m_layer, PyFloat_AsDouble(value));
+
+ return PY_SET_ATTR_SUCCESS;
+}
+
#endif // WITH_PYTHON
diff --git a/source/gameengine/Converter/BL_ActionActuator.h b/source/gameengine/Converter/BL_ActionActuator.h
index ff4ca785a96..5324cb10885 100644
--- a/source/gameengine/Converter/BL_ActionActuator.h
+++ b/source/gameengine/Converter/BL_ActionActuator.h
@@ -52,32 +52,12 @@ public:
short playtype,
short blendin,
short priority,
+ short layer,
+ float layer_weight,
+ short ipo_flags,
short end_reset,
- float stride)
- : SCA_IActuator(gameobj, KX_ACT_ACTION),
-
- m_lastpos(0, 0, 0),
- m_blendframe(0),
- m_flag(0),
- m_startframe (starttime),
- m_endframe(endtime) ,
- m_starttime(0),
- m_localtime(starttime),
- m_lastUpdate(-1),
- m_blendin(blendin),
- m_blendstart(0),
- m_stridelength(stride),
- m_playtype(playtype),
- m_priority(priority),
- m_end_reset(end_reset),
- m_pose(NULL),
- m_blendpose(NULL),
- m_userpose(NULL),
- m_action(action),
- m_propname(propname),
- m_framepropname(framepropname)
- {
- };
+ float stride);
+
virtual ~BL_ActionActuator();
virtual bool Update(double curtime, bool frame);
virtual CValue* GetReplica();
@@ -96,18 +76,10 @@ public:
static PyObject* pyattr_get_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static int pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
static PyObject* pyattr_get_channel_names(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- /* attribute check */
- static int CheckFrame(void *self, const PyAttributeDef*)
- {
- BL_ActionActuator* act = reinterpret_cast<BL_ActionActuator*>(self);
-
- if (act->m_localtime < act->m_startframe)
- act->m_localtime = act->m_startframe;
- else if (act->m_localtime > act->m_endframe)
- act->m_localtime = act->m_endframe;
-
- return 0;
- }
+ static PyObject* pyattr_get_use_continue(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static int pyattr_set_use_continue(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
+ static PyObject* pyattr_get_frame(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static int pyattr_set_frame(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
static int CheckBlendTime(void *self, const PyAttributeDef*)
{
@@ -139,11 +111,6 @@ public:
#endif // WITH_PYTHON
protected:
-
- void SetStartTime(float curtime);
- void SetLocalTime(float curtime);
- bool ClampLocalTime();
-
MT_Point3 m_lastpos;
float m_blendframe;
int m_flag;
@@ -160,9 +127,11 @@ protected:
float m_blendin;
float m_blendstart;
float m_stridelength;
+ float m_layer_weight;
short m_playtype;
short m_priority;
- bool m_end_reset;
+ short m_layer;
+ short m_ipo_flags;
struct bPose* m_pose;
struct bPose* m_blendpose;
struct bPose* m_userpose;
@@ -171,11 +140,17 @@ protected:
STR_String m_framepropname;
};
+// Not all of these values are used in BL_ActionActuator anymore,
+// but BL_ShapeActionActuator still uses them, so we keep them around
+// for now.
enum {
- ACT_FLAG_REVERSE = 0x00000001,
- ACT_FLAG_LOCKINPUT = 0x00000002,
- ACT_FLAG_KEYUP = 0x00000004,
- ACT_FLAG_ACTIVE = 0x00000008
+ ACT_FLAG_REVERSE = 1<<0,
+ ACT_FLAG_LOCKINPUT = 1<<1,
+ ACT_FLAG_KEYUP = 1<<2,
+ ACT_FLAG_ACTIVE = 1<<3,
+ ACT_FLAG_CONTINUE = 1<<4,
+ ACT_FLAG_PLAY_END = 1<<5,
+
};
#endif
diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp
index c6c20a96482..395cae4ba87 100644
--- a/source/gameengine/Converter/BL_ArmatureObject.cpp
+++ b/source/gameengine/Converter/BL_ArmatureObject.cpp
@@ -218,7 +218,8 @@ BL_ArmatureObject::BL_ArmatureObject(
void* sgReplicationInfo,
SG_Callbacks callbacks,
Object *armature,
- Scene *scene)
+ Scene *scene,
+ int vert_deform_type)
: KX_GameObject(sgReplicationInfo,callbacks),
m_controlledConstraints(),
@@ -232,7 +233,8 @@ BL_ArmatureObject::BL_ArmatureObject(
m_activePriority(999),
m_constraintNumber(0),
m_channelNumber(0),
- m_lastapplyframe(0.0)
+ m_lastapplyframe(0.0),
+ m_vert_deform_type(vert_deform_type)
{
m_armature = (bArmature *)armature->data;
@@ -298,6 +300,7 @@ void BL_ArmatureObject::LoadConstraints(KX_BlenderSceneConverter* converter)
case CONSTRAINT_TYPE_CLAMPTO:
case CONSTRAINT_TYPE_TRANSFORM:
case CONSTRAINT_TYPE_DISTLIMIT:
+ case CONSTRAINT_TYPE_TRANSLIKE:
cti = constraint_get_typeinfo(pcon);
gametarget = gamesubtarget = NULL;
if (cti && cti->get_constraint_targets) {
diff --git a/source/gameengine/Converter/BL_ArmatureObject.h b/source/gameengine/Converter/BL_ArmatureObject.h
index 2c3ca7404b3..1467f05c1bd 100644
--- a/source/gameengine/Converter/BL_ArmatureObject.h
+++ b/source/gameengine/Converter/BL_ArmatureObject.h
@@ -69,7 +69,8 @@ public:
void* sgReplicationInfo,
SG_Callbacks callbacks,
Object *armature,
- Scene *scene
+ Scene *scene,
+ int vert_deform_type
);
virtual ~BL_ArmatureObject();
@@ -90,6 +91,8 @@ public:
Object* GetArmatureObject() {return m_objArma;}
+ int GetVertDeformType() {return m_vert_deform_type;}
+
// for constraint python API
void LoadConstraints(KX_BlenderSceneConverter* converter);
size_t GetConstraintNumber() const { return m_constraintNumber; }
@@ -136,6 +139,7 @@ protected:
double m_timestep; // delta since last pose evaluation.
class BL_ActionActuator *m_activeAct;
short m_activePriority;
+ int m_vert_deform_type;
size_t m_constraintNumber;
size_t m_channelNumber;
// store the original armature object matrix
diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
index 35c319e263b..4daed538b39 100644
--- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp
+++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
@@ -1684,8 +1684,6 @@ static KX_LightObject *gamelight_from_blamp(Object *ob, Lamp *la, unsigned int l
gamelight = new KX_LightObject(kxscene, KX_Scene::m_callbacks, rendertools,
lightobj, glslmat);
-
- BL_ConvertLampIpos(la, gamelight, converter);
return gamelight;
}
@@ -1698,8 +1696,6 @@ static KX_Camera *gamecamera_from_bcamera(Object *ob, KX_Scene *kxscene, KX_Blen
gamecamera= new KX_Camera(kxscene, KX_Scene::m_callbacks, camdata);
gamecamera->SetName(ca->id.name + 2);
- BL_ConvertCameraIpos(ca, gamecamera, converter);
-
return gamecamera;
}
@@ -1809,11 +1805,13 @@ static KX_GameObject *gameobject_from_blenderobject(
case OB_ARMATURE:
{
+ bArmature *arm = (bArmature*)ob->data;
gameobj = new BL_ArmatureObject(
kxscene,
KX_Scene::m_callbacks,
ob,
- kxscene->GetBlenderScene() // handle
+ kxscene->GetBlenderScene(), // handle
+ arm->gevertdeformer
);
/* Get the current pose from the armature object and apply it as the rest pose */
break;
@@ -2092,8 +2090,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
gameobj->NodeSetLocalOrientation(MT_Matrix3x3(eulxyz));
gameobj->NodeSetLocalScale(scale);
gameobj->NodeUpdateGS(0);
-
- BL_ConvertIpos(blenderobject,gameobj,converter);
+
BL_ConvertMaterialIpos(blenderobject, gameobj, converter);
sumolist->Add(gameobj->AddRef());
@@ -2282,8 +2279,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
gameobj->NodeSetLocalOrientation(MT_Matrix3x3(eulxyz));
gameobj->NodeSetLocalScale(scale);
gameobj->NodeUpdateGS(0);
-
- BL_ConvertIpos(blenderobject,gameobj,converter);
+
BL_ConvertMaterialIpos(blenderobject,gameobj, converter);
sumolist->Add(gameobj->AddRef());
diff --git a/source/gameengine/Converter/BL_DeformableGameObject.cpp b/source/gameengine/Converter/BL_DeformableGameObject.cpp
index bfba054d0d4..48392ee8dda 100644
--- a/source/gameengine/Converter/BL_DeformableGameObject.cpp
+++ b/source/gameengine/Converter/BL_DeformableGameObject.cpp
@@ -87,15 +87,16 @@ bool BL_DeformableGameObject::SetActiveAction(BL_ShapeActionActuator *act, short
bool BL_DeformableGameObject::GetShape(vector<float> &shape)
{
shape.clear();
- if (m_pDeformer)
+ BL_ShapeDeformer* shape_deformer = dynamic_cast<BL_ShapeDeformer*>(m_pDeformer);
+ if (shape_deformer)
{
- Mesh* mesh = ((BL_MeshDeformer*)m_pDeformer)->GetMesh();
// this check is normally superfluous: a shape deformer can only be created if the mesh
// has relative keys
- if (mesh && mesh->key && mesh->key->type==KEY_RELATIVE)
+ Key* key = shape_deformer->GetKey();
+ if (key && key->type==KEY_RELATIVE)
{
KeyBlock *kb;
- for (kb = (KeyBlock*)mesh->key->block.first; kb; kb = (KeyBlock*)kb->next)
+ for (kb = (KeyBlock*)key->block.first; kb; kb = (KeyBlock*)kb->next)
{
shape.push_back(kb->curval);
}
diff --git a/source/gameengine/Converter/BL_DeformableGameObject.h b/source/gameengine/Converter/BL_DeformableGameObject.h
index 615bb84ac2b..3ba55664007 100644
--- a/source/gameengine/Converter/BL_DeformableGameObject.h
+++ b/source/gameengine/Converter/BL_DeformableGameObject.h
@@ -82,23 +82,6 @@ public:
bool SetActiveAction(class BL_ShapeActionActuator *act, short priority, double curtime);
bool GetShape(vector<float> &shape);
- Key* GetKey()
- {
- if(m_pDeformer) {
- BL_MeshDeformer *deformer= dynamic_cast<BL_MeshDeformer *>(m_pDeformer); // incase its not a MeshDeformer
- if(deformer) {
- return deformer->GetMesh()->key;
- }
-
-#if 0 // TODO. shape keys for softbody, currently they dont store a mesh.
- KX_SoftBodyDeformer *deformer_soft= dynamic_cast<KX_SoftBodyDeformer *>(m_pDeformer);
- if(deformer) {
- return deformer->GetMesh()->key;
- }
-#endif
- }
- return NULL;
- }
virtual void SetDeformer(class RAS_Deformer* deformer);
virtual class RAS_Deformer* GetDeformer()
diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.cpp b/source/gameengine/Converter/BL_ShapeActionActuator.cpp
index bb53c2d6fe6..ac377cdb7ca 100644
--- a/source/gameengine/Converter/BL_ShapeActionActuator.cpp
+++ b/source/gameengine/Converter/BL_ShapeActionActuator.cpp
@@ -59,10 +59,49 @@
extern "C" {
#include "BKE_animsys.h"
+ #include "BKE_key.h"
+ #include "RNA_access.h"
}
+BL_ShapeActionActuator::BL_ShapeActionActuator(SCA_IObject* gameobj,
+ const STR_String& propname,
+ const STR_String& framepropname,
+ float starttime,
+ float endtime,
+ struct bAction *action,
+ short playtype,
+ short blendin,
+ short priority,
+ float stride)
+ : SCA_IActuator(gameobj, KX_ACT_SHAPEACTION),
+
+ m_lastpos(0, 0, 0),
+ m_blendframe(0),
+ m_flag(0),
+ m_startframe (starttime),
+ m_endframe(endtime) ,
+ m_starttime(0),
+ m_localtime(starttime),
+ m_lastUpdate(-1),
+ m_blendin(blendin),
+ m_blendstart(0),
+ m_stridelength(stride),
+ m_playtype(playtype),
+ m_priority(priority),
+ m_action(action),
+ m_framepropname(framepropname),
+ m_propname(propname)
+{
+ m_idptr = new PointerRNA();
+ BL_DeformableGameObject *obj = (BL_DeformableGameObject*)GetParent();
+ BL_ShapeDeformer *shape_deformer = dynamic_cast<BL_ShapeDeformer*>(obj->GetDeformer());
+ RNA_id_pointer_create(&shape_deformer->GetKey()->id, m_idptr);
+};
+
BL_ShapeActionActuator::~BL_ShapeActionActuator()
{
+ if (m_idptr)
+ delete m_idptr;
}
void BL_ShapeActionActuator::ProcessReplica()
@@ -382,7 +421,11 @@ bool BL_ShapeActionActuator::Update(double curtime, bool frame)
/* Priority test */
if (obj->SetActiveAction(this, priority, curtime)){
- Key *key = obj->GetKey();
+ BL_ShapeDeformer *shape_deformer = dynamic_cast<BL_ShapeDeformer*>(obj->GetDeformer());
+ Key *key = NULL;
+
+ if (shape_deformer)
+ key = shape_deformer->GetKey();
if (!key) {
// this could happen if the mesh was changed in the middle of an action
@@ -397,10 +440,14 @@ bool BL_ShapeActionActuator::Update(double curtime, bool frame)
obj->GetShape(m_blendshape);
m_blendstart = curtime;
}
- // only interested in shape channel
- // in 2.4x was // extract_ipochannels_from_action(&tchanbase, &key->id, m_action, "Shape", m_localtime);
- BKE_animsys_evaluate_animdata(&key->id, key->adt, m_localtime, ADT_RECALC_ANIM);
+ KeyBlock *kb;
+ // We go through and clear out the keyblocks so there isn't any interference
+ // from other shape actions
+ for (kb=(KeyBlock*)key->block.first; kb; kb=(KeyBlock*)kb->next)
+ kb->curval = 0.f;
+
+ animsys_evaluate_action(m_idptr, m_action, NULL, m_localtime);
// XXX - in 2.5 theres no way to do this. possibly not that important to support - Campbell
if (0) { // XXX !execute_ipochannels(&tchanbase)) {
diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.h b/source/gameengine/Converter/BL_ShapeActionActuator.h
index 7a4523d4554..efd24fc305f 100644
--- a/source/gameengine/Converter/BL_ShapeActionActuator.h
+++ b/source/gameengine/Converter/BL_ShapeActionActuator.h
@@ -54,27 +54,7 @@ public:
short playtype,
short blendin,
short priority,
- float stride)
- : SCA_IActuator(gameobj, KX_ACT_SHAPEACTION),
-
- m_lastpos(0, 0, 0),
- m_blendframe(0),
- m_flag(0),
- m_startframe (starttime),
- m_endframe(endtime) ,
- m_starttime(0),
- m_localtime(starttime),
- m_lastUpdate(-1),
- m_blendin(blendin),
- m_blendstart(0),
- m_stridelength(stride),
- m_playtype(playtype),
- m_priority(priority),
- m_action(action),
- m_framepropname(framepropname),
- m_propname(propname)
- {
- };
+ float stride);
virtual ~BL_ShapeActionActuator();
virtual bool Update(double curtime, bool frame);
virtual CValue* GetReplica();
@@ -160,6 +140,7 @@ protected:
STR_String m_framepropname;
STR_String m_propname;
vector<float> m_blendshape;
+ struct PointerRNA *m_idptr;
};
#endif
diff --git a/source/gameengine/Converter/BL_ShapeDeformer.cpp b/source/gameengine/Converter/BL_ShapeDeformer.cpp
index 8d8f149bb6c..befe0f6e784 100644
--- a/source/gameengine/Converter/BL_ShapeDeformer.cpp
+++ b/source/gameengine/Converter/BL_ShapeDeformer.cpp
@@ -44,13 +44,12 @@
#include "RAS_MeshObject.h"
//#include "BL_ArmatureController.h"
+#include "DNA_anim_types.h"
#include "DNA_armature_types.h"
#include "DNA_action_types.h"
#include "DNA_key_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
-#include "DNA_ipo_types.h"
-#include "DNA_curve_types.h"
#include "BKE_armature.h"
#include "BKE_action.h"
#include "BKE_key.h"
@@ -59,6 +58,7 @@
extern "C"{
#include "BKE_lattice.h"
+ #include "BKE_animsys.h"
}
@@ -68,9 +68,42 @@ extern "C"{
#define __NLA_DEFNORMALS
//#undef __NLA_DEFNORMALS
+BL_ShapeDeformer::BL_ShapeDeformer(BL_DeformableGameObject *gameobj,
+ Object *bmeshobj,
+ RAS_MeshObject *mesh)
+ :
+ BL_SkinDeformer(gameobj,bmeshobj, mesh),
+ m_useShapeDrivers(false),
+ m_lastShapeUpdate(-1)
+{
+ m_key = m_bmesh->key;
+ m_bmesh->key = copy_key(m_key);
+};
+
+/* this second constructor is needed for making a mesh deformable on the fly. */
+BL_ShapeDeformer::BL_ShapeDeformer(BL_DeformableGameObject *gameobj,
+ Object *bmeshobj_old,
+ Object *bmeshobj_new,
+ RAS_MeshObject *mesh,
+ bool release_object,
+ bool recalc_normal,
+ BL_ArmatureObject* arma)
+ :
+ BL_SkinDeformer(gameobj, bmeshobj_old, bmeshobj_new, mesh, release_object, recalc_normal, arma),
+ m_useShapeDrivers(false),
+ m_lastShapeUpdate(-1)
+{
+ m_key = m_bmesh->key;
+ m_bmesh->key = copy_key(m_key);
+};
BL_ShapeDeformer::~BL_ShapeDeformer()
{
+ if (m_key && m_bmesh->key)
+ {
+ free_key(m_bmesh->key);
+ m_bmesh->key = m_key;
+ }
};
RAS_Deformer *BL_ShapeDeformer::GetReplica()
@@ -90,45 +123,23 @@ void BL_ShapeDeformer::ProcessReplica()
bool BL_ShapeDeformer::LoadShapeDrivers(Object* arma)
{
- IpoCurve *icu;
-
- m_shapeDrivers.clear();
- // check if this mesh has armature driven shape keys
- if (m_bmesh->key && m_bmesh->key->ipo) {
- for(icu= (IpoCurve*)m_bmesh->key->ipo->curve.first; icu; icu= (IpoCurve*)icu->next) {
- if(icu->driver &&
- (icu->flag & IPO_MUTE) == 0 &&
- icu->driver->type == IPO_DRIVER_TYPE_NORMAL &&
- icu->driver->ob == arma &&
- icu->driver->blocktype == ID_AR) {
- // this shape key ipo curve has a driver on the parent armature
- // record this curve in the shape deformer so that the corresponding
- m_shapeDrivers.push_back(icu);
- }
- }
- }
- return !m_shapeDrivers.empty();
+ // This used to check if we had drivers from this armature,
+ // now we just assume we want to use shape drivers
+ // and let the animsys handle things.
+ m_useShapeDrivers = true;
+
+ return true;
}
bool BL_ShapeDeformer::ExecuteShapeDrivers(void)
{
- if (!m_shapeDrivers.empty() && PoseUpdated()) {
- vector<IpoCurve*>::iterator it;
-// void *poin;
-// int type;
-
+ if (m_useShapeDrivers && PoseUpdated()) {
// the shape drivers use the bone matrix as input. Must
// update the matrix now
m_armobj->ApplyPose();
- for (it=m_shapeDrivers.begin(); it!=m_shapeDrivers.end(); it++) {
- // no need to set a specific time: this curve has a driver
- // XXX IpoCurve *icu = *it;
- //calc_icu(icu, 1.0f);
- //poin = get_ipo_poin((ID*)m_bmesh->key, icu, &type);
- //if (poin)
- // write_ipo_poin(poin, type, icu->curval);
- }
+ // We don't need an actual time, just use 0
+ BKE_animsys_evaluate_animdata(NULL, &GetKey()->id, GetKey()->adt, 0.f, ADT_RECALC_DRIVERS);
ForceUpdate();
m_armobj->RestorePose();
@@ -190,3 +201,13 @@ bool BL_ShapeDeformer::Update(void)
}
return bSkinUpdate;
}
+
+Key *BL_ShapeDeformer::GetKey()
+{
+ return m_bmesh->key;
+}
+
+void BL_ShapeDeformer::SetKey(Key *key)
+{
+ m_bmesh->key = key;
+}
diff --git a/source/gameengine/Converter/BL_ShapeDeformer.h b/source/gameengine/Converter/BL_ShapeDeformer.h
index 8115af59d27..655cc9d7aeb 100644
--- a/source/gameengine/Converter/BL_ShapeDeformer.h
+++ b/source/gameengine/Converter/BL_ShapeDeformer.h
@@ -42,19 +42,12 @@
#include "BL_DeformableGameObject.h"
#include <vector>
-struct IpoCurve;
-
class BL_ShapeDeformer : public BL_SkinDeformer
{
public:
BL_ShapeDeformer(BL_DeformableGameObject *gameobj,
Object *bmeshobj,
- RAS_MeshObject *mesh)
- :
- BL_SkinDeformer(gameobj,bmeshobj, mesh),
- m_lastShapeUpdate(-1)
- {
- };
+ RAS_MeshObject *mesh);
/* this second constructor is needed for making a mesh deformable on the fly. */
BL_ShapeDeformer(BL_DeformableGameObject *gameobj,
@@ -63,12 +56,7 @@ public:
class RAS_MeshObject *mesh,
bool release_object,
bool recalc_normal,
- BL_ArmatureObject* arma = NULL)
- :
- BL_SkinDeformer(gameobj, bmeshobj_old, bmeshobj_new, mesh, release_object, recalc_normal, arma),
- m_lastShapeUpdate(-1)
- {
- };
+ BL_ArmatureObject* arma = NULL);
virtual RAS_Deformer *GetReplica();
virtual void ProcessReplica();
@@ -78,14 +66,18 @@ public:
bool LoadShapeDrivers(Object* arma);
bool ExecuteShapeDrivers(void);
+ struct Key *GetKey();
+ void SetKey(struct Key *key);
+
void ForceUpdate()
{
m_lastShapeUpdate = -1.0;
};
protected:
- vector<IpoCurve*> m_shapeDrivers;
- double m_lastShapeUpdate;
+ bool m_useShapeDrivers;
+ double m_lastShapeUpdate;
+ struct Key* m_key;
#ifdef WITH_CXX_GUARDEDALLOC
diff --git a/source/gameengine/Converter/BL_SkinDeformer.cpp b/source/gameengine/Converter/BL_SkinDeformer.cpp
index 34f9cb56c27..3a379e8b0ed 100644
--- a/source/gameengine/Converter/BL_SkinDeformer.cpp
+++ b/source/gameengine/Converter/BL_SkinDeformer.cpp
@@ -36,6 +36,10 @@
#pragma warning (disable : 4786)
#endif //WIN32
+// Eigen2 stuff used for BGEDeformVerts
+#include <Eigen/Core>
+#include <Eigen/LU>
+
#include "BL_SkinDeformer.h"
#include "CTR_Map.h"
#include "STR_HashedString.h"
@@ -54,6 +58,7 @@
extern "C"{
#include "BKE_lattice.h"
+ #include "BKE_deform.h"
}
@@ -74,7 +79,9 @@ BL_SkinDeformer::BL_SkinDeformer(BL_DeformableGameObject *gameobj,
//m_defbase(&bmeshobj->defbase),
m_releaseobject(false),
m_poseApplied(false),
- m_recalcNormal(true)
+ m_recalcNormal(true),
+ m_copyNormals(false),
+ m_dfnrToPC(NULL)
{
copy_m4_m4(m_obmat, bmeshobj->obmat);
};
@@ -92,7 +99,9 @@ BL_SkinDeformer::BL_SkinDeformer(
m_lastArmaUpdate(-1),
//m_defbase(&bmeshobj_old->defbase),
m_releaseobject(release_object),
- m_recalcNormal(recalc_normal)
+ m_recalcNormal(recalc_normal),
+ m_copyNormals(false),
+ m_dfnrToPC(NULL)
{
// this is needed to ensure correct deformation of mesh:
// the deformation is done with Blender's armature_deform_verts() function
@@ -106,6 +115,8 @@ BL_SkinDeformer::~BL_SkinDeformer()
{
if(m_releaseobject && m_armobj)
m_armobj->Release();
+ if(m_dfnrToPC)
+ delete [] m_dfnrToPC;
}
void BL_SkinDeformer::Relink(CTR_Map<class CTR_HashedPtr, void*>*map)
@@ -152,9 +163,14 @@ bool BL_SkinDeformer::Apply(RAS_IPolyMaterial *mat)
for(i=it.startvertex; i<it.endvertex; i++) {
RAS_TexVert& v = it.vertex[i];
v.SetXYZ(m_transverts[v.getOrigIndex()]);
+ if (m_copyNormals)
+ v.SetNormal(m_transnors[v.getOrigIndex()]);
}
}
}
+
+ if (m_copyNormals)
+ m_copyNormals = false;
}
return true;
}
@@ -174,19 +190,126 @@ void BL_SkinDeformer::ProcessReplica()
BL_MeshDeformer::ProcessReplica();
m_lastArmaUpdate = -1;
m_releaseobject = false;
+ m_dfnrToPC = NULL;
+}
+
+void BL_SkinDeformer::BlenderDeformVerts()
+{
+ float obmat[4][4]; // the original object matrix
+ Object* par_arma = m_armobj->GetArmatureObject();
+
+ // save matrix first
+ copy_m4_m4(obmat, m_objMesh->obmat);
+ // set reference matrix
+ copy_m4_m4(m_objMesh->obmat, m_obmat);
+
+ armature_deform_verts( par_arma, m_objMesh, NULL, m_transverts, NULL, m_bmesh->totvert, ARM_DEF_VGROUP, NULL, NULL );
+
+ // restore matrix
+ copy_m4_m4(m_objMesh->obmat, obmat);
+
+#ifdef __NLA_DEFNORMALS
+ if (m_recalcNormal)
+ RecalcNormals();
+#endif
+}
+
+void BL_SkinDeformer::BGEDeformVerts()
+{
+ Object *par_arma = m_armobj->GetArmatureObject();
+ MDeformVert *dverts = m_bmesh->dvert;
+ bDeformGroup *dg;
+ int numGroups = BLI_countlist(&m_objMesh->defbase);
+
+ if (!dverts)
+ return;
+
+ if (m_dfnrToPC == NULL)
+ {
+ m_dfnrToPC = new bPoseChannel*[numGroups];
+ int i;
+ for (i=0, dg=(bDeformGroup*)m_objMesh->defbase.first;
+ dg;
+ ++i, dg=(bDeformGroup*)dg->next)
+ {
+ m_dfnrToPC[i] = get_pose_channel(par_arma->pose, dg->name);
+
+ if (m_dfnrToPC[i] && m_dfnrToPC[i]->bone->flag & BONE_NO_DEFORM)
+ m_dfnrToPC[i] = NULL;
+ }
+ }
+
+
+ for (int i=0; i<m_bmesh->totvert; ++i)
+ {
+ float contrib = 0.f, weight, max_weight=0.f;
+ Bone *bone;
+ bPoseChannel *pchan=NULL;
+ MDeformVert *dvert;
+ Eigen::Map<Eigen::Vector3f> norm(m_transnors[i]);
+ Eigen::Vector4f vec(0, 0, 0, 1);
+ Eigen::Matrix4f norm_chan_mat;
+ Eigen::Vector4f co(m_transverts[i][0],
+ m_transverts[i][1],
+ m_transverts[i][2],
+ 1.f);
+
+ dvert = dverts+i;
+
+ if (!dvert->totweight)
+ continue;
+
+ for (int j=0; j<dvert->totweight; ++j)
+ {
+ int index = dvert->dw[j].def_nr;
+
+ if (index < numGroups && (pchan=m_dfnrToPC[index]))
+ {
+ weight = dvert->dw[j].weight;
+ bone = pchan->bone;
+
+ if (weight)
+ {
+ Eigen::Vector4f cop(co);
+ Eigen::Matrix4f chan_mat = Eigen::Matrix4f::Map((float*)pchan->chan_mat);
+
+ // Update Vertex Position
+ cop = chan_mat*cop;
+ vec += (cop - co)*weight;
+
+ // Save the most influential channel so we can use it to update the vertex normal
+ if (weight > max_weight)
+ {
+ max_weight = weight;
+ norm_chan_mat = chan_mat;
+ }
+
+ contrib += weight;
+ }
+ }
+ }
+
+
+ // Update Vertex Normal
+ norm = norm_chan_mat.corner<3, 3>(Eigen::TopLeft)*norm;
+
+ if (contrib > 0.0001f)
+ {
+ vec *= 1.f/contrib;
+ co += vec;
+ }
+
+ m_transverts[i][0] = co[0];
+ m_transverts[i][1] = co[1];
+ m_transverts[i][2] = co[2];
+ }
+ m_copyNormals = true;
}
-//void where_is_pose (Object *ob);
-//void armature_deform_verts(Object *armOb, Object *target, float (*vertexCos)[3], int numVerts, int deformflag);
bool BL_SkinDeformer::UpdateInternal(bool shape_applied)
{
/* See if the armature has been updated for this frame */
if (PoseUpdated()){
- float obmat[4][4]; // the original object matrice
-
- /* XXX note: where_is_pose() (from BKE_armature.h) calculates all matrices needed to start deforming */
- /* but it requires the blender object pointer... */
- Object* par_arma = m_armobj->GetArmatureObject();
if(!shape_applied) {
/* store verts locally */
@@ -194,25 +317,23 @@ bool BL_SkinDeformer::UpdateInternal(bool shape_applied)
/* duplicate */
for (int v =0; v<m_bmesh->totvert; v++)
+ {
VECCOPY(m_transverts[v], m_bmesh->mvert[v].co);
+ VECCOPY(m_transnors[v], m_bmesh->mvert[v].no);
+ }
}
m_armobj->ApplyPose();
- // save matrix first
- copy_m4_m4(obmat, m_objMesh->obmat);
- // set reference matrix
- copy_m4_m4(m_objMesh->obmat, m_obmat);
-
- armature_deform_verts( par_arma, m_objMesh, NULL, m_transverts, NULL, m_bmesh->totvert, ARM_DEF_VGROUP, NULL, NULL );
-
- // restore matrix
- copy_m4_m4(m_objMesh->obmat, obmat);
-
-#ifdef __NLA_DEFNORMALS
- if (m_recalcNormal)
- RecalcNormals();
-#endif
+ switch (m_armobj->GetVertDeformType())
+ {
+ case ARM_VDEF_BGE_CPU:
+ BGEDeformVerts();
+ break;
+ case ARM_VDEF_BLENDER:
+ default:
+ BlenderDeformVerts();
+ }
/* Update the current frame */
m_lastArmaUpdate=m_armobj->GetLastFrame();
diff --git a/source/gameengine/Converter/BL_SkinDeformer.h b/source/gameengine/Converter/BL_SkinDeformer.h
index e53e21e946f..be974619281 100644
--- a/source/gameengine/Converter/BL_SkinDeformer.h
+++ b/source/gameengine/Converter/BL_SkinDeformer.h
@@ -109,6 +109,11 @@ protected:
bool m_releaseobject;
bool m_poseApplied;
bool m_recalcNormal;
+ bool m_copyNormals; // dirty flag so we know if Apply() needs to copy normal information (used for BGEDeformVerts())
+ struct bPoseChannel** m_dfnrToPC;
+
+ void BlenderDeformVerts();
+ void BGEDeformVerts();
#ifdef WITH_CXX_GUARDEDALLOC
diff --git a/source/gameengine/Converter/CMakeLists.txt b/source/gameengine/Converter/CMakeLists.txt
index 45a7701d404..3a217ce9d74 100644
--- a/source/gameengine/Converter/CMakeLists.txt
+++ b/source/gameengine/Converter/CMakeLists.txt
@@ -51,6 +51,7 @@ set(INC
../../blender/makesrna
../../blender/windowmanager
../../../extern/bullet2/src
+ ../../../extern/Eigen2
../../../intern/container
../../../intern/guardedalloc
../../../intern/moto/include
diff --git a/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp b/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp
index a9a3e66f996..75c0e012226 100644
--- a/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp
+++ b/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp
@@ -47,11 +47,11 @@ float BL_ScalarInterpolator::GetValue(float currentTime) const {
return evaluate_fcurve(m_fcu, currentTime);
}
-BL_InterpolatorList::BL_InterpolatorList(struct AnimData *adt) {
- if(adt->action==NULL)
+BL_InterpolatorList::BL_InterpolatorList(bAction *action) {
+ if(action==NULL)
return;
- for(FCurve *fcu= (FCurve *)adt->action->curves.first; fcu; fcu= (FCurve *)fcu->next) {
+ for(FCurve *fcu= (FCurve *)action->curves.first; fcu; fcu= (FCurve *)fcu->next) {
if(fcu->rna_path) {
BL_ScalarInterpolator *new_ipo = new BL_ScalarInterpolator(fcu);
//assert(new_ipo);
diff --git a/source/gameengine/Converter/KX_BlenderScalarInterpolator.h b/source/gameengine/Converter/KX_BlenderScalarInterpolator.h
index bd786bae969..cca66b3771c 100644
--- a/source/gameengine/Converter/KX_BlenderScalarInterpolator.h
+++ b/source/gameengine/Converter/KX_BlenderScalarInterpolator.h
@@ -66,7 +66,7 @@ public:
class BL_InterpolatorList : public std::vector<KX_IScalarInterpolator *> {
public:
- BL_InterpolatorList(struct AnimData *adt);
+ BL_InterpolatorList(struct bAction *action);
~BL_InterpolatorList();
KX_IScalarInterpolator *GetScalarInterpolator(const char *rna_path, int array_index);
diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
index dd21e7ef263..ffb9a8ce691 100644
--- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
+++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
@@ -566,18 +566,18 @@ void KX_BlenderSceneConverter::RegisterPolyMaterial(RAS_IPolyMaterial *polymat)
void KX_BlenderSceneConverter::RegisterInterpolatorList(
- BL_InterpolatorList *adtList,
- struct AnimData *for_adt)
+ BL_InterpolatorList *actList,
+ struct bAction *for_act)
{
- m_map_blender_to_gameAdtList.insert(CHashedPtr(for_adt), adtList);
+ m_map_blender_to_gameAdtList.insert(CHashedPtr(for_act), actList);
}
BL_InterpolatorList *KX_BlenderSceneConverter::FindInterpolatorList(
- struct AnimData *for_adt)
+ struct bAction *for_act)
{
- BL_InterpolatorList **listp = m_map_blender_to_gameAdtList[CHashedPtr(for_adt)];
+ BL_InterpolatorList **listp = m_map_blender_to_gameAdtList[CHashedPtr(for_act)];
return listp?*listp:NULL;
}
diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.h b/source/gameengine/Converter/KX_BlenderSceneConverter.h
index 2340e44d288..ba919eb9592 100644
--- a/source/gameengine/Converter/KX_BlenderSceneConverter.h
+++ b/source/gameengine/Converter/KX_BlenderSceneConverter.h
@@ -113,8 +113,8 @@ public:
void RegisterBlenderMaterial(BL_Material *mat);
- void RegisterInterpolatorList(BL_InterpolatorList *adtList, struct AnimData *for_adt);
- BL_InterpolatorList *FindInterpolatorList(struct AnimData *for_adt);
+ void RegisterInterpolatorList(BL_InterpolatorList *actList, struct bAction *for_act);
+ BL_InterpolatorList *FindInterpolatorList(struct bAction *for_act);
void RegisterGameActuator(SCA_IActuator *act, struct bActuator *for_actuator);
SCA_IActuator *FindGameActuator(struct bActuator *for_actuator);
diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp
index 51e0449a32e..7b9cba7770b 100644
--- a/source/gameengine/Converter/KX_ConvertActuators.cpp
+++ b/source/gameengine/Converter/KX_ConvertActuators.cpp
@@ -99,6 +99,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"
@@ -196,30 +197,37 @@ void BL_ConvertActuators(char* maggiename,
}
case ACT_ACTION:
{
- if (blenderobject->type==OB_ARMATURE){
- bActionActuator* actact = (bActionActuator*) bact->data;
- STR_String propname = (actact->name ? actact->name : "");
- STR_String propframe = (actact->frameProp ? actact->frameProp : "");
+ 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,
- propname,
- propframe,
- actact->sta,
- actact->end,
- actact->act,
- actact->type, // + 1, because Blender starts to count at zero,
- actact->blendin,
- actact->priority,
- actact->end_reset,
- actact->stridelength
- // Ketsji at 1, because zero is reserved for "NoDef"
- );
- baseact= tmpbaseact;
- break;
- }
- else
- printf ("Discarded action actuator from non-armature object [%s]\n", blenderobject->id.name+2);
+ BL_ActionActuator* tmpbaseact = new BL_ActionActuator(
+ gameobj,
+ propname,
+ propframe,
+ actact->sta,
+ actact->end,
+ actact->act,
+ actact->type, // + 1, because Blender starts to count at zero,
+ actact->blendin,
+ actact->priority,
+ actact->layer,
+ actact->layer_weight,
+ ipo_flags,
+ actact->end_reset,
+ actact->stridelength
+ // Ketsji at 1, because zero is reserved for "NoDef"
+ );
+ baseact= tmpbaseact;
+ break;
}
case ACT_SHAPEACTION:
{
@@ -380,7 +388,7 @@ void BL_ConvertActuators(char* maggiename,
{
bSound* sound = soundact->sound;
bool is3d = soundact->flag & ACT_SND_3D_SOUND ? true : false;
- AUD_Sound* snd_sound = NULL;
+ AUD_Reference<AUD_IFactory> snd_sound;
KX_3DSoundSettings settings;
settings.cone_inner_angle = soundact->sound3D.cone_inner_angle;
settings.cone_outer_angle = soundact->sound3D.cone_outer_angle;
@@ -398,7 +406,7 @@ void BL_ConvertActuators(char* maggiename,
"\" has no sound datablock." << std::endl;
}
else
- snd_sound = sound->playback_handle;
+ snd_sound = *reinterpret_cast<AUD_Reference<AUD_IFactory>*>(sound->playback_handle);
KX_SoundActuator* tmpsoundact =
new KX_SoundActuator(gameobj,
snd_sound,
diff --git a/source/gameengine/Converter/KX_IpoConvert.cpp b/source/gameengine/Converter/KX_IpoConvert.cpp
index 2ad56717e26..0ee99f5335b 100644
--- a/source/gameengine/Converter/KX_IpoConvert.cpp
+++ b/source/gameengine/Converter/KX_IpoConvert.cpp
@@ -54,6 +54,7 @@
#include "DNA_object_types.h"
#include "DNA_action_types.h"
+#include "DNA_anim_types.h"
#include "DNA_ipo_types.h"
#include "DNA_lamp_types.h"
#include "DNA_world_types.h"
@@ -72,226 +73,226 @@
#include "STR_HashedString.h"
-static BL_InterpolatorList *GetAdtList(struct AnimData *for_adt, KX_BlenderSceneConverter *converter) {
- BL_InterpolatorList *adtList= converter->FindInterpolatorList(for_adt);
+static BL_InterpolatorList *GetAdtList(struct bAction *for_act, KX_BlenderSceneConverter *converter) {
+ BL_InterpolatorList *adtList= converter->FindInterpolatorList(for_act);
if (!adtList) {
- adtList = new BL_InterpolatorList(for_adt);
- converter->RegisterInterpolatorList(adtList, for_adt);
+ adtList = new BL_InterpolatorList(for_act);
+ converter->RegisterInterpolatorList(adtList, for_act);
}
return adtList;
}
-void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_BlenderSceneConverter *converter)
+SG_Controller *BL_CreateIPO(struct bAction *action, KX_GameObject* gameobj, KX_BlenderSceneConverter *converter)
{
- if (blenderobject->adt) {
-
- KX_IpoSGController* ipocontr = new KX_IpoSGController();
- gameobj->GetSGNode()->AddSGController(ipocontr);
- ipocontr->SetObject(gameobj->GetSGNode());
-
- // For ipo_as_force, we need to know which SM object and Scene the
- // object associated with this ipo is in. Is this already known here?
- // I think not.... then it must be done later :(
-// ipocontr->SetSumoReference(gameobj->GetSumoScene(),
-// gameobj->GetSumoObject());
-
- ipocontr->SetGameObject(gameobj);
-
- ipocontr->GetIPOTransform().SetPosition(
- MT_Point3(
- blenderobject->loc[0]/*+blenderobject->dloc[0]*/,
- blenderobject->loc[1]/*+blenderobject->dloc[1]*/,
- blenderobject->loc[2]/*+blenderobject->dloc[2]*/
- )
- );
- ipocontr->GetIPOTransform().SetEulerAngles(
- MT_Vector3(
- blenderobject->rot[0],
- blenderobject->rot[1],
- blenderobject->rot[2]
- )
- );
- ipocontr->GetIPOTransform().SetScaling(
- MT_Vector3(
- blenderobject->size[0],
- blenderobject->size[1],
- blenderobject->size[2]
- )
- );
-
- const char *rotmode, *drotmode;
-
- switch(blenderobject->rotmode)
- {
- case ROT_MODE_AXISANGLE:
- rotmode = "rotation_axis_angle";
- drotmode = "delta_rotation_axis_angle";
- case ROT_MODE_QUAT:
- rotmode = "rotation_quaternion";
- drotmode = "delta_rotation_quaternion";
- default:
- rotmode = "rotation_euler";
- drotmode = "delta_rotation_euler";
- }
+ KX_IpoSGController* ipocontr = new KX_IpoSGController();
+ ipocontr->SetGameObject(gameobj);
+
+ Object* blenderobject = gameobj->GetBlenderObject();
+
+ ipocontr->GetIPOTransform().SetPosition(MT_Point3(blenderobject->loc));
+ ipocontr->GetIPOTransform().SetEulerAngles(MT_Vector3(blenderobject->rot));
+ ipocontr->GetIPOTransform().SetScaling(MT_Vector3(blenderobject->size));
+
+ const char *rotmode, *drotmode;
+
+ switch(blenderobject->rotmode) {
+ case ROT_MODE_AXISANGLE:
+ rotmode = "rotation_axis_angle";
+ drotmode = "delta_rotation_axis_angle";
+ break;
+ case ROT_MODE_QUAT:
+ rotmode = "rotation_quaternion";
+ drotmode = "delta_rotation_quaternion";
+ break;
+ default:
+ rotmode = "rotation_euler";
+ drotmode = "delta_rotation_euler";
+ break;
+ }
- BL_InterpolatorList *adtList= GetAdtList(blenderobject->adt, converter);
+ BL_InterpolatorList *adtList= GetAdtList(action, converter);
- // For each active channel in the adtList add an
- // interpolator to the game object.
+ // For each active channel in the adtList add an
+ // interpolator to the game object.
- KX_IInterpolator *interpolator;
- KX_IScalarInterpolator *interp;
+ KX_IInterpolator *interpolator;
+ KX_IScalarInterpolator *interp;
- for(int i=0; i<3; i++) {
- if ((interp = adtList->GetScalarInterpolator("location", i))) {
- interpolator= new KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetPosition()[i]), interp);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetIPOChannelActive(OB_LOC_X+i, true);
- }
+ for(int i=0; i<3; i++) {
+ if ((interp = adtList->GetScalarInterpolator("location", i))) {
+ interpolator= new KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetPosition()[i]), interp);
+ ipocontr->AddInterpolator(interpolator);
+ ipocontr->SetIPOChannelActive(OB_LOC_X+i, true);
}
- for(int i=0; i<3; i++) {
- if ((interp = adtList->GetScalarInterpolator("delta_location", i))) {
- interpolator= new KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetDeltaPosition()[i]), interp);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetIPOChannelActive(OB_DLOC_X+i, true);
- }
+ }
+ for(int i=0; i<3; i++) {
+ if ((interp = adtList->GetScalarInterpolator("delta_location", i))) {
+ interpolator= new KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetDeltaPosition()[i]), interp);
+ ipocontr->AddInterpolator(interpolator);
+ ipocontr->SetIPOChannelActive(OB_DLOC_X+i, true);
}
- for(int i=0; i<3; i++) {
- if ((interp = adtList->GetScalarInterpolator(rotmode, i))) {
- interpolator= new KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetEulerAngles()[i]), interp);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetIPOChannelActive(OB_ROT_X+i, true);
- }
+ }
+ for(int i=0; i<3; i++) {
+ if ((interp = adtList->GetScalarInterpolator(rotmode, i))) {
+ interpolator= new KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetEulerAngles()[i]), interp);
+ ipocontr->AddInterpolator(interpolator);
+ ipocontr->SetIPOChannelActive(OB_ROT_X+i, true);
}
- for(int i=0; i<3; i++) {
- if ((interp = adtList->GetScalarInterpolator(drotmode, i))) {
- interpolator= new KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetDeltaEulerAngles()[i]), interp);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetIPOChannelActive(OB_DROT_X+i, true);
- }
+ }
+ for(int i=0; i<3; i++) {
+ if ((interp = adtList->GetScalarInterpolator(drotmode, i))) {
+ interpolator= new KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetDeltaEulerAngles()[i]), interp);
+ ipocontr->AddInterpolator(interpolator);
+ ipocontr->SetIPOChannelActive(OB_DROT_X+i, true);
}
- for(int i=0; i<3; i++) {
- if ((interp = adtList->GetScalarInterpolator("scale", i))) {
- interpolator= new KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetScaling()[i]), interp);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetIPOChannelActive(OB_SIZE_X+i, true);
- }
+ }
+ for(int i=0; i<3; i++) {
+ if ((interp = adtList->GetScalarInterpolator("scale", i))) {
+ interpolator= new KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetScaling()[i]), interp);
+ ipocontr->AddInterpolator(interpolator);
+ ipocontr->SetIPOChannelActive(OB_SIZE_X+i, true);
}
- for(int i=0; i<3; i++) {
- if ((interp = adtList->GetScalarInterpolator("delta_scale", i))) {
- interpolator= new KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetDeltaScaling()[i]), interp);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetIPOChannelActive(OB_DSIZE_X+i, true);
- }
+ }
+ for(int i=0; i<3; i++) {
+ if ((interp = adtList->GetScalarInterpolator("delta_scale", i))) {
+ interpolator= new KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetDeltaScaling()[i]), interp);
+ ipocontr->AddInterpolator(interpolator);
+ ipocontr->SetIPOChannelActive(OB_DSIZE_X+i, true);
}
+ }
- {
- KX_ObColorIpoSGController* ipocontr_obcol=NULL;
+ {
+ KX_ObColorIpoSGController* ipocontr_obcol=NULL;
- for(int i=0; i<4; i++) {
- if ((interp = adtList->GetScalarInterpolator("color", i))) {
- if (!ipocontr_obcol) {
- ipocontr_obcol = new KX_ObColorIpoSGController();
- gameobj->GetSGNode()->AddSGController(ipocontr_obcol);
- ipocontr_obcol->SetObject(gameobj->GetSGNode());
- }
- interpolator= new KX_ScalarInterpolator(&ipocontr_obcol->m_rgba[i], interp);
- ipocontr_obcol->AddInterpolator(interpolator);
+ for(int i=0; i<4; i++) {
+ if ((interp = adtList->GetScalarInterpolator("color", i))) {
+ if (!ipocontr_obcol) {
+ ipocontr_obcol = new KX_ObColorIpoSGController();
+ gameobj->GetSGNode()->AddSGController(ipocontr_obcol);
+ ipocontr_obcol->SetObject(gameobj->GetSGNode());
}
+ interpolator= new KX_ScalarInterpolator(&ipocontr_obcol->m_rgba[i], interp);
+ ipocontr_obcol->AddInterpolator(interpolator);
}
}
}
+
+ return ipocontr;
}
-void BL_ConvertLampIpos(struct Lamp* blenderlamp, KX_GameObject *lightobj,KX_BlenderSceneConverter *converter)
+void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_BlenderSceneConverter *converter)
{
+ if (blenderobject->adt) {
+ SG_Controller *ipocontr = BL_CreateIPO(blenderobject->adt->action, gameobj, converter);
+ gameobj->GetSGNode()->AddSGController(ipocontr);
+ ipocontr->SetObject(gameobj->GetSGNode());
+ }
+}
- if (blenderlamp->adt) {
+SG_Controller *BL_CreateLampIPO(struct bAction *action, KX_GameObject* lightobj, KX_BlenderSceneConverter *converter)
+{
+ KX_LightIpoSGController* ipocontr = new KX_LightIpoSGController();
- KX_LightIpoSGController* ipocontr = new KX_LightIpoSGController();
- lightobj->GetSGNode()->AddSGController(ipocontr);
- ipocontr->SetObject(lightobj->GetSGNode());
-
- ipocontr->m_energy = blenderlamp->energy;
- ipocontr->m_col_rgb[0] = blenderlamp->r;
- ipocontr->m_col_rgb[1] = blenderlamp->g;
- ipocontr->m_col_rgb[2] = blenderlamp->b;
- ipocontr->m_dist = blenderlamp->dist;
+ Lamp *blenderlamp = (Lamp*)lightobj->GetBlenderObject()->data;
- BL_InterpolatorList *adtList= GetAdtList(blenderlamp->adt, converter);
+ ipocontr->m_energy = blenderlamp->energy;
+ ipocontr->m_col_rgb[0] = blenderlamp->r;
+ ipocontr->m_col_rgb[1] = blenderlamp->g;
+ ipocontr->m_col_rgb[2] = blenderlamp->b;
+ ipocontr->m_dist = blenderlamp->dist;
- // For each active channel in the adtList add an
- // interpolator to the game object.
+ BL_InterpolatorList *adtList= GetAdtList(action, converter);
+
+ // For each active channel in the adtList add an
+ // interpolator to the game object.
- KX_IInterpolator *interpolator;
- KX_IScalarInterpolator *interp;
+ KX_IInterpolator *interpolator;
+ KX_IScalarInterpolator *interp;
- if ((interp= adtList->GetScalarInterpolator("energy", 0))) {
- interpolator= new KX_ScalarInterpolator(&ipocontr->m_energy, interp);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyEnergy(true);
- }
+ if ((interp= adtList->GetScalarInterpolator("energy", 0))) {
+ interpolator= new KX_ScalarInterpolator(&ipocontr->m_energy, interp);
+ ipocontr->AddInterpolator(interpolator);
+ ipocontr->SetModifyEnergy(true);
+ }
- if ((interp = adtList->GetScalarInterpolator("distance", 0))) {
- interpolator= new KX_ScalarInterpolator(&ipocontr->m_dist, interp);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyDist(true);
- }
+ if ((interp = adtList->GetScalarInterpolator("distance", 0))) {
+ interpolator= new KX_ScalarInterpolator(&ipocontr->m_dist, interp);
+ ipocontr->AddInterpolator(interpolator);
+ ipocontr->SetModifyDist(true);
+ }
- for(int i=0; i<3; i++) {
- if ((interp = adtList->GetScalarInterpolator("color", i))) {
- interpolator= new KX_ScalarInterpolator(&ipocontr->m_col_rgb[i], interp);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyColor(true);
- }
+ for(int i=0; i<3; i++) {
+ if ((interp = adtList->GetScalarInterpolator("color", i))) {
+ interpolator= new KX_ScalarInterpolator(&ipocontr->m_col_rgb[i], interp);
+ ipocontr->AddInterpolator(interpolator);
+ ipocontr->SetModifyColor(true);
}
}
+
+ return ipocontr;
}
+void BL_ConvertLampIpos(struct Lamp* blenderlamp, KX_GameObject *lightobj,KX_BlenderSceneConverter *converter)
+{
+ if (blenderlamp->adt) {
+ SG_Controller* ipocontr = BL_CreateLampIPO(blenderlamp->adt->action, lightobj, converter);
+ lightobj->GetSGNode()->AddSGController(ipocontr);
+ ipocontr->SetObject(lightobj->GetSGNode());
+
+
+ }
+}
-void BL_ConvertCameraIpos(struct Camera* blendercamera, KX_GameObject *cameraobj,KX_BlenderSceneConverter *converter)
+SG_Controller *BL_CreateCameraIPO(struct bAction *action, KX_GameObject* cameraobj, KX_BlenderSceneConverter *converter)
{
+ KX_CameraIpoSGController* ipocontr = new KX_CameraIpoSGController();
- if (blendercamera->adt) {
+ Camera *blendercamera = (Camera*)cameraobj->GetBlenderObject()->data;
- KX_CameraIpoSGController* ipocontr = new KX_CameraIpoSGController();
- cameraobj->GetSGNode()->AddSGController(ipocontr);
- ipocontr->SetObject(cameraobj->GetSGNode());
-
- ipocontr->m_lens = blendercamera->lens;
- ipocontr->m_clipstart = blendercamera->clipsta;
- ipocontr->m_clipend = blendercamera->clipend;
+ ipocontr->m_lens = blendercamera->lens;
+ ipocontr->m_clipstart = blendercamera->clipsta;
+ ipocontr->m_clipend = blendercamera->clipend;
- BL_InterpolatorList *adtList= GetAdtList(blendercamera->adt, converter);
+ BL_InterpolatorList *adtList= GetAdtList(blendercamera->adt->action, converter);
- // For each active channel in the adtList add an
- // interpolator to the game object.
+ // For each active channel in the adtList add an
+ // interpolator to the game object.
- KX_IInterpolator *interpolator;
- KX_IScalarInterpolator *interp;
+ KX_IInterpolator *interpolator;
+ KX_IScalarInterpolator *interp;
- if ((interp = adtList->GetScalarInterpolator("lens", 0))) {
- interpolator= new KX_ScalarInterpolator(&ipocontr->m_lens, interp);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyLens(true);
- }
+ if ((interp = adtList->GetScalarInterpolator("lens", 0))) {
+ interpolator= new KX_ScalarInterpolator(&ipocontr->m_lens, interp);
+ ipocontr->AddInterpolator(interpolator);
+ ipocontr->SetModifyLens(true);
+ }
- if ((interp = adtList->GetScalarInterpolator("clip_start", 0))) {
- interpolator= new KX_ScalarInterpolator(&ipocontr->m_clipstart, interp);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyClipStart(true);
- }
+ if ((interp = adtList->GetScalarInterpolator("clip_start", 0))) {
+ interpolator= new KX_ScalarInterpolator(&ipocontr->m_clipstart, interp);
+ ipocontr->AddInterpolator(interpolator);
+ ipocontr->SetModifyClipStart(true);
+ }
- if ((interp = adtList->GetScalarInterpolator("clip_end", 0))) {
- interpolator= new KX_ScalarInterpolator(&ipocontr->m_clipend, interp);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyClipEnd(true);
- }
+ if ((interp = adtList->GetScalarInterpolator("clip_end", 0))) {
+ interpolator= new KX_ScalarInterpolator(&ipocontr->m_clipend, interp);
+ ipocontr->AddInterpolator(interpolator);
+ ipocontr->SetModifyClipEnd(true);
+ }
+
+ return ipocontr;
+}
+void BL_ConvertCameraIpos(struct Camera* blendercamera, KX_GameObject *cameraobj,KX_BlenderSceneConverter *converter)
+{
+
+ if (blendercamera->adt) {
+ SG_Controller* ipocontr = BL_CreateCameraIPO(blendercamera->adt->action, cameraobj, converter);
+ cameraobj->GetSGNode()->AddSGController(ipocontr);
+ ipocontr->SetObject(cameraobj->GetSGNode());
}
}
@@ -314,7 +315,7 @@ void BL_ConvertWorldIpos(struct World* blenderworld,KX_BlenderSceneConverter *co
ipocontr->m_mist_rgb[1] = blenderworld->horg;
ipocontr->m_mist_rgb[2] = blenderworld->horb;
- BL_InterpolatorList *adtList= GetAdtList(blenderworld->adt, converter);
+ BL_InterpolatorList *adtList= GetAdtList(blenderworld->adt->action, converter);
// For each active channel in the adtList add an
// interpolator to the game object.
@@ -356,7 +357,7 @@ static void ConvertMaterialIpos(
gameobj->GetSGNode()->AddSGController(ipocontr);
ipocontr->SetObject(gameobj->GetSGNode());
- BL_InterpolatorList *adtList= GetAdtList(blendermaterial->adt, converter);
+ BL_InterpolatorList *adtList= GetAdtList(blendermaterial->adt->action, converter);
ipocontr->m_rgba[0] = blendermaterial->r;
diff --git a/source/gameengine/Converter/KX_IpoConvert.h b/source/gameengine/Converter/KX_IpoConvert.h
index d77a72a82e2..60e695c68a7 100644
--- a/source/gameengine/Converter/KX_IpoConvert.h
+++ b/source/gameengine/Converter/KX_IpoConvert.h
@@ -36,10 +36,18 @@
struct Object;
+class SG_Controller *BL_CreateIPO(struct bAction *action,
+ class KX_GameObject* gameobj,
+ class KX_BlenderSceneConverter *converter);
+
void BL_ConvertIpos(struct Object* blenderobject,
class KX_GameObject* gameobj,
class KX_BlenderSceneConverter *converter);
+class SG_Controller *BL_CreateLampIPO(struct bAction *action,
+ class KX_GameObject* lightobj,
+ class KX_BlenderSceneConverter *converter);
+
void BL_ConvertLampIpos(struct Lamp* blenderlight,
class KX_GameObject* lightobj,
class KX_BlenderSceneConverter *converter);
@@ -47,6 +55,10 @@ void BL_ConvertLampIpos(struct Lamp* blenderlight,
void BL_ConvertWorldIpos(struct World* blenderworld,
class KX_BlenderSceneConverter *converter);
+class SG_Controller *BL_CreateCameraIPO(struct bAction *action,
+ class KX_GameObject* cameraobj,
+ class KX_BlenderSceneConverter *converter);
+
void BL_ConvertCameraIpos(struct Camera* blendercamera,
class KX_GameObject* cameraobj,
class KX_BlenderSceneConverter *converter);
diff --git a/source/gameengine/Converter/SConscript b/source/gameengine/Converter/SConscript
index 9cfc3410748..0ae22d548c5 100644
--- a/source/gameengine/Converter/SConscript
+++ b/source/gameengine/Converter/SConscript
@@ -20,6 +20,7 @@ incs += ' #source/blender/misc #source/blender/blenloader #source/blender/gpu'
incs += ' #source/blender/windowmanager'
incs += ' #source/blender/makesrna'
incs += ' #source/blender/ikplugin'
+incs += ' #extern/Eigen2'
incs += ' ' + env['BF_BULLET_INC']