diff options
author | James Yonan <james@openvpn.net> | 2013-12-09 15:26:52 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-12-09 15:28:38 +0400 |
commit | 1831c930a5a2144e7941407e2a283cd168897626 (patch) | |
tree | 53a979c4efe12074a7a9eb07ef7a721cc8f0d93d /source/gameengine/Ketsji | |
parent | 964252cdda6feedab58d42fc3fe92a42cd47501d (diff) |
Game Engine: Option to record static objects animation
Diffstat (limited to 'source/gameengine/Ketsji')
-rw-r--r-- | source/gameengine/Ketsji/KX_ConvertPhysicsObject.h | 1 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp | 10 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_GameObject.cpp | 24 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_GameObject.h | 17 |
4 files changed, 52 insertions, 0 deletions
diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h b/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h index 903966b79be..1ed3a998b99 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h @@ -71,6 +71,7 @@ struct KX_ObjectProperties bool m_ghost; class KX_GameObject* m_dynamic_parent; bool m_isactor; + bool m_record_animation; bool m_sensor; bool m_character; bool m_concave; diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index bde50588fd3..16513a97d60 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -435,6 +435,11 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, shapeInfo->Release(); gameobj->SetPhysicsController(physicscontroller,isbulletdyna); + + // record animation for dynamic objects + if (isbulletdyna) + gameobj->SetRecordAnimation(true); + // don't add automatically sensor object, they are added when a collision sensor is registered if (!isbulletsensor && objprop->m_in_active_layer) { @@ -493,6 +498,11 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, gameobj->getClientInfo()->m_type = (isbulletsensor) ? ((isActor) ? KX_ClientObjectInfo::OBACTORSENSOR : KX_ClientObjectInfo::OBSENSOR) : (isActor) ? KX_ClientObjectInfo::ACTOR : KX_ClientObjectInfo::STATIC; + + // should we record animation for this object? + if (objprop->m_record_animation) + gameobj->SetRecordAnimation(true); + // store materialname in auxinfo, needed for touchsensors if (meshobj) { diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 96f76ff21b1..d3b5a987138 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -112,6 +112,7 @@ KX_GameObject::KX_GameObject( m_pInstanceObjects(NULL), m_pDupliGroupObject(NULL), m_actionManager(NULL), + m_bRecordAnimation(false), m_isDeformable(false) #ifdef WITH_PYTHON @@ -1791,6 +1792,7 @@ PyAttributeDef KX_GameObject::Attributes[] = { KX_PYATTRIBUTE_RW_FUNCTION("linVelocityMin", KX_GameObject, pyattr_get_lin_vel_min, pyattr_set_lin_vel_min), KX_PYATTRIBUTE_RW_FUNCTION("linVelocityMax", KX_GameObject, pyattr_get_lin_vel_max, pyattr_set_lin_vel_max), KX_PYATTRIBUTE_RW_FUNCTION("visible", KX_GameObject, pyattr_get_visible, pyattr_set_visible), + KX_PYATTRIBUTE_RW_FUNCTION("record_animation", KX_GameObject, pyattr_get_record_animation, pyattr_set_record_animation), KX_PYATTRIBUTE_BOOL_RW ("occlusion", KX_GameObject, m_bOccluder), KX_PYATTRIBUTE_RW_FUNCTION("position", KX_GameObject, pyattr_get_worldPosition, pyattr_set_localPosition), KX_PYATTRIBUTE_RO_FUNCTION("localInertia", KX_GameObject, pyattr_get_localInertia), @@ -2258,6 +2260,28 @@ int KX_GameObject::pyattr_set_visible(void *self_v, const KX_PYATTRIBUTE_DEF *at return PY_SET_ATTR_SUCCESS; } +PyObject *KX_GameObject::pyattr_get_record_animation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +{ + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); + return PyBool_FromLong(self->IsRecordAnimation()); +} + +int KX_GameObject::pyattr_set_record_animation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) +{ + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); + int param = PyObject_IsTrue(value); + if (param == -1) { + PyErr_SetString(PyExc_AttributeError, "gameOb.record_animation = bool: KX_GameObject, expected boolean"); + return PY_SET_ATTR_FAIL; + } + + self->SetRecordAnimation(param); + + return PY_SET_ATTR_SUCCESS; +} + + + PyObject *KX_GameObject::pyattr_get_worldPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { #ifdef USE_MATHUTILS diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 55e2b31c5bf..12aac68365b 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -126,6 +126,7 @@ protected: BL_ActionManager* GetActionManager(); + bool m_bRecordAnimation; public: bool m_isDeformable; @@ -600,6 +601,20 @@ public: } /** + * Should we record animation for this object? + */ + + void SetRecordAnimation(bool recordAnimation) + { + m_bRecordAnimation = recordAnimation; + } + + bool IsRecordAnimation() const + { + return m_bRecordAnimation; + } + + /** * Check if this object has a vertex parent relationship */ bool IsVertexParent( ) @@ -981,6 +996,8 @@ public: static int pyattr_set_lin_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); static PyObject* pyattr_get_visible(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_visible(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); + static PyObject* pyattr_get_record_animation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static int pyattr_set_record_animation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); static PyObject* pyattr_get_worldPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_worldPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); static PyObject* pyattr_get_localPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); |