diff options
Diffstat (limited to 'source/gameengine/Ketsji')
-rw-r--r-- | source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp | 4 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_GameObject.h | 62 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 9 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_KetsjiEngine.h | 3 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_SumoPhysicsController.cpp | 8 |
5 files changed, 39 insertions, 47 deletions
diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index cedd689e85f..b5aea65cfe4 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -305,7 +305,7 @@ static void BL_RegisterSumoObject( // need easy access, not via 'node' etc. KX_SumoPhysicsController* physicscontroller = new KX_SumoPhysicsController(sumoScene,sumoObj,motionstate,isDynamic); - gameobj->SetPhysicsController(physicscontroller); + gameobj->SetPhysicsController(physicscontroller,isDynamic); if (!gameobj->getClientInfo()) @@ -1012,7 +1012,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, env->addCcdPhysicsController( physicscontroller); - gameobj->SetPhysicsController(physicscontroller); + gameobj->SetPhysicsController(physicscontroller,dyna); physicscontroller->setNewClientInfo(gameobj->getClientInfo()); bool isActor = objprop->m_isactor; gameobj->getClientInfo()->m_type = (isActor ? KX_ClientObjectInfo::ACTOR : KX_ClientObjectInfo::STATIC); diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index fa116795ef4..34628897af7 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -265,38 +265,26 @@ public: * @return a pointer to the physics controller owned by this class. */ - KX_IPhysicsController* - GetPhysicsController( - ) ; + KX_IPhysicsController* GetPhysicsController() ; - void SetPhysicsController - (KX_IPhysicsController* physicscontroller) - { m_pPhysicsController1 = physicscontroller;}; + void SetPhysicsController(KX_IPhysicsController* physicscontroller,bool isDynamic) + { + m_bDyna = isDynamic; + m_pPhysicsController1 = physicscontroller; + } /** * @section Coordinate system manipulation functions */ - void - NodeSetLocalPosition( - const MT_Point3& trans - ); + void NodeSetLocalPosition(const MT_Point3& trans ); - void - NodeSetLocalOrientation( - const MT_Matrix3x3& rot - ); + void NodeSetLocalOrientation(const MT_Matrix3x3& rot ); - void - NodeSetLocalScale( - const MT_Vector3& scale - ); + void NodeSetLocalScale( const MT_Vector3& scale ); - void - NodeSetRelativeScale( - const MT_Vector3& scale - ); + void NodeSetRelativeScale( const MT_Vector3& scale ); void NodeUpdateGS( @@ -324,16 +312,13 @@ public: * @section scene graph node accessor functions. */ - SG_Node* - GetSGNode( - ) { + SG_Node* GetSGNode( ) + { return m_pSGNode; } - const - SG_Node* - GetSGNode( - ) const { + const SG_Node* GetSGNode( ) const + { return m_pSGNode; } @@ -345,19 +330,14 @@ public: * old node. This class takes ownership of the new * node. */ - void - SetSGNode( - SG_Node* node - ){ - m_pSGNode = node; - } + void SetSGNode(SG_Node* node ) + { + m_pSGNode = node; + } - /** - * Deprecated & broken - */ - bool - IsDynamic( - ) const { + //Is it a dynamic/physics object ? + bool IsDynamic() const + { return m_bDyna; } diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 10bf70849bf..24c34976ce8 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -258,6 +258,10 @@ void KX_KetsjiEngine::StartEngine() m_firstframe = true; m_bInitialized = true; m_ticrate = DEFAULT_LOGIC_TIC_RATE; + m_currentFrame = 0; + + m_sceneconverter->ResetPhysicsObjectsAnimationIpo(); + } bool KX_KetsjiEngine::BeginFrame() @@ -305,6 +309,8 @@ void KX_KetsjiEngine::EndFrame() m_rendertools->EndFrame(m_rasterizer); m_canvas->EndDraw(); + + } @@ -390,6 +396,9 @@ void KX_KetsjiEngine::NextFrame() m_logger->StartLog(tc_physics, m_kxsystem->GetTimeInSeconds(), true); scene->GetPhysicsEnvironment()->proceedDeltaTime(localtime,realDeltaTime); m_previoustime = curtime; + + m_sceneconverter->WritePhysicsObjectToAnimationIpo(m_currentFrame++); + } // suspended DoSound(scene); diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h index 8ea611298e7..5af694f5f1f 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.h +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.h @@ -97,7 +97,8 @@ private: bool m_bFixedTime; bool m_firstframe; - + int m_currentFrame; + double m_previoustime; double m_deltatime; static double m_ticrate; diff --git a/source/gameengine/Ketsji/KX_SumoPhysicsController.cpp b/source/gameengine/Ketsji/KX_SumoPhysicsController.cpp index a062a348b02..11a09a12e1e 100644 --- a/source/gameengine/Ketsji/KX_SumoPhysicsController.cpp +++ b/source/gameengine/Ketsji/KX_SumoPhysicsController.cpp @@ -157,9 +157,11 @@ void KX_SumoPhysicsController::SetObject (SG_IObject* object) SG_Controller::SetObject(object); // cheating here... - KX_GameObject* gameobj = (KX_GameObject*) object->GetSGClientObject(); - gameobj->SetPhysicsController(this); - GetSumoObject()->setClientObject(gameobj->getClientInfo()); +//should not be necessary, is it for duplicates ? + +KX_GameObject* gameobj = (KX_GameObject*) object->GetSGClientObject(); +gameobj->SetPhysicsController(this,gameobj->IsDynamic()); +GetSumoObject()->setClientObject(gameobj->getClientInfo()); } |