diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-07-26 03:16:45 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-07-26 03:16:45 +0400 |
commit | 777a0d78e79d25c385eac4dd4835f8ca65317b26 (patch) | |
tree | a3b5213e6ac6572ca966448044affec198b3e0e5 /source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp | |
parent | 756488fbe2c0beaf205cb28d6f4ca1e62a64588a (diff) | |
parent | e9ca43521f99c6b9baf6d9278f85323086fcade2 (diff) |
svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r21899:21908
Diffstat (limited to 'source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp')
-rw-r--r-- | source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index 64b5760de28..04e82d21cf4 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -628,5 +628,44 @@ void KX_ClearBulletSharedShapes() { } -#endif +/* Refresh the physics object from either an object or a mesh. + * gameobj must be valid + * from_gameobj and from_meshobj can be NULL + * + * when setting the mesh, the following vars get priority + * 1) from_meshobj - creates the phys mesh from RAS_MeshObject + * 2) from_gameobj - creates the phys mesh from the DerivedMesh where possible, else the RAS_MeshObject + * 3) gameobj - update the phys mesh from DerivedMesh or RAS_MeshObject + * + * Most of the logic behind this is in shapeInfo->UpdateMesh(...) + */ +bool KX_ReInstanceBulletShapeFromMesh(KX_GameObject *gameobj, KX_GameObject *from_gameobj, RAS_MeshObject* from_meshobj) +{ + KX_BulletPhysicsController *spc= static_cast<KX_BulletPhysicsController*>((gameobj->GetPhysicsController())); + CcdShapeConstructionInfo *shapeInfo; + + /* if this is the child of a compound shape this can happen + * dont support compound shapes for now */ + if(spc==NULL) + return false; + + shapeInfo = spc->GetShapeInfo(); + + if(shapeInfo->m_shapeType != PHY_SHAPE_MESH || spc->GetSoftBody()) + return false; + + spc->DeleteControllerShape(); + + if(from_gameobj==NULL && from_meshobj==NULL) + from_gameobj= gameobj; + + /* updates the arrays used for making the new bullet mesh */ + shapeInfo->UpdateMesh(from_gameobj, from_meshobj); + /* create the new bullet mesh */ + btCollisionShape* bm= shapeInfo->CreateBulletShape(spc->getConstructionInfo().m_margin); + + spc->ReplaceControllerShape(bm); + return true; +} +#endif |