fixed some motionstate synchronization issues
authorErwin Coumans <blender@erwincoumans.com>
Mon, 4 Dec 2006 04:13:42 +0000 (04:13 +0000)
committerErwin Coumans <blender@erwincoumans.com>
Mon, 4 Dec 2006 04:13:42 +0000 (04:13 +0000)
nearsensor was not synchronized at the start
wheels not synchronized properly (one frame delay)

source/gameengine/Ketsji/KX_MotionState.cpp
source/gameengine/Ketsji/KX_NearSensor.cpp
source/gameengine/Ketsji/KX_RadarSensor.cpp
source/gameengine/Ketsji/KX_TouchSensor.cpp
source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp

index 14849ef704c38ab54ca68648874882faec0ab17c..cd01c0466cd6deae80bfe6902813ce04f500a30d 100644 (file)
@@ -73,7 +73,7 @@ void  KX_MotionState::getWorldOrientation(float& quatIma0,float& quatIma1,float&
 void   KX_MotionState::setWorldPosition(float posX,float posY,float posZ)
 {
        m_node->SetLocalPosition(MT_Point3(posX,posY,posZ));
-       //m_node->SetWorldPosition(MT_Point3(posX,posY,posZ));
+       m_node->SetWorldPosition(MT_Point3(posX,posY,posZ));
 }
 
 void   KX_MotionState::setWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal)
@@ -85,7 +85,7 @@ void  KX_MotionState::setWorldOrientation(float quatIma0,float quatIma1,float qua
        orn[3] = quatReal;
 
        m_node->SetLocalOrientation(orn);
-       //m_node->SetWorldOrientation(orn);
+       m_node->SetWorldOrientation(orn);
 
 }
 
index fac2302b85e84bc9a9ab99a3cf91859bdddcc072..34561045cab2e157d7c2724291715b6524bcfa24 100644 (file)
@@ -116,6 +116,7 @@ CValue* KX_NearSensor::GetReplica()
        //replica->m_sumoObj->setMargin(m_Margin);
        //replica->m_sumoObj->setClientObject(replica->m_client_info);
        
+       ((KX_GameObject*)replica->GetParent())->GetSGNode()->ComputeWorldTransforms(NULL);
        replica->SynchronizeTransform();
        
        return replica;
@@ -139,7 +140,7 @@ void KX_NearSensor::ReParent(SCA_IObject* parent)
        client_info->m_sensors.push_back(this);
        SCA_ISensor::ReParent(parent);
 */
-
+       ((KX_GameObject*)GetParent())->GetSGNode()->ComputeWorldTransforms(NULL);
        SynchronizeTransform();
 }
 
index eae9784935c80b0d9149985fef6dc9f69a127eef..5d56eaabb5abad898f28d34858c7d6e0525f6cf7 100644 (file)
@@ -103,6 +103,7 @@ CValue* KX_RadarSensor::GetReplica()
        //replica->m_sumoObj->setMargin(m_Margin);
        //replica->m_sumoObj->setClientObject(replica->m_client_info);
        
+       ((KX_GameObject*)replica->GetParent())->GetSGNode()->ComputeWorldTransforms(NULL);
        replica->SynchronizeTransform();
        
        return replica;
index 3cd5097ebb701c3331da415419a7e223fbbd48bf..5b013e75e4e3799729536dc3d8f8e6b54c08af29 100644 (file)
@@ -54,8 +54,10 @@ void KX_TouchSensor::SynchronizeTransform()
 
        if (m_physCtrl)
        {
-               MT_Vector3 pos = ((KX_GameObject*)GetParent())->NodeGetWorldPosition();
-               MT_Quaternion orn = ((KX_GameObject*)GetParent())->NodeGetWorldOrientation().getRotation();
+
+               KX_GameObject* parent = ((KX_GameObject*)GetParent());
+               MT_Vector3 pos = parent->NodeGetWorldPosition();
+               MT_Quaternion orn = parent->NodeGetWorldOrientation().getRotation();
                m_physCtrl->setPosition(pos.x(),pos.y(),pos.z());
                m_physCtrl->setOrientation(orn.x(),orn.y(),orn.z(),orn.w());
                m_physCtrl->calcXform();
index f6a087887f944b6a3786732061cf27e09b6f7735..3ddac72618db2d88911968826ae907e5ab7ac8f8 100644 (file)
@@ -99,7 +99,7 @@ public:
                m_blenderMotionState->setWorldPosition(worldTrans.getOrigin().getX(),worldTrans.getOrigin().getY(),worldTrans.getOrigin().getZ());
                btQuaternion rotQuat = worldTrans.getRotation();
                m_blenderMotionState->setWorldOrientation(rotQuat[0],rotQuat[1],rotQuat[2],rotQuat[3]);
-
+               m_blenderMotionState->calculateWorldTransformations();
        }
 
 };
index 418271a5c46d3b1afc31da18bc11dbd518a02c16..edd4c2e2bb4a5912e482cc4a4f4ee7b4461ad985 100644 (file)
@@ -108,7 +108,8 @@ public:
                {
                        btWheelInfo& info = m_vehicle->getWheelInfo(i);
                        PHY_IMotionState* motionState = (PHY_IMotionState*)info.m_clientInfo ;
-                       m_vehicle->updateWheelTransform(i,true);
+       //              m_vehicle->updateWheelTransformsWS(info,false);
+                       m_vehicle->updateWheelTransform(i,false);
                        btTransform trans = m_vehicle->getWheelInfo(i).m_worldTransform;
                        btQuaternion orn = trans.getRotation();
                        const btVector3& pos = trans.getOrigin();
@@ -463,7 +464,7 @@ bool        CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep)
        for (i=0;i<numCtrl;i++)
        {
                CcdPhysicsController* ctrl = GetPhysicsController(i);
-               //ctrl->SynchronizeMotionStates(timeStep);
+               ctrl->SynchronizeMotionStates(timeStep);
        }
 
        for (i=0;i<m_wrapperVehicles.size();i++)
@@ -829,6 +830,8 @@ void CcdPhysicsEnvironment::addSensor(PHY_IPhysicsController* ctrl)
        }
        //force collision detection with everything, including static objects (might hurt performance!)
        ctrl1->GetRigidBody()->getBroadphaseHandle()->m_collisionFilterMask = btBroadphaseProxy::AllFilter;
+       ctrl1->GetRigidBody()->getBroadphaseHandle()->m_collisionFilterGroup = btBroadphaseProxy::AllFilter;
+       //todo: make this 'sensor'!
 
        requestCollisionCallback(ctrl);
        //printf("addSensor\n");