diff options
Diffstat (limited to 'source/gameengine')
4 files changed, 39 insertions, 8 deletions
diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index f90df047ca0..7e684e5d5b7 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -672,11 +672,11 @@ void KX_ConvertODEEngineObject(KX_GameObject* gameobj, { btSoftBody* m_softBody; class RAS_MeshObject* m_pMeshObject; - class BL_DeformableGameObject* m_gameobj; + class KX_GameObject* m_gameobj; public: - KX_SoftBodyDeformer(btSoftBody* softBody,RAS_MeshObject* pMeshObject,BL_DeformableGameObject* gameobj) + KX_SoftBodyDeformer(btSoftBody* softBody,RAS_MeshObject* pMeshObject,KX_GameObject* gameobj) : m_softBody(softBody), m_pMeshObject(pMeshObject), m_gameobj(gameobj) @@ -703,6 +703,8 @@ void KX_ConvertODEEngineObject(KX_GameObject* gameobj, // update the vertex in m_transverts Update(); + + // The vertex cache can only be updated for this deformer: // Duplicated objects with more than one ploymaterial (=multiple mesh slot per object) // share the same mesh (=the same cache). As the rendering is done per polymaterial @@ -748,6 +750,12 @@ void KX_ConvertODEEngineObject(KX_GameObject* gameobj, //printf("getReplica\n"); return 0; } + + virtual bool SkipVertexTransform() + { + return true; + } + protected: //class RAS_MeshObject *m_pMesh; }; @@ -1089,7 +1097,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, if (softBody && gameobj->GetMesh(0))//only the first mesh, if any { //should be a mesh then, so add a soft body deformer - KX_SoftBodyDeformer* softbodyDeformer = new KX_SoftBodyDeformer(softBody, gameobj->GetMesh(0),(BL_DeformableGameObject*)gameobj); + KX_SoftBodyDeformer* softbodyDeformer = new KX_SoftBodyDeformer(softBody, gameobj->GetMesh(0),gameobj); gameobj->SetDeformer(softbodyDeformer); } diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index f8dc81e0f3d..29ee0310c58 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -401,13 +401,17 @@ void CcdPhysicsController::CreateRigidbody() { startTrans = rbci.m_startWorldTransform; } - startTrans.setIdentity(); + //startTrans.setIdentity(); - m_object->setWorldTransform(startTrans); - m_object->setInterpolationWorldTransform(startTrans); - m_MotionState->setWorldPosition(0,0,0); + //m_object->setWorldTransform(startTrans); + //m_object->setInterpolationWorldTransform(startTrans); + m_MotionState->setWorldPosition(startTrans.getOrigin().getX(),startTrans.getOrigin().getY(),startTrans.getOrigin().getZ()); m_MotionState->setWorldOrientation(0,0,0,1); +// btVector3 wp = m_softBody->getWorldTransform().getOrigin(); +// MT_Point3 center(wp.getX(),wp.getY(),wp.getZ()); +// m_gameobj->NodeSetWorldPosition(center); + } else { @@ -502,10 +506,22 @@ bool CcdPhysicsController::SynchronizeMotionStates(float time) { //sync non-static to motionstate, and static from motionstate (todo: add kinematic etc.) + btSoftBody* sb = GetSoftBody(); + if (sb) + { + btVector3 aabbMin,aabbMax; + sb->getAabb(aabbMin,aabbMax); + btVector3 worldPos = (aabbMax+aabbMin)*0.5f; + m_MotionState->setWorldPosition(worldPos[0],worldPos[1],worldPos[2]); + m_MotionState->calculateWorldTransformations(); + return true; + } + btRigidBody* body = GetRigidBody(); if (body && !body->isStaticObject()) { + const btVector3& worldPos = body->getCenterOfMassPosition(); m_MotionState->setWorldPosition(worldPos[0],worldPos[1],worldPos[2]); diff --git a/source/gameengine/Rasterizer/RAS_Deformer.h b/source/gameengine/Rasterizer/RAS_Deformer.h index 4e8484ab880..6665e1926cf 100644 --- a/source/gameengine/Rasterizer/RAS_Deformer.h +++ b/source/gameengine/Rasterizer/RAS_Deformer.h @@ -45,6 +45,10 @@ public: virtual bool Apply(class RAS_IPolyMaterial *polymat)=0; virtual bool Update(void)=0; virtual RAS_Deformer *GetReplica()=0; + virtual bool SkipVertexTransform() + { + return false; + } protected: class RAS_MeshObject *m_pMesh; }; diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp index 2b129f51609..ad8d7ebd5b0 100644 --- a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp +++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp @@ -539,7 +539,10 @@ void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRa ms.m_mesh->SortPolygons(ms, cameratrans*MT_Transform(ms.m_OpenGLMatrix)); rendertools->PushMatrix(); - rendertools->applyTransform(rasty,ms.m_OpenGLMatrix,m_material->GetDrawingMode()); + if (!ms.m_pDeformer || !ms.m_pDeformer->SkipVertexTransform()) + { + rendertools->applyTransform(rasty,ms.m_OpenGLMatrix,m_material->GetDrawingMode()); + } if(rasty->QueryLists()) if(ms.m_DisplayList) |