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:
authorCampbell Barton <ideasman42@gmail.com>2009-07-26 02:57:29 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-07-26 02:57:29 +0400
commite9ca43521f99c6b9baf6d9278f85323086fcade2 (patch)
tree58ab9f5afe70d77fa04f920fa2c55adb34cd2990 /source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
parent1c00eacca2b084d7189de33cb75e8612cb542030 (diff)
BGE Physics
Add support back for reinstancePhysics mesh, a frequently requested feature in the BGE forums. from what I can tell Sumo supported this but bullet never did. Currently only accessible via python at the moment. - rigid body, dynamic, static types work. - instanced physics meshes are modified too. - compound shapes are not supported. Physics mesh can be re-instanced from... * shape keys & armature deformations * subsurf (any other modifiers too) * RAS_TexVert's (can be modified from python) Moved the reinstancePhysicsMesh functions from RAS_MeshObject into KX_GameObject since the physics data is stored here. video and blend file demo. http://www.graphicall.org/ftp/ideasman42/reinstance.ogv http://www.graphicall.org/ftp/ideasman42/reinstance_demo.blend
Diffstat (limited to 'source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp41
1 files changed, 40 insertions, 1 deletions
diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
index 51c41c0686d..cc8a00e8454 100644
--- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
+++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
@@ -1220,5 +1220,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