diff options
Diffstat (limited to 'source/gameengine')
-rw-r--r-- | source/gameengine/Converter/BL_BlenderDataConversion.cpp | 4 | ||||
-rw-r--r-- | source/gameengine/Converter/BL_MeshDeformer.h | 8 | ||||
-rw-r--r-- | source/gameengine/Converter/BL_SkinDeformer.cpp | 12 | ||||
-rw-r--r-- | source/gameengine/Converter/BL_SkinDeformer.h | 11 | ||||
-rw-r--r-- | source/gameengine/Expressions/Value.cpp | 4 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_BulletPhysicsController.cpp | 79 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp | 26 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_EmptyObject.cpp | 4 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_EmptyObject.h | 2 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_Scene.cpp | 4 | ||||
-rw-r--r-- | source/gameengine/Physics/Bullet/CcdPhysicsController.cpp | 90 | ||||
-rw-r--r-- | source/gameengine/Physics/Bullet/CcdPhysicsController.h | 10 | ||||
-rw-r--r-- | source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp | 2 |
13 files changed, 211 insertions, 45 deletions
diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index f6136d52684..fe0cf281a1a 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -961,11 +961,11 @@ static KX_GameObject *gameobject_from_blenderobject( // If this is a skin object, make Skin Controller if (ob->parent && ob->parent->type == OB_ARMATURE && ob->partype==PARSKEL && ((Mesh*)ob->data)->dvert){ - BL_SkinDeformer *dcont = new BL_SkinDeformer(ob, (BL_SkinMeshObject*)meshobj); + BL_SkinDeformer *dcont = new BL_SkinDeformer(ob, (BL_SkinMeshObject*)meshobj,ob->parent); ((BL_DeformableGameObject*)gameobj)->m_pDeformer = dcont; } else if (((Mesh*)ob->data)->dvert){ - BL_MeshDeformer *dcont = new BL_MeshDeformer(ob, (BL_SkinMeshObject*)meshobj); + BL_MeshDeformer *dcont = new BL_MeshDeformer(ob, (BL_SkinMeshObject*)meshobj,ob->parent); ((BL_DeformableGameObject*)gameobj)->m_pDeformer = dcont; } diff --git a/source/gameengine/Converter/BL_MeshDeformer.h b/source/gameengine/Converter/BL_MeshDeformer.h index 04e0f3b0628..c9030ceca36 100644 --- a/source/gameengine/Converter/BL_MeshDeformer.h +++ b/source/gameengine/Converter/BL_MeshDeformer.h @@ -48,12 +48,14 @@ public: void VerifyStorage(); void RecalcNormals(); virtual void Relink(GEN_Map<class GEN_HashedPtr, void*>*map){}; - BL_MeshDeformer(struct Object* obj, class BL_SkinMeshObject *meshobj): + BL_MeshDeformer(struct Object* obj, class BL_SkinMeshObject *meshobj,struct Object* armatureObj): m_pMeshObject(meshobj), m_bmesh((struct Mesh*)(obj->data)), m_transnors(NULL), m_transverts(NULL), - m_tvtot(0) + m_tvtot(0), + m_blenderMeshObject(obj), + m_blenderArmatureObj(armatureObj) {}; virtual ~BL_MeshDeformer(); virtual void SetSimulatedTime(double time){}; @@ -67,6 +69,8 @@ protected: MT_Point3 *m_transnors; MT_Point3 *m_transverts; int m_tvtot; + Object* m_blenderMeshObject; + Object* m_blenderArmatureObj; }; diff --git a/source/gameengine/Converter/BL_SkinDeformer.cpp b/source/gameengine/Converter/BL_SkinDeformer.cpp index ee298d70baf..84a3b8dcc5c 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.cpp +++ b/source/gameengine/Converter/BL_SkinDeformer.cpp @@ -145,6 +145,10 @@ void BL_SkinDeformer::ProcessReplica() { } +//void where_is_pose (Object *ob); +//void armature_deform_verts(Object *armOb, Object *target, float (*vertexCos)[3], int numVerts, int deformflag); +extern "C" void armature_deform_verts(struct Object *armOb, struct Object *target, float (*vertexCos)[3], int numVerts, int deformflag); + void BL_SkinDeformer::Update(void) { @@ -156,7 +160,8 @@ void BL_SkinDeformer::Update(void) /* XXX note: where_is_pose() (from BKE_armature.h) calculates all matrices needed to start deforming */ /* but it requires the blender object pointer... */ -// void where_is_pose (Object *ob); + //void where_is_pose (Object *ob); + where_is_pose (m_blenderArmatureObj); /* store verts locally */ for (int v =0; v<m_bmesh->totvert; v++){ @@ -165,6 +170,11 @@ void BL_SkinDeformer::Update(void) m_transverts[v]=MT_Point3(m_bmesh->mvert[v].co); } + float test[1000][3]; + + armature_deform_verts(m_blenderArmatureObj,m_blenderMeshObject,test,m_bmesh->totvert,ARM_DEF_VGROUP); + + /* XXX note: now use this call instead */ // void armature_deform_verts(Object *armOb, Object *target, float (*vertexCos)[3], int numVerts, int deformflag) // - armOb = armature object diff --git a/source/gameengine/Converter/BL_SkinDeformer.h b/source/gameengine/Converter/BL_SkinDeformer.h index a61ebf59b22..49c69298336 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.h +++ b/source/gameengine/Converter/BL_SkinDeformer.h @@ -63,9 +63,10 @@ public: m_armobj=NULL; } void SetArmature (class BL_ArmatureObject *armobj); - BL_SkinDeformer( struct Object *bmeshobj, - class BL_SkinMeshObject *mesh) - :BL_MeshDeformer(bmeshobj, mesh), + + BL_SkinDeformer( struct Object *bmeshobj, + class BL_SkinMeshObject *mesh,struct Object* blenderArmatureObj) + :BL_MeshDeformer(bmeshobj, mesh,blenderArmatureObj), m_armobj(NULL), m_lastUpdate(-1), m_defbase(&bmeshobj->defbase) @@ -85,8 +86,8 @@ public: BL_SkinDeformer( struct Object *bmeshobj_old, struct Object *bmeshobj_new, - class BL_SkinMeshObject *mesh) - :BL_MeshDeformer(bmeshobj_old, mesh), + class BL_SkinMeshObject *mesh,struct Object *bArmatureObj) + :BL_MeshDeformer(bmeshobj_old, mesh,bArmatureObj), m_armobj(NULL), m_lastUpdate(-1), m_defbase(&bmeshobj_old->defbase) diff --git a/source/gameengine/Expressions/Value.cpp b/source/gameengine/Expressions/Value.cpp index 1a09123c107..bb9ad81f245 100644 --- a/source/gameengine/Expressions/Value.cpp +++ b/source/gameengine/Expressions/Value.cpp @@ -558,6 +558,10 @@ void CValue::DisableRefCount() void CValue::AddDataToReplica(CValue *replica) { replica->m_refcount = 1; + + //register with Python + _Py_NewReference(replica); + #ifdef _DEBUG //gRefCountValue++; #endif diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp index 5857c614e2d..7806b77257a 100644 --- a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp +++ b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp @@ -7,6 +7,14 @@ #include "Dynamics/RigidBody.h" +#include "SG_Spatial.h" + +#include "KX_GameObject.h" +#include "KX_MotionState.h" +#include "KX_ClientObjectInfo.h" + +#include "PHY_IPhysicsEnvironment.h" + KX_BulletPhysicsController::KX_BulletPhysicsController (const CcdConstructionInfo& ci, bool dyna) : KX_IPhysicsController(dyna,(PHY_IPhysicsController*)this), CcdPhysicsController(ci) @@ -38,6 +46,16 @@ void KX_BulletPhysicsController::applyImpulse(const MT_Point3& attach, const MT_ void KX_BulletPhysicsController::SetObject (SG_IObject* object) { + SG_Controller::SetObject(object); + + // cheating here... + //should not be necessary, is it for duplicates ? + + KX_GameObject* gameobj = (KX_GameObject*) object->GetSGClientObject(); + gameobj->SetPhysicsController(this,gameobj->IsDynamic()); + //GetSumoObject()->setClientObject(gameobj->getClientInfo()); + + } void KX_BulletPhysicsController::RelativeTranslate(const MT_Vector3& dloc,bool local) @@ -55,22 +73,25 @@ void KX_BulletPhysicsController::RelativeRotate(const MT_Matrix3x3& drot,bool lo void KX_BulletPhysicsController::ApplyTorque(const MT_Vector3& torque,bool local) { + CcdPhysicsController::ApplyTorque(torque.x(),torque.y(),torque.z(),local); } void KX_BulletPhysicsController::ApplyForce(const MT_Vector3& force,bool local) { + CcdPhysicsController::ApplyForce(force.x(),force.y(),force.z(),local); } MT_Vector3 KX_BulletPhysicsController::GetLinearVelocity() { - assert(0); - return MT_Vector3(0.f,0.f,0.f); - + float angVel[3]; + CcdPhysicsController::GetAngularVelocity(angVel[0],angVel[1],angVel[2]); + return MT_Vector3(angVel[0],angVel[1],angVel[2]); } MT_Vector3 KX_BulletPhysicsController::GetVelocity(const MT_Point3& pos) { - assert(0); - return MT_Vector3(0.f,0.f,0.f); - + float linVel[3]; + CcdPhysicsController::GetLinearVelocity(linVel[0],linVel[1],linVel[2]); + return MT_Vector3(linVel[0],linVel[1],linVel[2]); } + void KX_BulletPhysicsController::SetAngularVelocity(const MT_Vector3& ang_vel,bool local) { CcdPhysicsController::SetAngularVelocity(ang_vel.x(),ang_vel.y(),ang_vel.z(),local); @@ -82,16 +103,21 @@ void KX_BulletPhysicsController::SetLinearVelocity(const MT_Vector3& lin_vel,boo } void KX_BulletPhysicsController::getOrientation(MT_Quaternion& orn) { + float myorn[4]; + CcdPhysicsController::getOrientation(myorn[0],myorn[1],myorn[2],myorn[3]); + orn = MT_Quaternion(myorn[0],myorn[1],myorn[2],myorn[3]); } void KX_BulletPhysicsController::setOrientation(const MT_Quaternion& orn) { + CcdPhysicsController::setOrientation(orn.x(),orn.y(),orn.z(),orn.w()); } void KX_BulletPhysicsController::setPosition(const MT_Point3& pos) { - + CcdPhysicsController::setPosition(pos.x(),pos.y(),pos.z()); } void KX_BulletPhysicsController::setScaling(const MT_Vector3& scaling) { + CcdPhysicsController::setScaling(scaling.x(),scaling.y(),scaling.z()); } MT_Scalar KX_BulletPhysicsController::GetMass() { @@ -113,6 +139,7 @@ void KX_BulletPhysicsController::setRigidBody(bool rigid) void KX_BulletPhysicsController::SuspendDynamics() { + } void KX_BulletPhysicsController::RestoreDynamics() { @@ -120,8 +147,42 @@ void KX_BulletPhysicsController::RestoreDynamics() SG_Controller* KX_BulletPhysicsController::GetReplica(class SG_Node* destnode) { - assert(0); - return 0; + PHY_IMotionState* motionstate = new KX_MotionState(destnode); + + KX_BulletPhysicsController* physicsreplica = new KX_BulletPhysicsController(*this); + + //parentcontroller is here be able to avoid collisions between parent/child + + PHY_IPhysicsController* parentctrl = NULL; + + if (destnode != destnode->GetRootSGParent()) + { + KX_GameObject* clientgameobj = (KX_GameObject*) destnode->GetRootSGParent()->GetSGClientObject(); + if (clientgameobj) + { + parentctrl = (KX_BulletPhysicsController*)clientgameobj->GetPhysicsController(); + } else + { + // it could be a false node, try the children + NodeList::const_iterator childit; + for ( + childit = destnode->GetSGChildren().begin(); + childit!= destnode->GetSGChildren().end(); + ++childit + ) { + KX_GameObject *clientgameobj = static_cast<KX_GameObject*>( (*childit)->GetSGClientObject()); + if (clientgameobj) + { + parentctrl = (KX_BulletPhysicsController*)clientgameobj->GetPhysicsController(); + } + } + } + } + + physicsreplica->PostProcessReplica(motionstate,parentctrl); + + return physicsreplica; + } diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index e9a6c2442b0..646fc93dadb 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -673,6 +673,7 @@ void KX_ConvertODEEngineObject(KX_GameObject* gameobj, #include "CollisionShapes/ConvexHullShape.h" #include "CollisionShapes/TriangleMesh.h" #include "CollisionShapes/TriangleMeshShape.h" +#include "CollisionShapes/BvhTriangleMeshShape.h" static GEN_Map<GEN_HashedPtr,CollisionShape*> map_gamemesh_to_bulletshape; @@ -770,8 +771,8 @@ static CollisionShape* CreateBulletShapeFromMesh(RAS_MeshObject* meshobj, bool p } else { collisionMeshData = new TriangleMesh(); - concaveShape = new TriangleMeshShape(collisionMeshData); - collisionMeshShape = concaveShape; +// concaveShape = new TriangleMeshShape(collisionMeshData); + //collisionMeshShape = concaveShape; } @@ -843,7 +844,20 @@ static CollisionShape* CreateBulletShapeFromMesh(RAS_MeshObject* meshobj, bool p if (numvalidpolys > 0) { + //map_gamemesh_to_bulletshape.insert(GEN_HashedPtr(meshobj),collisionMeshShape); + if (!polytope) + { + concaveShape = new BvhTriangleMeshShape( collisionMeshData ); + //concaveShape = new TriangleMeshShape( collisionMeshData ); + + concaveShape->RecalcLocalAabb(); + collisionMeshShape = concaveShape; + + } + + + return collisionMeshShape; } @@ -1002,7 +1016,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, ci.m_broadphaseHandle = 0; ci.m_friction = smmaterial->m_friction; ci.m_restitution = smmaterial->m_restitution; - + ci.m_physicsEnv = env; // drag / damping is inverted ci.m_linearDamping = 1.f - shapeprops->m_lin_drag; ci.m_angularDamping = 1.f - shapeprops->m_ang_drag; @@ -1010,7 +1024,11 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, KX_BulletPhysicsController* physicscontroller = new KX_BulletPhysicsController(ci,isbulletdyna); - env->addCcdPhysicsController( physicscontroller); + + if (objprop->m_in_active_layer) + { + env->addCcdPhysicsController( physicscontroller); + } gameobj->SetPhysicsController(physicscontroller,isbulletdyna); diff --git a/source/gameengine/Ketsji/KX_EmptyObject.cpp b/source/gameengine/Ketsji/KX_EmptyObject.cpp index 8a72ba62f51..4636f2f0a3e 100644 --- a/source/gameengine/Ketsji/KX_EmptyObject.cpp +++ b/source/gameengine/Ketsji/KX_EmptyObject.cpp @@ -35,3 +35,7 @@ #include <config.h> #endif +KX_EmptyObject::~KX_EmptyObject() +{ + +} diff --git a/source/gameengine/Ketsji/KX_EmptyObject.h b/source/gameengine/Ketsji/KX_EmptyObject.h index b2038eb4816..46858b5c46d 100644 --- a/source/gameengine/Ketsji/KX_EmptyObject.h +++ b/source/gameengine/Ketsji/KX_EmptyObject.h @@ -39,7 +39,7 @@ public: KX_EmptyObject(void* sgReplicationInfo,SG_Callbacks callbacks) : KX_GameObject(sgReplicationInfo,callbacks) {}; - virtual ~KX_EmptyObject() {}; + virtual ~KX_EmptyObject(); }; diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 6ad420375e6..f13df6bfa44 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -732,7 +732,7 @@ void KX_Scene::ReplaceMesh(class CValue* gameobj,void* meshobj) Object* blendobj = (struct Object*)m_logicmgr->FindBlendObjByGameObj(newobj); Object* oldblendobj = (struct Object*)m_logicmgr->FindBlendObjByGameMeshName(mesh->GetName()); if (blendobj->parent && blendobj->parent->type == OB_ARMATURE && blendobj->partype==PARSKEL && ((Mesh*)blendobj->data)->dvert) { - BL_SkinDeformer* skindeformer = new BL_SkinDeformer(oldblendobj, blendobj, (BL_SkinMeshObject*)mesh); + BL_SkinDeformer* skindeformer = new BL_SkinDeformer(oldblendobj, blendobj, (BL_SkinMeshObject*)mesh,blendobj->parent); skindeformer->SetArmature((BL_ArmatureObject*) newobj->GetParent()); // FIXME: should the old m_pDeformer be deleted? @@ -741,7 +741,7 @@ void KX_Scene::ReplaceMesh(class CValue* gameobj,void* meshobj) ((BL_DeformableGameObject*)newobj)->m_pDeformer = skindeformer; } else if (((Mesh*)blendobj->data)->dvert) { - BL_MeshDeformer* meshdeformer = new BL_MeshDeformer(oldblendobj, (BL_SkinMeshObject*)mesh); + BL_MeshDeformer* meshdeformer = new BL_MeshDeformer(oldblendobj, (BL_SkinMeshObject*)mesh,oldblendobj->parent); // FIXME: should the old m_pDeformer be deleted? // delete ((BL_DeformableGameObject*)newobj)->m_pDeformer diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index d9c5575f657..bb4f1465b2d 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -4,6 +4,8 @@ #include "PHY_IMotionState.h" #include "BroadphaseCollision/BroadphaseProxy.h" #include "CollisionShapes/ConvexShape.h" +#include "CcdPhysicsEnvironment.h" + class BP_Proxy; @@ -20,6 +22,7 @@ float gAngularSleepingTreshold = 1.0f; SimdVector3 startVel(0,0,0);//-10000); CcdPhysicsController::CcdPhysicsController (const CcdConstructionInfo& ci) +:m_cci(ci) { m_collisionDelay = 0; m_newClientInfo = 0; @@ -27,6 +30,22 @@ CcdPhysicsController::CcdPhysicsController (const CcdConstructionInfo& ci) m_MotionState = ci.m_MotionState; + m_broadphaseHandle = ci.m_broadphaseHandle; + + m_collisionShape = ci.m_collisionShape; + + CreateRigidbody(); + + + #ifdef WIN32 + if (m_body->getInvMass()) + m_body->setLinearVelocity(startVel); + #endif + +} + +void CcdPhysicsController::CreateRigidbody() +{ SimdTransform trans; float tmp[3]; m_MotionState->getWorldPosition(tmp[0],tmp[1],tmp[2]); @@ -36,31 +55,19 @@ CcdPhysicsController::CcdPhysicsController (const CcdConstructionInfo& ci) m_MotionState->getWorldOrientation(orn[0],orn[1],orn[2],orn[3]); trans.setRotation(orn); - MassProps mp(ci.m_mass, ci.m_localInertiaTensor); + MassProps mp(m_cci.m_mass, m_cci.m_localInertiaTensor); - m_body = new RigidBody(mp,0,0,ci.m_friction,ci.m_restitution); + m_body = new RigidBody(mp,0,0,m_cci.m_friction,m_cci.m_restitution); - m_broadphaseHandle = ci.m_broadphaseHandle; - - m_collisionShape = ci.m_collisionShape; - // // init the rigidbody properly // - m_body->setMassProps(ci.m_mass, ci.m_localInertiaTensor); - m_body->setGravity( ci.m_gravity); - - - m_body->setDamping(ci.m_linearDamping, ci.m_angularDamping); - - + m_body->setMassProps(m_cci.m_mass, m_cci.m_localInertiaTensor); + m_body->setGravity( m_cci.m_gravity); + m_body->setDamping(m_cci.m_linearDamping, m_cci.m_angularDamping); m_body->setCenterOfMassTransform( trans ); - #ifdef WIN32 - if (m_body->getInvMass()) - m_body->setLinearVelocity(startVel); - #endif } @@ -68,6 +75,7 @@ CcdPhysicsController::~CcdPhysicsController() { //will be reference counted, due to sharing //delete m_collisionShape; + m_cci.m_physicsEnv->removeCcdPhysicsController(this); delete m_MotionState; delete m_body; } @@ -109,6 +117,45 @@ void CcdPhysicsController::WriteDynamicsToMotionState() // controller replication void CcdPhysicsController::PostProcessReplica(class PHY_IMotionState* motionstate,class PHY_IPhysicsController* parentctrl) { + + m_MotionState = motionstate; + m_broadphaseHandle = 0; + m_body = 0; + CreateRigidbody(); + + m_cci.m_physicsEnv->addCcdPhysicsController(this); + + +/* SM_Object* dynaparent=0; + SumoPhysicsController* sumoparentctrl = (SumoPhysicsController* )parentctrl; + + if (sumoparentctrl) + { + dynaparent = sumoparentctrl->GetSumoObject(); + } + + SM_Object* orgsumoobject = m_sumoObj; + + + m_sumoObj = new SM_Object( + orgsumoobject->getShapeHandle(), + orgsumoobject->getMaterialProps(), + orgsumoobject->getShapeProps(), + dynaparent); + + m_sumoObj->setRigidBody(orgsumoobject->isRigidBody()); + + m_sumoObj->setMargin(orgsumoobject->getMargin()); + m_sumoObj->setPosition(orgsumoobject->getPosition()); + m_sumoObj->setOrientation(orgsumoobject->getOrientation()); + //if it is a dyna, register for a callback + m_sumoObj->registerCallback(*this); + + m_sumoScene->add(* (m_sumoObj)); + */ + + + } // kinematic methods @@ -269,6 +316,15 @@ void CcdPhysicsController::GetLinearVelocity(float& linvX,float& linvY,float& l linvZ = linvel.z(); } + +void CcdPhysicsController::GetAngularVelocity(float& angVelX,float& angVelY,float& angVelZ) +{ + const SimdVector3& angvel= m_body->getAngularVelocity(); + angVelX = angvel.x(); + angVelY = angvel.y(); + angVelZ = angvel.z(); +} + void CcdPhysicsController::GetVelocity(const float posX,const float posY,const float posZ,float& linvX,float& linvY,float& linvZ) { SimdVector3 pos(posX,posY,posZ); diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h index 4f189b7f324..87290f65fb4 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h @@ -16,6 +16,7 @@ extern float gDeactivationTime; extern float gLinearSleepingTreshold; extern float gAngularSleepingTreshold; extern bool gDisableDeactivation; +class CcdPhysicsEnvironment; struct CcdConstructionInfo @@ -27,7 +28,8 @@ struct CcdConstructionInfo m_linearDamping(0.1f), m_angularDamping(0.1f), m_MotionState(0), - m_collisionShape(0) + m_collisionShape(0), + m_physicsEnv(0) { } @@ -42,7 +44,7 @@ struct CcdConstructionInfo class PHY_IMotionState* m_MotionState; CollisionShape* m_collisionShape; - + CcdPhysicsEnvironment* m_physicsEnv; //needed for self-replication }; @@ -56,8 +58,11 @@ class CcdPhysicsController : public PHY_IPhysicsController CollisionShape* m_collisionShape; void* m_newClientInfo; + CcdConstructionInfo m_cci;//needed for replication void GetWorldOrientation(SimdMatrix3x3& mat); + void CreateRigidbody(); + public: int m_collisionDelay; @@ -110,6 +115,7 @@ class CcdPhysicsController : public PHY_IPhysicsController // reading out information from physics virtual void GetLinearVelocity(float& linvX,float& linvY,float& linvZ); + virtual void GetAngularVelocity(float& angVelX,float& angVelY,float& angVelZ); virtual void GetVelocity(const float posX,const float posY,const float posZ,float& linvX,float& linvY,float& linvZ); virtual void getReactionForce(float& forceX,float& forceY,float& forceZ); diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index c375abbdb16..3a500a833c8 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -226,11 +226,13 @@ void CcdPhysicsEnvironment::removeCcdPhysicsController(CcdPhysicsController* ctr if (removeFromBroadphase) { + } // // only clear the cached algorithms // scene->CleanProxyFromPairs(bp); + scene->DestroyProxy(bp);//?? } { std::vector<CcdPhysicsController*>::iterator i = |