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:
authorErwin Coumans <blender@erwincoumans.com>2005-08-22 22:31:19 +0400
committerErwin Coumans <blender@erwincoumans.com>2005-08-22 22:31:19 +0400
commit43b59afebb7b4887028786174978ab551e8cb9d2 (patch)
tree44df649fa62f5a54538575d9780b061b92dfc9d3 /source/gameengine
parent3b8e94ac6b10900825cf0c93aaa2e67d3f4d59a3 (diff)
more preparation for physics recording to ipo keyframes
Diffstat (limited to 'source/gameengine')
-rw-r--r--source/gameengine/Converter/KX_BlenderSceneConverter.cpp69
-rw-r--r--source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp4
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.h62
-rw-r--r--source/gameengine/Ketsji/KX_KetsjiEngine.cpp9
-rw-r--r--source/gameengine/Ketsji/KX_KetsjiEngine.h3
-rw-r--r--source/gameengine/Ketsji/KX_SumoPhysicsController.cpp8
6 files changed, 107 insertions, 48 deletions
diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
index fa716981bd1..b7942fd91a0 100644
--- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
+++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
@@ -39,6 +39,10 @@
#include "KX_IpoConvert.h"
#include "RAS_MeshObject.h"
#include "KX_PhysicsEngineEnums.h"
+#include "PHY_IPhysicsEnvironment.h"
+#include "KX_KetsjiEngine.h"
+#include "Object.h"
+#include "KX_IPhysicsController.h"
#include "DummyPhysicsEnvironment.h"
@@ -73,6 +77,10 @@
#include "DNA_world_types.h"
#include "BKE_main.h"
+#include "DNA_object_types.h"
+#include "DNA_ipo_types.h"
+#include "DNA_curve_types.h"
+
KX_BlenderSceneConverter::KX_BlenderSceneConverter(
struct Main* maggie,
@@ -321,7 +329,9 @@ void KX_BlenderSceneConverter::ConvertScene(const STR_String& scenename,
m_map_blender_to_gameobject.clear();
m_map_mesh_to_gamemesh.clear();
- m_map_gameobject_to_blender.clear();
+
+ //don't clear it yet, it is needed for the baking physics into ipo animation
+ //m_map_gameobject_to_blender.clear();
}
@@ -466,6 +476,50 @@ void KX_BlenderSceneConverter::RegisterWorldInfo(
void KX_BlenderSceneConverter::ResetPhysicsObjectsAnimationIpo()
{
//todo,before 2.38/2.40 release, Erwin
+
+ KX_SceneList* scenes = m_ketsjiEngine->CurrentScenes();
+ int numScenes = scenes->size();
+ int i;
+ for (i=0;i<numScenes;i++)
+ {
+ KX_Scene* scene = scenes->at(i);
+ //PHY_IPhysicsEnvironment* physEnv = scene->GetPhysicsEnvironment();
+ CListValue* parentList = scene->GetRootParentList();
+ int numObjects = parentList->GetCount();
+ int g;
+ for (g=0;g<numObjects;g++)
+ {
+ KX_GameObject* gameObj = (KX_GameObject*)parentList->GetValue(g);
+ if (gameObj->IsDynamic())
+ {
+ //KX_IPhysicsController* physCtrl = gameObj->GetPhysicsController();
+
+ Object* blenderObject = FindBlenderObject(gameObj);
+ if (blenderObject)
+ {
+ //erase existing ipo's
+ Ipo* ipo = blenderObject->ipo;
+ if (ipo)
+ {
+
+ IpoCurve *icu;
+ int numCurves = 0;
+ for( icu = (IpoCurve*)ipo->curve.first; icu; icu = icu->next ) {
+ numCurves++;
+
+ }
+
+ }
+ }
+ }
+
+ }
+
+
+ }
+
+
+
}
///this generates ipo curves for position, rotation, allowing to use game physics in animation
@@ -596,6 +650,19 @@ void KX_BlenderSceneConverter::WritePhysicsObjectToAnimationIpo(int frameNumber)
return IpoCurve_CreatePyObject( icu );
}
+ static PyObject *Ipo_getNcurves( BPy_Ipo * self )
+ {
+ int i = 0;
+
+ IpoCurve *icu;
+ for( icu = self->ipo->curve.first; icu; icu = icu->next ) {
+ i++;
+ }
+
+ return ( PyInt_FromLong( i ) );
+ }
+
+
static PyObject *Ipo_getNBezPoints( BPy_Ipo * self, PyObject * args )
{
int num = 0, i = 0;
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());
}