diff options
author | Benoit Bolsee <benoit.bolsee@online.be> | 2009-01-14 01:59:18 +0300 |
---|---|---|
committer | Benoit Bolsee <benoit.bolsee@online.be> | 2009-01-14 01:59:18 +0300 |
commit | 00c12e09066c551e3ae8ee6da3cb85fb3bcf90f8 (patch) | |
tree | a71ff54db96bf05245708ca65ad79de67c05fd76 /source/gameengine/Ketsji/KX_IPhysicsController.h | |
parent | 7f5073729f5fafe4118edb18ac10abbab66bf0c7 (diff) |
BGE patch: dynamically update the coumpound parent shape when parenting to a compound object.
This patch modifies the way the setParent actuator and KX_GameObject::setParent() function
works when parenting to a compound object: the collision shape of the object being parented
is dynamically added to the coumpound shape.
Similarly, unparenting an object from a compound object will cause the child collision shape
to be dynamically removed from the parent shape provided that is was previously added with
setParent.
Note: * This also works if the object is parented to a child of a compound object: the
collision shape is added to the compound shape of the top parent.
* The collision shape is added with the transformation (position, scale and orientation)
it had at the time of the parenting.
* The child shape is rigidly attached to the compound shape, the transformation is not
affected by any further change in position/scale/orientation of the child object.
* While the child shape is added to the compound shape, the child object is removed from
the dynamic world to avoid superposition of shapes (one for the object itself and
one for the compound child shape). This means that collision sensors on the child
object are disabled while the child object is parent to a compound object.
* There is no difference when setParent is used on a non-compound object: the child
object is automatically changed to a static ghost object to avoid bad interaction
with the parent shape; collision sensors on the child object continue to be active
while the object is parented.
* The child shape dynamically added to a compound shape modifies the inertia of the
compound object but not the mass. It participates to collision detection as any other
"static" child shape.
Diffstat (limited to 'source/gameengine/Ketsji/KX_IPhysicsController.h')
-rw-r--r-- | source/gameengine/Ketsji/KX_IPhysicsController.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/source/gameengine/Ketsji/KX_IPhysicsController.h b/source/gameengine/Ketsji/KX_IPhysicsController.h index 4ea283e9f98..fed71735bec 100644 --- a/source/gameengine/Ketsji/KX_IPhysicsController.h +++ b/source/gameengine/Ketsji/KX_IPhysicsController.h @@ -32,6 +32,7 @@ #include "SG_Controller.h" #include "MT_Vector3.h" #include "MT_Point3.h" +#include "MT_Transform.h" #include "MT_Matrix3x3.h" struct KX_ClientObjectInfo; @@ -48,10 +49,11 @@ class KX_IPhysicsController : public SG_Controller { protected: bool m_bDyna; + bool m_bCompound; bool m_suspendDynamics; void* m_userdata; public: - KX_IPhysicsController(bool dyna,void* userdata); + KX_IPhysicsController(bool dyna,bool compound, void* userdata); virtual ~KX_IPhysicsController(); @@ -78,6 +80,8 @@ public: virtual MT_Scalar GetMass()=0; virtual MT_Vector3 getReactionForce()=0; virtual void setRigidBody(bool rigid)=0; + virtual void AddCompoundChild(KX_IPhysicsController* child) = 0; + virtual void RemoveCompoundChild(KX_IPhysicsController* child) = 0; virtual void SuspendDynamics(bool ghost=false)=0; virtual void RestoreDynamics()=0; @@ -92,6 +96,10 @@ public: return m_bDyna; } + bool IsCompound(void) { + return m_bCompound; + } + virtual MT_Scalar GetRadius()=0; virtual void SetSumoTransform(bool nondynaonly)=0; // todo: remove next line ! |