diff options
author | Campbell Barton <ideasman42@gmail.com> | 2008-06-14 21:12:49 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2008-06-14 21:12:49 +0400 |
commit | fc7a83b458811883b01e948a37e6177ae96602db (patch) | |
tree | 8188c60e419df90e1f0c699c2d227e3d6290ae7a /source/gameengine | |
parent | 9c2bf9bdbcc23bb008af543b4fbbdf7c33d0decd (diff) |
Added access for adjusting timeOffset value at runtime, used for apricot (Franky climbing walls)
Diffstat (limited to 'source/gameengine')
-rw-r--r-- | source/gameengine/Ketsji/KX_GameObject.cpp | 21 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_SG_NodeRelationships.h | 15 | ||||
-rw-r--r-- | source/gameengine/PyDoc/KX_GameObject.py | 2 | ||||
-rw-r--r-- | source/gameengine/SceneGraph/SG_Node.cpp | 11 | ||||
-rw-r--r-- | source/gameengine/SceneGraph/SG_Node.h | 8 | ||||
-rw-r--r-- | source/gameengine/SceneGraph/SG_ParentRelation.h | 10 | ||||
-rw-r--r-- | source/gameengine/SceneGraph/SG_Spatial.cpp | 7 | ||||
-rw-r--r-- | source/gameengine/SceneGraph/SG_Spatial.h | 4 |
8 files changed, 78 insertions, 0 deletions
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index c192cd01261..6fde94fec53 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -911,6 +911,14 @@ PyObject* KX_GameObject::_getattr(const STR_String& attr) if (attr == "name") return PyString_FromString(m_name.ReadPtr()); + if (attr == "timeOffset") { + if (m_pSGNode->GetSGParent()->IsSlowParent()) { + return PyFloat_FromDouble(static_cast<KX_SlowParentRelation *>(m_pSGNode->GetSGParent()->GetParentRelation())->GetTimeOffset()); + } else { + return PyFloat_FromDouble(0.0); + } + } + _getattr_up(SCA_IObject); } @@ -932,6 +940,19 @@ int KX_GameObject::_setattr(const STR_String& attr, PyObject *value) // _setattr return 0; } } + + if (PyFloat_Check(value)) + { + MT_Scalar val = PyFloat_AsDouble(value); + if (attr == "timeOffset") { + if (m_pSGNode->GetSGParent()->IsSlowParent()) { + static_cast<KX_SlowParentRelation *>(m_pSGNode->GetSGParent()->GetParentRelation())->SetTimeOffset(val); + return 0; + } else { + return 0; + } + } + } if (PySequence_Check(value)) { diff --git a/source/gameengine/Ketsji/KX_SG_NodeRelationships.h b/source/gameengine/Ketsji/KX_SG_NodeRelationships.h index e53af22408e..faa650106c8 100644 --- a/source/gameengine/Ketsji/KX_SG_NodeRelationships.h +++ b/source/gameengine/Ketsji/KX_SG_NodeRelationships.h @@ -177,8 +177,23 @@ public : NewCopy( ); + MT_Scalar + GetTimeOffset( + ) { return m_relax; } + + void + SetTimeOffset( + MT_Scalar relaxation + ) { m_relax = relaxation; } + ~KX_SlowParentRelation( ); + + bool + IsSlowRelation( + ) { + return true; + } private : diff --git a/source/gameengine/PyDoc/KX_GameObject.py b/source/gameengine/PyDoc/KX_GameObject.py index 8d29a704380..678df59e4a9 100644 --- a/source/gameengine/PyDoc/KX_GameObject.py +++ b/source/gameengine/PyDoc/KX_GameObject.py @@ -22,6 +22,8 @@ class KX_GameObject: @type orientation: 3x3 Matrix [[float]] @ivar scaling: The object's scaling factor. list [sx, sy, sz] @type scaling: list [sx, sy, sz] + @ivar timeOffset: adjust the slowparent delay at runtime. + @type timeOffset: float """ def setVisible(visible): diff --git a/source/gameengine/SceneGraph/SG_Node.cpp b/source/gameengine/SceneGraph/SG_Node.cpp index ff9a9f7f371..4e90d7c4653 100644 --- a/source/gameengine/SceneGraph/SG_Node.cpp +++ b/source/gameengine/SceneGraph/SG_Node.cpp @@ -159,6 +159,17 @@ IsVertexParent() return false; } + bool +SG_Node:: +IsSlowParent() +{ + if (m_parent_relation) + { + return m_parent_relation->IsSlowRelation(); + } + return false; +} + void SG_Node:: DisconnectFromParent( diff --git a/source/gameengine/SceneGraph/SG_Node.h b/source/gameengine/SceneGraph/SG_Node.h index 5cf24de68f3..f86e3046d93 100644 --- a/source/gameengine/SceneGraph/SG_Node.h +++ b/source/gameengine/SceneGraph/SG_Node.h @@ -159,6 +159,14 @@ public: bool IsVertexParent( ) ; + + /** + * Return slow parent status. + */ + + bool + IsSlowParent( + ) ; /** * Update the spatial data of this node. Iterate through diff --git a/source/gameengine/SceneGraph/SG_ParentRelation.h b/source/gameengine/SceneGraph/SG_ParentRelation.h index 9d360d1c274..6507cb98519 100644 --- a/source/gameengine/SceneGraph/SG_ParentRelation.h +++ b/source/gameengine/SceneGraph/SG_ParentRelation.h @@ -99,6 +99,16 @@ public : ) { return false; } + + /** + * Need this to see if we are able to adjust time-offset from the python api + */ + virtual + bool + IsSlowRelation( + ) { + return false; + } protected : /** diff --git a/source/gameengine/SceneGraph/SG_Spatial.cpp b/source/gameengine/SceneGraph/SG_Spatial.cpp index 18049592977..5ba116e59db 100644 --- a/source/gameengine/SceneGraph/SG_Spatial.cpp +++ b/source/gameengine/SceneGraph/SG_Spatial.cpp @@ -87,6 +87,13 @@ SG_Spatial:: delete (m_parent_relation); } + SG_ParentRelation * +SG_Spatial:: +GetParentRelation( +){ + return m_parent_relation; +} + void SG_Spatial:: SetParentRelation( diff --git a/source/gameengine/SceneGraph/SG_Spatial.h b/source/gameengine/SceneGraph/SG_Spatial.h index a70784472a7..28848b0f933 100644 --- a/source/gameengine/SceneGraph/SG_Spatial.h +++ b/source/gameengine/SceneGraph/SG_Spatial.h @@ -83,6 +83,10 @@ public: SetParentRelation( SG_ParentRelation *relation ); + + SG_ParentRelation * + GetParentRelation( + ); /** |