[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20952] trunk/blender/source/gameengine/ Physics/Sumo: BGE #18823: Loading older blend files ( from the blender Gamekit 1.0 demos) that use Sumo crash on playback in 2.48 .5, worked in rc3.
Benoit Bolsee
benoit.bolsee at online.be
Wed Jun 17 10:36:37 CEST 2009
Revision: 20952
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20952
Author: ben2610
Date: 2009-06-17 10:36:37 +0200 (Wed, 17 Jun 2009)
Log Message:
-----------
BGE #18823: Loading older blend files (from the blender Gamekit 1.0 demos) that use Sumo crash on playback in 2.48.5, worked in rc3. Fixed by upgrading Sumo to support the new method of sensor synchronization introduced with Sensor objects in Bullet. Sumo demo will not crash but may still not run well as other features and methods have not been ported.
Modified Paths:
--------------
trunk/blender/source/gameengine/Physics/Sumo/SumoPhysicsController.cpp
trunk/blender/source/gameengine/Physics/Sumo/SumoPhysicsController.h
trunk/blender/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp
Modified: trunk/blender/source/gameengine/Physics/Sumo/SumoPhysicsController.cpp
===================================================================
--- trunk/blender/source/gameengine/Physics/Sumo/SumoPhysicsController.cpp 2009-06-17 07:38:07 UTC (rev 20951)
+++ trunk/blender/source/gameengine/Physics/Sumo/SumoPhysicsController.cpp 2009-06-17 08:36:37 UTC (rev 20952)
@@ -402,7 +402,13 @@
void SumoPhysicsController::WriteMotionStateToDynamics(bool)
{
-
+ float tmp[4];
+ m_MotionState->getWorldPosition(tmp[0], tmp[1], tmp[2]);
+ MT_Point3 pos(tmp);
+ m_sumoObj->setPosition(pos);
+ m_MotionState->getWorldOrientation(tmp[0], tmp[1], tmp[2], tmp[3]);
+ MT_Quaternion quat(tmp);
+ m_sumoObj->setOrientation(quat);
}
// this is the actual callback from sumo, and the position/orientation
//is written to the scenegraph, using the motionstate abstraction
@@ -493,3 +499,70 @@
return 0.f;
}
+
+///////////////////////////////////////////////////////////
+///A small utility class, SumoDefaultMotionState
+///
+///////////////////////////////////////////////////////////
+
+SumoDefaultMotionState::SumoDefaultMotionState()
+{
+ m_worldTransform.setIdentity();
+ m_localScaling.setValue(1.f,1.f,1.f);
+}
+
+
+SumoDefaultMotionState::~SumoDefaultMotionState()
+{
+
+}
+
+void SumoDefaultMotionState::getWorldPosition(float& posX,float& posY,float& posZ)
+{
+ posX = m_worldTransform.getOrigin().x();
+ posY = m_worldTransform.getOrigin().y();
+ posZ = m_worldTransform.getOrigin().z();
+}
+
+void SumoDefaultMotionState::getWorldScaling(float& scaleX,float& scaleY,float& scaleZ)
+{
+ scaleX = m_localScaling.x();
+ scaleY = m_localScaling.y();
+ scaleZ = m_localScaling.z();
+}
+
+void SumoDefaultMotionState::getWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal)
+{
+ MT_Quaternion quat = m_worldTransform.getRotation();
+ quatIma0 = quat.x();
+ quatIma1 = quat.y();
+ quatIma2 = quat.z();
+ quatReal = quat.w();
+}
+
+void SumoDefaultMotionState::getWorldOrientation(float* ori)
+{
+ m_worldTransform.getBasis().getValue(ori);
+}
+
+void SumoDefaultMotionState::setWorldOrientation(const float* ori)
+{
+ m_worldTransform.getBasis().setValue(ori);
+}
+void SumoDefaultMotionState::setWorldPosition(float posX,float posY,float posZ)
+{
+ MT_Point3 pos(posX,posY,posZ);
+ m_worldTransform.setOrigin( pos );
+}
+
+void SumoDefaultMotionState::setWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal)
+{
+ MT_Quaternion orn(quatIma0,quatIma1,quatIma2,quatReal);
+ m_worldTransform.setRotation( orn );
+}
+
+void SumoDefaultMotionState::calculateWorldTransformations()
+{
+
+}
+
Modified: trunk/blender/source/gameengine/Physics/Sumo/SumoPhysicsController.h
===================================================================
--- trunk/blender/source/gameengine/Physics/Sumo/SumoPhysicsController.h 2009-06-17 07:38:07 UTC (rev 20951)
+++ trunk/blender/source/gameengine/Physics/Sumo/SumoPhysicsController.h 2009-06-17 08:36:37 UTC (rev 20952)
@@ -30,6 +30,7 @@
#define __SUMO_PHYSICSCONTROLLER_H
#include "PHY_IPhysicsController.h"
+#include "PHY_IMotionState.h"
#include "SM_Scene.h"
#include "SM_Callback.h"
@@ -188,5 +189,30 @@
};
+///SumoDefaultMotionState implements standard motionstate, using btTransform
+class SumoDefaultMotionState : public PHY_IMotionState
+
+{
+ public:
+ SumoDefaultMotionState();
+
+ virtual ~SumoDefaultMotionState();
+
+ virtual void getWorldPosition(float& posX,float& posY,float& posZ);
+ virtual void getWorldScaling(float& scaleX,float& scaleY,float& scaleZ);
+ virtual void getWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal);
+
+ virtual void setWorldPosition(float posX,float posY,float posZ);
+ virtual void setWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal);
+ virtual void getWorldOrientation(float* ori);
+ virtual void setWorldOrientation(const float* ori);
+
+ virtual void calculateWorldTransformations();
+
+ MT_Transform m_worldTransform;
+ MT_Vector3 m_localScaling;
+
+};
+
#endif //__SUMO_PHYSICSCONTROLLER_H
Modified: trunk/blender/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp
===================================================================
--- trunk/blender/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp 2009-06-17 07:38:07 UTC (rev 20951)
+++ trunk/blender/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp 2009-06-17 08:36:37 UTC (rev 20952)
@@ -244,8 +244,8 @@
//testing
MT_Quaternion rotquatje(MT_Vector3(0,0,1),MT_radians(90));
ob->setOrientation(rotquatje);
-
- PHY_IPhysicsController* ctrl = new SumoPhysicsController(m_sumoScene,ob,0,false);
+ PHY_IMotionState* motionState = new SumoDefaultMotionState();
+ PHY_IPhysicsController* ctrl = new SumoPhysicsController(m_sumoScene,ob,motionState,false);
ctrl->SetMargin(radius);
return ctrl;
}
@@ -256,8 +256,9 @@
ob->setPosition(MT_Point3(0.f,0.f,0.f));
MT_Quaternion rotquatje(MT_Vector3(0,0,1),MT_radians(90));
ob->setOrientation(rotquatje);
+ PHY_IMotionState* motionState = new SumoDefaultMotionState();
- PHY_IPhysicsController* ctrl = new SumoPhysicsController(m_sumoScene,ob,0,false);
+ PHY_IPhysicsController* ctrl = new SumoPhysicsController(m_sumoScene,ob,motionState,false);
return ctrl;
}
More information about the Bf-blender-cvs
mailing list