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:
authorMitchell Stokes <mogurijin@gmail.com>2014-04-24 06:37:54 +0400
committerMitchell Stokes <mogurijin@gmail.com>2014-04-24 06:39:57 +0400
commitf5c3c624f8e62f266994be42fa4c85ce579321c0 (patch)
tree1ecddb7f709c95840ffc5711f912e23d867306a3 /source/gameengine/Physics
parent4e5e3a978e497dad315fec2e3690c977a06ca779 (diff)
BGE Cleanup: Moving reinstancing physics shapes from KX_ConvertPhysicsObject to PHY_IPhysicsController
This was the last item in KX_ConvertPhysicsObject. Therefore, KX_ConvertPhysicsObject.h and KX_ConvertPhysicsObjects.cpp have been removed.
Diffstat (limited to 'source/gameengine/Physics')
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsController.cpp35
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsController.h2
-rw-r--r--source/gameengine/Physics/common/PHY_IPhysicsController.h5
3 files changed, 42 insertions, 0 deletions
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
index 33726018268..c98cf212265 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
@@ -1625,6 +1625,41 @@ PHY_IPhysicsController* CcdPhysicsController::GetReplicaForSensors()
return replica;
}
+/* Refresh the physics object from either an object or a mesh.
+ * 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) this - update the phys mesh from DerivedMesh or RAS_MeshObject
+ *
+ * Most of the logic behind this is in shapeInfo->UpdateMesh(...)
+ */
+bool CcdPhysicsController::ReinstancePhysicsShape(KX_GameObject *from_gameobj, RAS_MeshObject *from_meshobj)
+{
+ CcdShapeConstructionInfo *shapeInfo;
+
+ shapeInfo = this->GetShapeInfo();
+
+ if (shapeInfo->m_shapeType != PHY_SHAPE_MESH/* || spc->GetSoftBody()*/)
+ return false;
+
+ this->DeleteControllerShape();
+
+ if (from_gameobj==NULL && from_meshobj==NULL)
+ from_gameobj = KX_GameObject::GetClientObject((KX_ClientObjectInfo*)this->GetNewClientInfo());
+
+ /* updates the arrays used for making the new bullet mesh */
+ shapeInfo->UpdateMesh(from_gameobj, from_meshobj);
+
+ /* create the new bullet mesh */
+ CcdConstructionInfo& cci = this->GetConstructionInfo();
+ btCollisionShape* bm= shapeInfo->CreateBulletShape(cci.m_margin, cci.m_bGimpact, !cci.m_bSoft);
+
+ this->ReplaceControllerShape(bm);
+ return true;
+}
+
///////////////////////////////////////////////////////////
///A small utility class, DefaultMotionState
///
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h
index 0d6d40861c5..d8bb0d06d10 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h
@@ -704,6 +704,8 @@ protected:
return GetConstructionInfo().m_shapeInfo->m_shapeType == PHY_SHAPE_COMPOUND;
}
+ virtual bool ReinstancePhysicsShape(KX_GameObject *from_gameobj, RAS_MeshObject* from_meshobj);
+
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("GE:CcdPhysicsController")
#endif
diff --git a/source/gameengine/Physics/common/PHY_IPhysicsController.h b/source/gameengine/Physics/common/PHY_IPhysicsController.h
index a1d0972a950..2ffb115e3b2 100644
--- a/source/gameengine/Physics/common/PHY_IPhysicsController.h
+++ b/source/gameengine/Physics/common/PHY_IPhysicsController.h
@@ -41,6 +41,9 @@ class MT_Vector3;
class MT_Point3;
class MT_Matrix3x3;
+class KX_GameObject;
+class RAS_MeshObject;
+
/**
* PHY_IPhysicsController is the abstract simplified Interface to a physical object.
* It contains the IMotionState and IDeformableMesh Interfaces.
@@ -124,6 +127,8 @@ class PHY_IPhysicsController : public PHY_IController
virtual bool IsDynamic() = 0;
virtual bool IsCompound() = 0;
+ virtual bool ReinstancePhysicsShape(KX_GameObject *from_gameobj, RAS_MeshObject* from_meshobj) = 0;
+
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("GE:PHY_IPhysicsController")