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:
authorBenoit Bolsee <benoit.bolsee@online.be>2009-05-17 16:51:51 +0400
committerBenoit Bolsee <benoit.bolsee@online.be>2009-05-17 16:51:51 +0400
commit3ea1c1b4b640b18e651de7eacb40bb7cc7a2f55f (patch)
tree50cc6a424bc29abbd4dcfe5a81d35bfb7172deb0
parent96aa60cee36dfb8a98501b6b9d4c88222b909c35 (diff)
BGE: new sensor object to generalize Near and Radar sensor, static-static collision capbility.
A new type of "Sensor" physics object is available in the GE for advanced collision management. It's called Sensor for its similarities with the physics objects that underlie the Near and Radar sensors. Like the Near and Radar object it is: - static and ghost - invisible by default - always active to ensure correct collision detection - capable of detecting both static and dynamic objects - ignoring collision with their parent - capable of broadphase filtering based on: * Actor option: the collisioning object must have the Actor flag set to be detected * property/material: as specified in the collision sensors attached to it Broadphase filtering is important for performance reason: the collision points will be computed only for the objects that pass the broahphase filter. - automatically removed from the simulation when no collision sensor is active on it Unlike the Near and Radar object it can: - take any shape, including triangle mesh - be made visible for debugging (just use the Visible actuator) - have multiple collision sensors using it Other than that, the sensor objects are ordinary objects. You can move them freely or parent them. When parented to a dynamic object, they can provide advanced collision control to this object. The type of collision capability depends on the shape: - box, sphere, cylinder, cone, convex hull provide volume detection. - triangle mesh provides surface detection but you can give some volume to the suface by increasing the margin in the Advanced Settings panel. The margin applies on both sides of the surface. Performance tip: - Sensor objects perform better than Near and Radar: they do less synchronizations because of the Scenegraph optimizations and they can have multiple collision sensors on them (with different property filtering for example). - Always prefer simple shape (box, sphere) to complex shape whenever possible. - Always use broadphase filtering (avoid collision sensor with empty propery/material) - Use collision sensor only when you need them. When no collision sensor is active on the sensor object, it is removed from the simulation and consume no CPU. Known limitations: - When running Blender in debug mode, you will see one warning line of the console: "warning btCollisionDispatcher::needsCollision: static-static collision!" In release mode this message is not printed. - Collision margin has no effect on sphere, cone and cylinder shape. Other performance improvements: - Remove unnecessary interpolation for Near and Radar objects and by extension sensor objects. - Use direct matrix copy instead of quaternion to synchronize orientation. Other bug fix: - Fix Near/Radar position error on newly activated objects. This was causing several detection problems in YoFrankie - Fix margin not passed correctly to gImpact shape. - Disable force/velocity actions on static objects
-rw-r--r--source/blender/makesdna/DNA_object_types.h2
-rw-r--r--source/blender/python/api2_2x/Object.c3
-rw-r--r--source/blender/src/buttons_logic.c82
-rw-r--r--source/gameengine/Converter/BL_BlenderDataConversion.cpp1
-rw-r--r--source/gameengine/GameLogic/SCA_ISensor.h11
-rw-r--r--source/gameengine/Ketsji/KX_BulletPhysicsController.cpp24
-rw-r--r--source/gameengine/Ketsji/KX_BulletPhysicsController.h3
-rw-r--r--source/gameengine/Ketsji/KX_ClientObjectInfo.h5
-rw-r--r--source/gameengine/Ketsji/KX_ConvertPhysicsObject.h1
-rw-r--r--source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp54
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.cpp26
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.h9
-rw-r--r--source/gameengine/Ketsji/KX_IPhysicsController.cpp3
-rw-r--r--source/gameengine/Ketsji/KX_IPhysicsController.h12
-rw-r--r--source/gameengine/Ketsji/KX_MotionState.cpp5
-rw-r--r--source/gameengine/Ketsji/KX_MotionState.h1
-rw-r--r--source/gameengine/Ketsji/KX_NearSensor.cpp35
-rw-r--r--source/gameengine/Ketsji/KX_NearSensor.h4
-rw-r--r--source/gameengine/Ketsji/KX_OdePhysicsController.h1
-rw-r--r--source/gameengine/Ketsji/KX_RadarSensor.cpp21
-rw-r--r--source/gameengine/Ketsji/KX_RadarSensor.h2
-rw-r--r--source/gameengine/Ketsji/KX_Scene.cpp4
-rw-r--r--source/gameengine/Ketsji/KX_SumoPhysicsController.h3
-rw-r--r--source/gameengine/Ketsji/KX_TouchEventManager.cpp34
-rw-r--r--source/gameengine/Ketsji/KX_TouchSensor.cpp58
-rw-r--r--source/gameengine/Ketsji/KX_TouchSensor.h3
-rw-r--r--source/gameengine/Physics/BlOde/OdePhysicsController.cpp5
-rw-r--r--source/gameengine/Physics/BlOde/OdePhysicsController.h1
-rw-r--r--source/gameengine/Physics/BlOde/OdePhysicsEnvironment.h4
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsController.cpp199
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsController.h14
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp87
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h4
-rw-r--r--source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h4
-rw-r--r--source/gameengine/Physics/Sumo/SumoPhysicsController.cpp5
-rw-r--r--source/gameengine/Physics/Sumo/SumoPhysicsController.h1
-rw-r--r--source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp7
-rw-r--r--source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h4
-rw-r--r--source/gameengine/Physics/common/PHY_IMotionState.h2
-rw-r--r--source/gameengine/Physics/common/PHY_IPhysicsController.h3
-rw-r--r--source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h4
-rw-r--r--source/gameengine/SceneGraph/SG_IObject.h7
-rw-r--r--source/gameengine/SceneGraph/SG_Spatial.h7
43 files changed, 464 insertions, 301 deletions
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index 82da883df4a..9121f38be16 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -440,6 +440,7 @@ extern Object workob;
#define OB_COLLISION 65536
#define OB_SOFT_BODY 0x20000
#define OB_OCCLUDER 0x40000
+#define OB_SENSOR 0x80000
/* ob->gameflag2 */
#define OB_NEVER_DO_ACTIVITY_CULLING 1
@@ -459,6 +460,7 @@ extern Object workob;
#define OB_BODY_TYPE_RIGID 3
#define OB_BODY_TYPE_SOFT 4
#define OB_BODY_TYPE_OCCLUDER 5
+#define OB_BODY_TYPE_SENSOR 6
/* ob->scavisflag */
#define OB_VIS_SENS 1
diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c
index 2de2906335f..c3f7a21a7bf 100644
--- a/source/blender/python/api2_2x/Object.c
+++ b/source/blender/python/api2_2x/Object.c
@@ -3562,7 +3562,7 @@ static int Object_setRBMass( BPy_Object * self, PyObject * args )
/* this is too low level, possible to add helper methods */
#define GAMEFLAG_MASK ( OB_OCCLUDER | OB_COLLISION | OB_DYNAMIC | OB_CHILD | OB_ACTOR | OB_DO_FH | \
- OB_ROT_FH | OB_ANISOTROPIC_FRICTION | OB_GHOST | OB_RIGID_BODY | OB_SOFT_BODY | \
+ OB_ROT_FH | OB_ANISOTROPIC_FRICTION | OB_GHOST | OB_RIGID_BODY | OB_SOFT_BODY | OB_SENSOR | \
OB_BOUNDS | OB_COLLISION_RESPONSE | OB_SECTOR | OB_PROP | \
OB_MAINACTOR )
@@ -5544,6 +5544,7 @@ static PyObject *M_Object_RBFlagsDict( void )
BPy_constant *d = ( BPy_constant * ) M;
PyConstant_Insert( d, "OCCLUDER", PyInt_FromLong( OB_OCCLUDER ) );
PyConstant_Insert( d, "COLLISION", PyInt_FromLong( OB_COLLISION ) );
+ PyConstant_Insert( d, "SENSOR", PyInt_FromLong( OB_SENSOR ) );
PyConstant_Insert( d, "DYNAMIC", PyInt_FromLong( OB_DYNAMIC ) );
PyConstant_Insert( d, "CHILD", PyInt_FromLong( OB_CHILD ) );
PyConstant_Insert( d, "ACTOR", PyInt_FromLong( OB_ACTOR ) );
diff --git a/source/blender/src/buttons_logic.c b/source/blender/src/buttons_logic.c
index dccbc73787d..a537d32feae 100644
--- a/source/blender/src/buttons_logic.c
+++ b/source/blender/src/buttons_logic.c
@@ -3064,29 +3064,33 @@ static void check_body_type(void *arg1_but, void *arg2_object)
Object *ob = arg2_object;
switch (ob->body_type) {
+ case OB_BODY_TYPE_SENSOR:
+ ob->gameflag |= OB_SENSOR|OB_COLLISION|OB_GHOST;
+ ob->gameflag &= ~(OB_OCCLUDER|OB_DYNAMIC|OB_RIGID_BODY|OB_ACTOR|OB_ANISOTROPIC_FRICTION|OB_DO_FH|OB_ROT_FH|OB_COLLISION_RESPONSE);
+ break;
case OB_BODY_TYPE_OCCLUDER:
ob->gameflag |= OB_OCCLUDER;
- ob->gameflag &= ~(OB_COLLISION|OB_DYNAMIC);
+ ob->gameflag &= ~(OB_SENSOR|OB_COLLISION|OB_DYNAMIC);
break;
case OB_BODY_TYPE_NO_COLLISION:
- ob->gameflag &= ~(OB_COLLISION|OB_OCCLUDER|OB_DYNAMIC);
+ ob->gameflag &= ~(OB_SENSOR|OB_COLLISION|OB_OCCLUDER|OB_DYNAMIC);
break;
case OB_BODY_TYPE_STATIC:
ob->gameflag |= OB_COLLISION;
- ob->gameflag &= ~(OB_DYNAMIC|OB_RIGID_BODY|OB_SOFT_BODY|OB_OCCLUDER);
+ ob->gameflag &= ~(OB_DYNAMIC|OB_RIGID_BODY|OB_SOFT_BODY|OB_OCCLUDER|OB_SENSOR);
break;
case OB_BODY_TYPE_DYNAMIC:
ob->gameflag |= OB_COLLISION|OB_DYNAMIC|OB_ACTOR;
- ob->gameflag &= ~(OB_RIGID_BODY|OB_SOFT_BODY|OB_OCCLUDER);
+ ob->gameflag &= ~(OB_RIGID_BODY|OB_SOFT_BODY|OB_OCCLUDER|OB_SENSOR);
break;
case OB_BODY_TYPE_RIGID:
ob->gameflag |= OB_COLLISION|OB_DYNAMIC|OB_RIGID_BODY|OB_ACTOR;
- ob->gameflag &= ~(OB_SOFT_BODY|OB_OCCLUDER);
+ ob->gameflag &= ~(OB_SOFT_BODY|OB_OCCLUDER|OB_SENSOR);
break;
default:
case OB_BODY_TYPE_SOFT:
ob->gameflag |= OB_COLLISION|OB_DYNAMIC|OB_SOFT_BODY|OB_ACTOR;
- ob->gameflag &= ~(OB_RIGID_BODY|OB_OCCLUDER);
+ ob->gameflag &= ~(OB_RIGID_BODY|OB_OCCLUDER|OB_SENSOR);
/* assume triangle mesh, if no bounds chosen for soft body */
if ((ob->gameflag & OB_BOUNDS) && (ob->boundtype<OB_BOUND_POLYH))
@@ -3271,17 +3275,31 @@ static uiBlock *advanced_bullet_menu(void *arg_ob)
static void buttons_bullet(uiBlock *block, Object *ob)
{
uiBut *but;
+ char *tip;
/* determine the body_type setting based on flags */
- if (!(ob->gameflag & OB_COLLISION))
- ob->body_type = (ob->gameflag & OB_OCCLUDER) ? OB_BODY_TYPE_OCCLUDER : OB_BODY_TYPE_NO_COLLISION;
- else if (!(ob->gameflag & OB_DYNAMIC))
+ if (!(ob->gameflag & OB_COLLISION)) {
+ if (ob->gameflag & OB_OCCLUDER) {
+ tip = "Occluder";
+ ob->body_type = OB_BODY_TYPE_OCCLUDER;
+ } else {
+ tip = "Disable colision for this object";
+ ob->body_type = OB_BODY_TYPE_NO_COLLISION;
+ }
+ } else if (ob->gameflag & OB_SENSOR) {
+ tip = "Collision Sensor, detects static and dynamic objects but not the other collision sensor objects";
+ ob->body_type = OB_BODY_TYPE_SENSOR;
+ } else if (!(ob->gameflag & OB_DYNAMIC)) {
+ tip = "Static";
ob->body_type = OB_BODY_TYPE_STATIC;
- else if (!(ob->gameflag & (OB_RIGID_BODY|OB_SOFT_BODY)))
+ } else if (!(ob->gameflag & (OB_RIGID_BODY|OB_SOFT_BODY))) {
+ tip = "Dynamic";
ob->body_type = OB_BODY_TYPE_DYNAMIC;
- else if (ob->gameflag & OB_RIGID_BODY)
+ } else if (ob->gameflag & OB_RIGID_BODY) {
+ tip = "Rigid body";
ob->body_type = OB_BODY_TYPE_RIGID;
- else {
+ } else {
+ tip = "Soft body";
ob->body_type = OB_BODY_TYPE_SOFT;
/* create the structure here because we display soft body buttons in the main panel */
if (!ob->bsoft)
@@ -3292,28 +3310,36 @@ static void buttons_bullet(uiBlock *block, Object *ob)
//only enable game soft body if Blender Soft Body exists
but = uiDefButS(block, MENU, REDRAWVIEW3D,
- "Object type%t|Occluder%x5|No collision%x0|Static%x1|Dynamic%x2|Rigid body%x3|Soft body%x4",
- 10, 205, 100, 19, &ob->body_type, 0, 0, 0, 0, "Selects the type of physical representation");
+ "Object type%t|Occluder%x5|No collision%x0|Sensor%x6|Static%x1|Dynamic%x2|Rigid body%x3|Soft body%x4",
+ 10, 205, 100, 19, &ob->body_type, 0, 0, 0, 0, tip);
uiButSetFunc(but, check_body_type, but, ob);
if (ob->gameflag & OB_COLLISION) {
- uiDefButBitI(block, TOG, OB_ACTOR, 0, "Actor",
- 110, 205, 50, 19, &ob->gameflag, 0, 0, 0, 0,
- "Objects that are detected by the Near and Radar sensor");
+ if (ob->gameflag & OB_SENSOR) {
+ uiBlockEndAlign(block);
+ uiDefBlockBut(block, advanced_bullet_menu, ob,
+ "Advanced Settings",
+ 210, 205, 140, 19, "Display collision advanced settings");
+ uiBlockBeginAlign(block);
+ } else {
+ uiDefButBitI(block, TOG, OB_ACTOR, 0, "Actor",
+ 110, 205, 50, 19, &ob->gameflag, 0, 0, 0, 0,
+ "Objects that are detected by the Near and Radar sensor and the collision sensor objects");
-
+
- uiDefButBitI(block, TOG, OB_GHOST, B_REDR, "Ghost",
- 160,205,50,19,
- &ob->gameflag, 0, 0, 0, 0,
- "Objects that don't restitute collisions (like a ghost)");
+ uiDefButBitI(block, TOG, OB_GHOST, B_REDR, "Ghost",
+ 160,205,50,19,
+ &ob->gameflag, 0, 0, 0, 0,
+ "Objects that don't restitute collisions (like a ghost)");
- //uiBlockSetCol(block, TH_BUT_SETTING1);
- uiDefBlockBut(block, advanced_bullet_menu, ob,
- "Advanced Settings",
- 210, 205, 140, 19, "Display collision advanced settings");
- //uiBlockSetCol(block, TH_BUT_SETTING2);
+ //uiBlockSetCol(block, TH_BUT_SETTING1);
+ uiDefBlockBut(block, advanced_bullet_menu, ob,
+ "Advanced Settings",
+ 210, 205, 140, 19, "Display collision advanced settings");
+ //uiBlockSetCol(block, TH_BUT_SETTING2);
+ }
if(ob->gameflag & OB_DYNAMIC) {
@@ -3394,7 +3420,7 @@ static void buttons_bullet(uiBlock *block, Object *ob)
/* In Bullet, anisotripic friction can be applied to static objects as well, just not soft bodies */
- if (!(ob->gameflag & OB_SOFT_BODY))
+ if (!(ob->gameflag & (OB_SOFT_BODY|OB_SENSOR)))
{
uiDefButBitI(block, TOG, OB_ANISOTROPIC_FRICTION, B_REDR, "Anisotropic",
230, 145, 120, 19,
diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
index 9ea623f17e4..d4cc047d5e3 100644
--- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp
+++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
@@ -1413,6 +1413,7 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj,
objprop.m_dyna = (blenderobject->gameflag & OB_DYNAMIC) != 0;
objprop.m_softbody = (blenderobject->gameflag & OB_SOFT_BODY) != 0;
objprop.m_angular_rigidbody = (blenderobject->gameflag & OB_RIGID_BODY) != 0;
+ objprop.m_sensor = (blenderobject->gameflag & OB_SENSOR) != 0;
if (objprop.m_softbody)
{
diff --git a/source/gameengine/GameLogic/SCA_ISensor.h b/source/gameengine/GameLogic/SCA_ISensor.h
index 9aeda728caf..ad8865299d6 100644
--- a/source/gameengine/GameLogic/SCA_ISensor.h
+++ b/source/gameengine/GameLogic/SCA_ISensor.h
@@ -91,6 +91,15 @@ protected:
std::vector<class SCA_IController*> m_linkedcontrollers;
public:
+
+ enum sensortype {
+ NONE = 0,
+ TOUCH,
+ NEAR,
+ RADAR,
+ // to be updated as needed
+ };
+
SCA_ISensor(SCA_IObject* gameobj,
class SCA_EventManager* eventmgr,
PyTypeObject* T );;
@@ -138,6 +147,8 @@ public:
virtual double GetNumber();
+ virtual sensortype GetSensorType() { return NONE; }
+
/** Stop sensing for a while. */
void Suspend();
diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp
index 300a7906e81..e22edfd1306 100644
--- a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp
+++ b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp
@@ -17,8 +17,8 @@
#include "BulletSoftBody/btSoftBody.h"
-KX_BulletPhysicsController::KX_BulletPhysicsController (const CcdConstructionInfo& ci, bool dyna, bool compound)
-: KX_IPhysicsController(dyna,compound,(PHY_IPhysicsController*)this),
+KX_BulletPhysicsController::KX_BulletPhysicsController (const CcdConstructionInfo& ci, bool dyna, bool sensor, bool compound)
+: KX_IPhysicsController(dyna,sensor,compound,(PHY_IPhysicsController*)this),
CcdPhysicsController(ci),
m_savedCollisionFlags(0),
m_savedCollisionFilterGroup(0),
@@ -174,6 +174,20 @@ void KX_BulletPhysicsController::setScaling(const MT_Vector3& scaling)
{
CcdPhysicsController::setScaling(scaling.x(),scaling.y(),scaling.z());
}
+void KX_BulletPhysicsController::SetTransform()
+{
+ btVector3 pos;
+ btVector3 scale;
+ float ori[12];
+ m_MotionState->getWorldPosition(pos.m_floats[0],pos.m_floats[1],pos.m_floats[2]);
+ m_MotionState->getWorldScaling(scale.m_floats[0],scale.m_floats[1],scale.m_floats[2]);
+ m_MotionState->getWorldOrientation(ori);
+ btMatrix3x3 rot(ori[0], ori[4], ori[8],
+ ori[1], ori[5], ori[9],
+ ori[2], ori[6], ori[10]);
+ CcdPhysicsController::forceWorldTransform(rot, pos);
+}
+
MT_Scalar KX_BulletPhysicsController::GetMass()
{
if (GetSoftBody())
@@ -262,7 +276,7 @@ void KX_BulletPhysicsController::AddCompoundChild(KX_IPhysicsController* chil
// add to parent compound shapeinfo
GetShapeInfo()->AddShape(proxyShapeInfo);
// create new bullet collision shape from the object shapeinfo and set scaling
- btCollisionShape* newChildShape = proxyShapeInfo->CreateBulletShape();
+ btCollisionShape* newChildShape = proxyShapeInfo->CreateBulletShape(childCtrl->GetMargin());
newChildShape->setLocalScaling(relativeScale);
// add bullet collision shape to parent compound collision shape
compoundShape->addChildShape(proxyShapeInfo->m_childTrans,newChildShape);
@@ -359,7 +373,7 @@ void KX_BulletPhysicsController::SetMass(MT_Scalar newmass)
void KX_BulletPhysicsController::SuspendDynamics(bool ghost)
{
btRigidBody *body = GetRigidBody();
- if (body && !m_suspended)
+ if (body && !m_suspended && !IsSensor())
{
btBroadphaseProxy* handle = body->getBroadphaseHandle();
m_savedCollisionFlags = body->getCollisionFlags();
@@ -445,7 +459,7 @@ SG_Controller* KX_BulletPhysicsController::GetReplica(class SG_Node* destnode)
void KX_BulletPhysicsController::SetSumoTransform(bool nondynaonly)
{
- if (!m_bDyna)
+ if (!m_bDyna && !m_bSensor)
{
btCollisionObject* object = GetRigidBody();
object->setActivationState(ACTIVE_TAG);
diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.h b/source/gameengine/Ketsji/KX_BulletPhysicsController.h
index 9d2afad1a5c..755b1cbd780 100644
--- a/source/gameengine/Ketsji/KX_BulletPhysicsController.h
+++ b/source/gameengine/Ketsji/KX_BulletPhysicsController.h
@@ -19,7 +19,7 @@ private:
public:
- KX_BulletPhysicsController (const CcdConstructionInfo& ci, bool dyna, bool compound);
+ KX_BulletPhysicsController (const CcdConstructionInfo& ci, bool dyna, bool sensor, bool compound);
virtual ~KX_BulletPhysicsController ();
///////////////////////////////////
@@ -42,6 +42,7 @@ public:
virtual void setOrientation(const MT_Matrix3x3& orn);
virtual void setPosition(const MT_Point3& pos);
virtual void setScaling(const MT_Vector3& scaling);
+ virtual void SetTransform();
virtual MT_Scalar GetMass();
virtual void SetMass(MT_Scalar newmass);
virtual MT_Vector3 GetLocalInertia();
diff --git a/source/gameengine/Ketsji/KX_ClientObjectInfo.h b/source/gameengine/Ketsji/KX_ClientObjectInfo.h
index 7345edb054b..74d463fbf20 100644
--- a/source/gameengine/Ketsji/KX_ClientObjectInfo.h
+++ b/source/gameengine/Ketsji/KX_ClientObjectInfo.h
@@ -50,8 +50,8 @@ struct KX_ClientObjectInfo
STATIC,
ACTOR,
RESERVED1,
- RADAR,
- NEAR
+ SENSOR,
+ OBSENSOR
} m_type;
KX_GameObject* m_gameobject;
void* m_auxilary_info;
@@ -84,6 +84,7 @@ public:
}
bool isActor() { return m_type <= ACTOR; }
+ bool isSensor() { return m_type >= SENSOR && m_type <= OBSENSOR; }
};
#endif //__KX_CLIENTOBJECT_INFO_H
diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h b/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h
index 5b912a123fe..e48fddb30bd 100644
--- a/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h
+++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h
@@ -83,6 +83,7 @@ struct KX_ObjectProperties
bool m_ghost;
class KX_GameObject* m_dynamic_parent;
bool m_isactor;
+ bool m_sensor;
bool m_concave;
bool m_isdeformable;
bool m_disableSleeping;
diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
index f18ffb56ccb..73693e68642 100644
--- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
+++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
@@ -808,12 +808,12 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
bool isbulletdyna = false;
+ bool isbulletsensor = false;
CcdConstructionInfo ci;
class PHY_IMotionState* motionstate = new KX_MotionState(gameobj->GetSGNode());
class CcdShapeConstructionInfo *shapeInfo = new CcdShapeConstructionInfo();
-
if (!objprop->m_dyna)
{
ci.m_collisionFlags |= btCollisionObject::CF_STATIC_OBJECT;
@@ -832,6 +832,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
ci.m_margin = objprop->m_margin;
shapeInfo->m_radius = objprop->m_radius;
isbulletdyna = objprop->m_dyna;
+ isbulletsensor = objprop->m_sensor;
ci.m_localInertiaTensor = btVector3(ci.m_mass/3.f,ci.m_mass/3.f,ci.m_mass/3.f);
@@ -851,7 +852,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
//bm = new MultiSphereShape(inertiaHalfExtents,,&trans.getOrigin(),&radius,1);
shapeInfo->m_shapeType = PHY_SHAPE_SPHERE;
- bm = shapeInfo->CreateBulletShape();
+ bm = shapeInfo->CreateBulletShape(ci.m_margin);
break;
};
case KX_BOUNDBOX:
@@ -864,7 +865,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
shapeInfo->m_halfExtend /= 2.0;
shapeInfo->m_halfExtend = shapeInfo->m_halfExtend.absolute();
shapeInfo->m_shapeType = PHY_SHAPE_BOX;
- bm = shapeInfo->CreateBulletShape();
+ bm = shapeInfo->CreateBulletShape(ci.m_margin);
break;
};
case KX_BOUNDCYLINDER:
@@ -875,7 +876,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
objprop->m_boundobject.c.m_height * 0.5f
);
shapeInfo->m_shapeType = PHY_SHAPE_CYLINDER;
- bm = shapeInfo->CreateBulletShape();
+ bm = shapeInfo->CreateBulletShape(ci.m_margin);
break;
}
@@ -884,18 +885,18 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
shapeInfo->m_radius = objprop->m_boundobject.c.m_radius;
shapeInfo->m_height = objprop->m_boundobject.c.m_height;
shapeInfo->m_shapeType = PHY_SHAPE_CONE;
- bm = shapeInfo->CreateBulletShape();
+ bm = shapeInfo->CreateBulletShape(ci.m_margin);
break;
}
case KX_BOUNDPOLYTOPE:
{
shapeInfo->SetMesh(meshobj, dm,true,false);
- bm = shapeInfo->CreateBulletShape();
+ bm = shapeInfo->CreateBulletShape(ci.m_margin);
break;
}
case KX_BOUNDMESH:
{
- bool useGimpact = (ci.m_mass && !objprop->m_softbody);
+ bool useGimpact = ((ci.m_mass || isbulletsensor) && !objprop->m_softbody);
// mesh shapes can be shared, check first if we already have a shape on that mesh
class CcdShapeConstructionInfo *sharedShapeInfo = CcdShapeConstructionInfo::FindMesh(meshobj, dm, false,useGimpact);
@@ -915,7 +916,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
shapeInfo->setVertexWeldingThreshold1(objprop->m_soft_welding); //todo: expose this to the UI
}
- bm = shapeInfo->CreateBulletShape();
+ bm = shapeInfo->CreateBulletShape(ci.m_margin);
//should we compute inertia for dynamic shape?
//bm->calculateLocalInertia(ci.m_mass,ci.m_localInertiaTensor);
@@ -933,7 +934,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
return;
}
- bm->setMargin(ci.m_margin);
+ //bm->setMargin(ci.m_margin);
if (objprop->m_isCompoundChild)
@@ -1103,26 +1104,39 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
ci.m_soft_numclusteriterations= objprop->m_soft_numclusteriterations; /* number of iterations to refine collision clusters*/
////////////////////
-
- ci.m_collisionFilterGroup = (isbulletdyna) ? short(CcdConstructionInfo::DefaultFilter) : short(CcdConstructionInfo::StaticFilter);
- ci.m_collisionFilterMask = (isbulletdyna) ? short(CcdConstructionInfo::AllFilter) : short(CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::StaticFilter);
+ ci.m_collisionFilterGroup =
+ (isbulletsensor) ? short(CcdConstructionInfo::SensorFilter) :
+ (isbulletdyna) ? short(CcdConstructionInfo::DefaultFilter) :
+ short(CcdConstructionInfo::StaticFilter);
+ ci.m_collisionFilterMask =
+ (isbulletsensor) ? short(CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::SensorFilter) :
+ (isbulletdyna) ? short(CcdConstructionInfo::AllFilter) :
+ short(CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::StaticFilter);
ci.m_bRigid = objprop->m_dyna && objprop->m_angular_rigidbody;
ci.m_bSoft = objprop->m_softbody;
+ ci.m_bSensor = isbulletsensor;
MT_Vector3 scaling = gameobj->NodeGetWorldScaling();
ci.m_scaling.setValue(scaling[0], scaling[1], scaling[2]);
- KX_BulletPhysicsController* physicscontroller = new KX_BulletPhysicsController(ci,isbulletdyna,objprop->m_hasCompoundChildren);
+ KX_BulletPhysicsController* physicscontroller = new KX_BulletPhysicsController(ci,isbulletdyna,isbulletsensor,objprop->m_hasCompoundChildren);
// shapeInfo is reference counted, decrement now as we don't use it anymore
if (shapeInfo)
shapeInfo->Release();
- if (objprop->m_in_active_layer)
+ gameobj->SetPhysicsController(physicscontroller,isbulletdyna);
+ if (isbulletsensor)
+ {
+ // use a different callback function for sensor object,
+ // bullet will not synchronize, we must do it explicitely
+ SG_Callbacks& callbacks = gameobj->GetSGNode()->GetCallBackFunctions();
+ callbacks.m_updatefunc = KX_GameObject::SynchronizeTransformFunc;
+ // make sensor object invisible by default
+ gameobj->SetVisible(false, false);
+ }
+ // don't add automatically sensor object, they are added when a collision sensor is registered
+ else if (objprop->m_in_active_layer)
{
env->addCcdPhysicsController( physicscontroller);
}
-
-
-
- gameobj->SetPhysicsController(physicscontroller,isbulletdyna);
physicscontroller->setNewClientInfo(gameobj->getClientInfo());
{
btRigidBody* rbody = physicscontroller->GetRigidBody();
@@ -1181,7 +1195,9 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
}
bool isActor = objprop->m_isactor;
- gameobj->getClientInfo()->m_type = (isActor ? KX_ClientObjectInfo::ACTOR : KX_ClientObjectInfo::STATIC);
+ gameobj->getClientInfo()->m_type =
+ (isbulletsensor) ? KX_ClientObjectInfo::OBSENSOR :
+ (isActor) ? KX_ClientObjectInfo::ACTOR : KX_ClientObjectInfo::STATIC;
// store materialname in auxinfo, needed for touchsensors
if (meshobj)
{
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index 79519bfb491..1d7bf56f6d3 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -332,7 +332,7 @@ void KX_GameObject::ProcessReplica()
}
-static void setGraphicController_recursive(SG_Node* node, bool v)
+static void setGraphicController_recursive(SG_Node* node)
{
NodeList& children = node->GetSGChildren();
@@ -341,24 +341,24 @@ static void setGraphicController_recursive(SG_Node* node, bool v)
SG_Node* childnode = (*childit);
KX_GameObject *clientgameobj = static_cast<KX_GameObject*>( (*childit)->GetSGClientObject());
if (clientgameobj != NULL) // This is a GameObject
- clientgameobj->ActivateGraphicController(v, false);
+ clientgameobj->ActivateGraphicController(false);
// if the childobj is NULL then this may be an inverse parent link
// so a non recursive search should still look down this node.
- setGraphicController_recursive(childnode, v);
+ setGraphicController_recursive(childnode);
}
}
-void KX_GameObject::ActivateGraphicController(bool active, bool recurse)
+void KX_GameObject::ActivateGraphicController(bool recurse)
{
if (m_pGraphicController)
{
- m_pGraphicController->Activate(active);
+ m_pGraphicController->Activate(m_bVisible);
}
if (recurse)
{
- setGraphicController_recursive(GetSGNode(), active);
+ setGraphicController_recursive(GetSGNode());
}
}
@@ -538,6 +538,20 @@ void KX_GameObject::UpdateTransformFunc(SG_IObject* node, void* gameobj, void* s
((KX_GameObject*)gameobj)->UpdateTransform();
}
+void KX_GameObject::SynchronizeTransform()
+{
+ // only used for sensor object, do full synchronization as bullet doesn't do it
+ if (m_pPhysicsController1)
+ m_pPhysicsController1->SetTransform();
+ if (m_pGraphicController)
+ m_pGraphicController->SetGraphicTransform();
+}
+
+void KX_GameObject::SynchronizeTransformFunc(SG_IObject* node, void* gameobj, void* scene)
+{
+ ((KX_GameObject*)gameobj)->SynchronizeTransform();
+}
+
void KX_GameObject::SetDebugColor(unsigned int bgra)
{
diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h
index e5b26539d4d..e0e78918dde 100644
--- a/source/gameengine/Ketsji/KX_GameObject.h
+++ b/source/gameengine/Ketsji/KX_GameObject.h
@@ -384,7 +384,7 @@ public:
/*
* @add/remove the graphic controller to the physic system
*/
- void ActivateGraphicController(bool active, bool recurse);
+ void ActivateGraphicController(bool recurse);
/**
* @section Coordinate system manipulation functions
@@ -560,6 +560,13 @@ public:
static void UpdateTransformFunc(SG_IObject* node, void* gameobj, void* scene);
/**
+ * only used for sensor objects
+ */
+ void SynchronizeTransform();
+
+ static void SynchronizeTransformFunc(SG_IObject* node, void* gameobj, void* scene);
+
+ /**
* Function to set IPO option at start of IPO
*/
void
diff --git a/source/gameengine/Ketsji/KX_IPhysicsController.cpp b/source/gameengine/Ketsji/KX_IPhysicsController.cpp
index a38222c5f7e..673acabd774 100644
--- a/source/gameengine/Ketsji/KX_IPhysicsController.cpp
+++ b/source/gameengine/Ketsji/KX_IPhysicsController.cpp
@@ -35,9 +35,10 @@
#include "PHY_DynamicTypes.h"
-KX_IPhysicsController::KX_IPhysicsController(bool dyna, bool compound, void* userdata)
+KX_IPhysicsController::KX_IPhysicsController(bool dyna, bool sensor, bool compound, void* userdata)
: m_bDyna(dyna),
+ m_bSensor(sensor),
m_bCompound(compound),
m_suspendDynamics(false),
m_userdata(userdata)
diff --git a/source/gameengine/Ketsji/KX_IPhysicsController.h b/source/gameengine/Ketsji/KX_IPhysicsController.h
index 10b66da7b76..81c01045071 100644
--- a/source/gameengine/Ketsji/KX_IPhysicsController.h
+++ b/source/gameengine/Ketsji/KX_IPhysicsController.h
@@ -49,11 +49,12 @@ class KX_IPhysicsController : public SG_Controller
{
protected:
bool m_bDyna;
+ bool m_bSensor;
bool m_bCompound;
bool m_suspendDynamics;
void* m_userdata;
public:
- KX_IPhysicsController(bool dyna,bool compound, void* userdata);
+ KX_IPhysicsController(bool dyna,bool sensor,bool compound, void* userdata);
virtual ~KX_IPhysicsController();
@@ -74,6 +75,7 @@ public:
virtual void getOrientation(MT_Quaternion& orn)=0;
virtual void setOrientation(const MT_Matrix3x3& orn)=0;
+ virtual void SetTransform()=0;
//virtual void setOrientation(const MT_Quaternion& orn)=0;
virtual void setPosition(const MT_Point3& pos)=0;
virtual void setScaling(const MT_Vector3& scaling)=0;
@@ -100,10 +102,18 @@ public:
m_bDyna = isDynamic;
}
+ void SetSensor(bool isSensor) {
+ m_bSensor = isSensor;
+ }
+
bool IsDyna(void) {
return m_bDyna;
}
+ bool IsSensor(void) {
+ return m_bSensor;
+ }
+
bool IsCompound(void) {
return m_bCompound;
}
diff --git a/source/gameengine/Ketsji/KX_MotionState.cpp b/source/gameengine/Ketsji/KX_MotionState.cpp
index b4d58dccfdf..60455d33312 100644
--- a/source/gameengine/Ketsji/KX_MotionState.cpp
+++ b/source/gameengine/Ketsji/KX_MotionState.cpp
@@ -73,6 +73,11 @@ void KX_MotionState::getWorldOrientation(float* ori)
mat.getValue(ori);
}
+void KX_MotionState::setWorldOrientation(const float* ori)
+{
+ m_node->SetLocalOrientation(ori);
+}
+
void KX_MotionState::setWorldPosition(float posX,float posY,float posZ)
{
m_node->SetLocalPosition(MT_Point3(posX,posY,posZ));
diff --git a/source/gameengine/Ketsji/KX_MotionState.h b/source/gameengine/Ketsji/KX_MotionState.h
index 7ba3ca2f85c..0e43e88fbeb 100644
--- a/source/gameengine/Ketsji/KX_MotionState.h
+++ b/source/gameengine/Ketsji/KX_MotionState.h
@@ -45,6 +45,7 @@ public:
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();
};
diff --git a/source/gameengine/Ketsji/KX_NearSensor.cpp b/source/gameengine/Ketsji/KX_NearSensor.cpp
index a3c4e95ae24..44842b7f5b3 100644
--- a/source/gameengine/Ketsji/KX_NearSensor.cpp
+++ b/source/gameengine/Ketsji/KX_NearSensor.cpp
@@ -36,6 +36,7 @@
#include "KX_Scene.h" // needed to create a replica
#include "PHY_IPhysicsEnvironment.h"
#include "PHY_IPhysicsController.h"
+#include "PHY_IMotionState.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -62,7 +63,7 @@ KX_NearSensor::KX_NearSensor(SCA_EventManager* eventmgr,
{
gameobj->getClientInfo()->m_sensors.remove(this);
- m_client_info = new KX_ClientObjectInfo(gameobj, KX_ClientObjectInfo::NEAR);
+ m_client_info = new KX_ClientObjectInfo(gameobj, KX_ClientObjectInfo::SENSOR);
m_client_info->m_sensors.push_back(this);
//DT_ShapeHandle shape = (DT_ShapeHandle) vshape;
@@ -81,28 +82,14 @@ void KX_NearSensor::SynchronizeTransform()
// not linked to the parent object, must synchronize it.
if (m_physCtrl)
{
+ PHY_IMotionState* motionState = m_physCtrl->GetMotionState();
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();
- }
-}
-
-void KX_NearSensor::RegisterSumo(KX_TouchEventManager *touchman)
-{
- if (m_physCtrl)
- {
- touchman->GetPhysicsEnvironment()->addSensor(m_physCtrl);
- }
-}
-
-void KX_NearSensor::UnregisterSumo(KX_TouchEventManager* touchman)
-{
- if (m_physCtrl)
- {
- touchman->GetPhysicsEnvironment()->removeSensor(m_physCtrl);
+ const MT_Point3& pos = parent->NodeGetWorldPosition();
+ float ori[12];
+ parent->NodeGetWorldOrientation().getValue(ori);
+ motionState->setWorldPosition(pos[0], pos[1], pos[2]);
+ motionState->setWorldOrientation(ori);
+ m_physCtrl->WriteMotionStateToDynamics(true);
}
}
@@ -117,7 +104,7 @@ void KX_NearSensor::ProcessReplica()
{
KX_TouchSensor::ProcessReplica();
- m_client_info = new KX_ClientObjectInfo(m_client_info->m_gameobject, KX_ClientObjectInfo::NEAR);
+ m_client_info = new KX_ClientObjectInfo(m_client_info->m_gameobject, KX_ClientObjectInfo::SENSOR);
if (m_physCtrl)
{
@@ -134,11 +121,11 @@ void KX_NearSensor::ProcessReplica()
void KX_NearSensor::ReParent(SCA_IObject* parent)
{
+ SCA_ISensor::ReParent(parent);
m_client_info->m_gameobject = static_cast<KX_GameObject*>(parent);
m_client_info->m_sensors.push_back(this);
//Synchronize here with the actual parent.
SynchronizeTransform();
- SCA_ISensor::ReParent(parent);
}
diff --git a/source/gameengine/Ketsji/KX_NearSensor.h b/source/gameengine/Ketsji/KX_NearSensor.h
index 35136b79d13..d98b464a443 100644
--- a/source/gameengine/Ketsji/KX_NearSensor.h
+++ b/source/gameengine/Ketsji/KX_NearSensor.h
@@ -77,8 +77,8 @@ public:
virtual bool NewHandleCollision(void* obj1,void* obj2,
const PHY_CollData * coll_data);
virtual bool BroadPhaseFilterCollision(void*obj1,void*obj2);
- virtual void RegisterSumo(KX_TouchEventManager *touchman);
- virtual void UnregisterSumo(KX_TouchEventManager* touchman);
+ virtual bool BroadPhaseSensorFilterCollision(void*obj1,void*obj2) { return false; };
+ virtual sensortype GetSensorType() { return NEAR; }
/* --------------------------------------------------------------------- */
/* Python interface ---------------------------------------------------- */
diff --git a/source/gameengine/Ketsji/KX_OdePhysicsController.h b/source/gameengine/Ketsji/KX_OdePhysicsController.h
index 21b7e632d83..8c3974c38a3 100644
--- a/source/gameengine/Ketsji/KX_OdePhysicsController.h
+++ b/source/gameengine/Ketsji/KX_OdePhysicsController.h
@@ -70,6 +70,7 @@ public:
virtual void setOrientation(const MT_Matrix3x3& orn);
virtual void setPosition(const MT_Point3& pos);
virtual void setScaling(const MT_Vector3& scaling);
+ virtual void SetTransform() {}
virtual MT_Scalar GetMass();
virtual MT_Vector3 getReactionForce();
virtual void setRigidBody(bool rigid);
diff --git a/source/gameengine/Ketsji/KX_RadarSensor.cpp b/source/gameengine/Ketsji/KX_RadarSensor.cpp
index 4532224a81e..064dc9126ac 100644
--- a/source/gameengine/Ketsji/KX_RadarSensor.cpp
+++ b/source/gameengine/Ketsji/KX_RadarSensor.cpp
@@ -30,6 +30,7 @@
#include "KX_GameObject.h"
#include "KX_PyMath.h"
#include "PHY_IPhysicsController.h"
+#include "PHY_IMotionState.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -66,7 +67,7 @@ KX_RadarSensor::KX_RadarSensor(SCA_EventManager* eventmgr,
m_coneheight(coneheight),
m_axis(axis)
{
- m_client_info->m_type = KX_ClientObjectInfo::RADAR;
+ m_client_info->m_type = KX_ClientObjectInfo::SENSOR;
//m_client_info->m_clientobject = gameobj;
//m_client_info->m_auxilary_info = NULL;
//sumoObj->setClientObject(&m_client_info);
@@ -84,12 +85,6 @@ CValue* KX_RadarSensor::GetReplica()
return replica;
}
-void KX_RadarSensor::ProcessReplica()
-{
- KX_NearSensor::ProcessReplica();
- m_client_info->m_type = KX_ClientObjectInfo::RADAR;
-}
-
/**
* Transforms the collision object. A cone is not correctly centered
* for usage. */
@@ -169,11 +164,13 @@ void KX_RadarSensor::SynchronizeTransform()
if (m_physCtrl)
{
- MT_Quaternion orn = trans.getRotation();
- MT_Point3 pos = trans.getOrigin();
- m_physCtrl->setPosition(pos[0],pos[1],pos[2]);
- m_physCtrl->setOrientation(orn[0],orn[1],orn[2],orn[3]);
- m_physCtrl->calcXform();
+ PHY_IMotionState* motionState = m_physCtrl->GetMotionState();
+ const MT_Point3& pos = trans.getOrigin();
+ float ori[12];
+ trans.getBasis().getValue(ori);
+ motionState->setWorldPosition(pos[0], pos[1], pos[2]);
+ motionState->setWorldOrientation(ori);
+ m_physCtrl->WriteMotionStateToDynamics(true);
}
}
diff --git a/source/gameengine/Ketsji/KX_RadarSensor.h b/source/gameengine/Ketsji/KX_RadarSensor.h
index b4268797f85..6779a9edffe 100644
--- a/source/gameengine/Ketsji/KX_RadarSensor.h
+++ b/source/gameengine/Ketsji/KX_RadarSensor.h
@@ -76,7 +76,6 @@ public:
virtual ~KX_RadarSensor();
virtual void SynchronizeTransform();
virtual CValue* GetReplica();
- virtual void ProcessReplica();
/* --------------------------------------------------------------------- */
/* Python interface ---------------------------------------------------- */
@@ -93,6 +92,7 @@ public:
virtual PyObject* py_getattro(PyObject *attr);
virtual PyObject* py_getattro_dict();
virtual int py_setattro(PyObject *attr, PyObject* value);
+ virtual sensortype GetSensorType() { return RADAR; }
//Deprecated ----->
KX_PYMETHOD_DOC_NOARGS(KX_RadarSensor,GetConeOrigin);
diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp
index 9502599603c..bb5e0875402 100644
--- a/source/gameengine/Ketsji/KX_Scene.cpp
+++ b/source/gameengine/Ketsji/KX_Scene.cpp
@@ -737,7 +737,7 @@ void KX_Scene::DupliGroupRecurse(CValue* obj, int level)
replica->GetSGNode()->SetBBox(gameobj->GetSGNode()->BBox());
replica->GetSGNode()->SetRadius(gameobj->GetSGNode()->Radius());
// we can now add the graphic controller to the physic engine
- replica->ActivateGraphicController(true,true);
+ replica->ActivateGraphicController(true);
// done with replica
replica->Release();
@@ -850,7 +850,7 @@ SCA_IObject* KX_Scene::AddReplicaObject(class CValue* originalobject,
replica->GetSGNode()->SetBBox(originalobj->GetSGNode()->BBox());
replica->GetSGNode()->SetRadius(originalobj->GetSGNode()->Radius());
// the size is correct, we can add the graphic controller to the physic engine
- replica->ActivateGraphicController(true,true);
+ replica->ActivateGraphicController(true);
// now replicate logic
vector<KX_GameObject*>::iterator git;
diff --git a/source/gameengine/Ketsji/KX_SumoPhysicsController.h b/source/gameengine/Ketsji/KX_SumoPhysicsController.h
index 083d89896f6..278994c6ae7 100644
--- a/source/gameengine/Ketsji/KX_SumoPhysicsController.h
+++ b/source/gameengine/Ketsji/KX_SumoPhysicsController.h
@@ -53,7 +53,7 @@ public:
class SM_Object* sumoObj,
class PHY_IMotionState* motionstate
,bool dyna)
- : KX_IPhysicsController(dyna,false,NULL) ,
+ : KX_IPhysicsController(dyna,false,false,NULL) ,
SumoPhysicsController(sumoScene,/*solidscene,*/sumoObj,motionstate,dyna)
{
};
@@ -83,6 +83,7 @@ public:
virtual void getOrientation(MT_Quaternion& orn);
virtual void setOrientation(const MT_Matrix3x3& orn);
+ virtual void SetTransform() {}
virtual void setPosition(const MT_Point3& pos);
virtual void setScaling(const MT_Vector3& scaling);
diff --git a/source/gameengine/Ketsji/KX_TouchEventManager.cpp b/source/gameengine/Ketsji/KX_TouchEventManager.cpp
index 8ae5fae8fa3..46927541099 100644
--- a/source/gameengine/Ketsji/KX_TouchEventManager.cpp
+++ b/source/gameengine/Ketsji/KX_TouchEventManager.cpp
@@ -85,14 +85,34 @@ bool KX_TouchEventManager::newBroadphaseResponse(void *client_data,
PHY_IPhysicsController* ctrl = static_cast<PHY_IPhysicsController*>(object1);
KX_ClientObjectInfo* info = (ctrl) ? static_cast<KX_ClientObjectInfo*>(ctrl->getNewClientInfo()) : NULL;
// This call back should only be called for controllers of Near and Radar sensor
- if (info &&
- info->m_sensors.size() == 1 &&
- (info->m_type == KX_ClientObjectInfo::NEAR ||
- info->m_type == KX_ClientObjectInfo::RADAR))
+ if (!info)
+ return true;
+
+ switch (info->m_type)
{
- // only one sensor for this type of object
- KX_TouchSensor* touchsensor = static_cast<KX_TouchSensor*>(*info->m_sensors.begin());
- return touchsensor->BroadPhaseFilterCollision(object1,object2);
+ case KX_ClientObjectInfo::SENSOR:
+ if (info->m_sensors.size() == 1)
+ {
+ // only one sensor for this type of object
+ KX_TouchSensor* touchsensor = static_cast<KX_TouchSensor*>(*info->m_sensors.begin());
+ return touchsensor->BroadPhaseFilterCollision(object1,object2);
+ }
+ break;
+ case KX_ClientObjectInfo::OBSENSOR:
+ // this object may have multiple collision sensors,
+ // check is any of them is interested in this object
+ for(std::list<SCA_ISensor*>::iterator it = info->m_sensors.begin();
+ it != info->m_sensors.end();
+ ++it)
+ {
+ if ((*it)->GetSensorType() == SCA_ISensor::TOUCH)
+ {
+ KX_TouchSensor* touchsensor = static_cast<KX_TouchSensor*>(*it);
+ if (touchsensor->BroadPhaseSensorFilterCollision(object1, object2))
+ return true;
+ }
+ }
+ return false;
}
return true;
}
diff --git a/source/gameengine/Ketsji/KX_TouchSensor.cpp b/source/gameengine/Ketsji/KX_TouchSensor.cpp
index 8c0d5596939..509fc60e9f5 100644
--- a/source/gameengine/Ketsji/KX_TouchSensor.cpp
+++ b/source/gameengine/Ketsji/KX_TouchSensor.cpp
@@ -173,19 +173,65 @@ void KX_TouchSensor::RegisterSumo(KX_TouchEventManager *touchman)
{
if (m_physCtrl)
{
- touchman->GetPhysicsEnvironment()->requestCollisionCallback(m_physCtrl);
- // collision
- // Deprecated
-
+ if (touchman->GetPhysicsEnvironment()->requestCollisionCallback(m_physCtrl))
+ {
+ KX_ClientObjectInfo* client_info = static_cast<KX_ClientObjectInfo*>(m_physCtrl->getNewClientInfo());
+ if (client_info->isSensor())
+ touchman->GetPhysicsEnvironment()->addSensor(m_physCtrl);
+ }
}
}
-
void KX_TouchSensor::UnregisterSumo(KX_TouchEventManager* touchman)
{
if (m_physCtrl)
{
- touchman->GetPhysicsEnvironment()->removeCollisionCallback(m_physCtrl);
+ if (touchman->GetPhysicsEnvironment()->removeCollisionCallback(m_physCtrl))
+ {
+ // no more sensor on the controller, can remove it if it is a sensor object
+ KX_ClientObjectInfo* client_info = static_cast<KX_ClientObjectInfo*>(m_physCtrl->getNewClientInfo());
+ if (client_info->isSensor())
+ touchman->GetPhysicsEnvironment()->removeSensor(m_physCtrl);
+ }
+ }
+}
+
+// this function is called only for sensor objects
+// return true if the controller can collide with the object
+bool KX_TouchSensor::BroadPhaseSensorFilterCollision(void*obj1,void*obj2)
+{
+ assert(obj1==m_physCtrl && obj2);
+
+ KX_GameObject* myobj = (KX_GameObject*)GetParent();
+ KX_GameObject* myparent = myobj->GetParent();
+ KX_ClientObjectInfo* client_info = static_cast<KX_ClientObjectInfo*>(((PHY_IPhysicsController*)obj2)->getNewClientInfo());
+ KX_GameObject* otherobj = ( client_info ? client_info->m_gameobject : NULL);
+
+ // first, decrement refcount as GetParent() increases it
+ if (myparent)
+ myparent->Release();
+
+ // we can only check on persistent characteristic: m_link and m_suspended are not
+ // good candidate because they are transient. That must be handled at another level
+ if (!otherobj ||
+ otherobj == myparent || // don't interact with our parent
+ client_info->m_type != KX_ClientObjectInfo::ACTOR) // only with actor objects
+ return false;
+
+ bool found = m_touchedpropname.IsEmpty();
+ if (!found)
+ {
+ if (m_bFindMaterial)
+ {
+ if (client_info->m_auxilary_info)
+ {
+ found = (!strcmp(m_touchedpropname.Ptr(), (char*)client_info->m_auxilary_info));
+ }
+ } else
+ {
+ found = (otherobj->GetProperty(m_touchedpropname) != NULL);
+ }
}
+ return found;
}
bool KX_TouchSensor::NewHandleCollision(void*object1,void*object2,const PHY_CollData* colldata)
diff --git a/source/gameengine/Ketsji/KX_TouchSensor.h b/source/gameengine/Ketsji/KX_TouchSensor.h
index 9c9c6bf5816..b62ec6eaf4d 100644
--- a/source/gameengine/Ketsji/KX_TouchSensor.h
+++ b/source/gameengine/Ketsji/KX_TouchSensor.h
@@ -103,7 +103,8 @@ public:
// obj1 = sensor physical controller, obj2 = physical controller of second object
// return value = true if collision should be checked on pair of object
virtual bool BroadPhaseFilterCollision(void*obj1,void*obj2) { return true; }
-
+ virtual bool BroadPhaseSensorFilterCollision(void*obj1,void*obj2);
+ virtual sensortype GetSensorType() { return TOUCH; }
virtual bool IsPositiveTrigger() {
diff --git a/source/gameengine/Physics/BlOde/OdePhysicsController.cpp b/source/gameengine/Physics/BlOde/OdePhysicsController.cpp
index efe4554d970..5efd0994311 100644
--- a/source/gameengine/Physics/BlOde/OdePhysicsController.cpp
+++ b/source/gameengine/Physics/BlOde/OdePhysicsController.cpp
@@ -379,7 +379,10 @@ bool ODEPhysicsController::SynchronizeMotionStates(float time)
return false; //it update the worldpos
}
-
+PHY_IMotionState* ODEPhysicsController::GetMotionState()
+{
+ return m_MotionState;
+}
// kinematic methods
diff --git a/source/gameengine/Physics/BlOde/OdePhysicsController.h b/source/gameengine/Physics/BlOde/OdePhysicsController.h
index e97afdb68c3..544d11da2ca 100644
--- a/source/gameengine/Physics/BlOde/OdePhysicsController.h
+++ b/source/gameengine/Physics/BlOde/OdePhysicsController.h
@@ -102,6 +102,7 @@ public:
virtual void WriteDynamicsToMotionState() {};
virtual void WriteMotionStateToDynamics(bool nondynaonly);
+ virtual class PHY_IMotionState* GetMotionState();
/**
call from Scene Graph Node to 'update'.
diff --git a/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.h b/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.h
index 82e26e01460..54e4f7f90e1 100644
--- a/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.h
+++ b/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.h
@@ -64,8 +64,8 @@ public:
virtual void addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user)
{
}
- virtual void requestCollisionCallback(PHY_IPhysicsController* ctrl) {}
- virtual void removeCollisionCallback(PHY_IPhysicsController* ctrl) {}
+ virtual bool requestCollisionCallback(PHY_IPhysicsController* ctrl) {return false;}
+ virtual bool removeCollisionCallback(PHY_IPhysicsController* ctrl) {return false;}
virtual PHY_IPhysicsController* CreateSphereController(float radius,const PHY__Vector3& position) {return 0;}
virtual PHY_IPhysicsController* CreateConeController(float coneradius,float coneheight) { return 0;}
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
index 01e8aa2560f..7302c47f4bf 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
@@ -92,16 +92,19 @@ CcdPhysicsController::CcdPhysicsController (const CcdConstructionInfo& ci)
}
-btTransform CcdPhysicsController::GetTransformFromMotionState(PHY_IMotionState* motionState)
+btTransform& CcdPhysicsController::GetTransformFromMotionState(PHY_IMotionState* motionState)
{
- btTransform trans;
- float tmp[3];
- motionState->getWorldPosition(tmp[0],tmp[1],tmp[2]);
- trans.setOrigin(btVector3(tmp[0],tmp[1],tmp[2]));
-
- btQuaternion orn;
- motionState->getWorldOrientation(orn[0],orn[1],orn[2],orn[3]);
- trans.setRotation(orn);
+ static btTransform trans;
+ btVector3 tmp;
+ motionState->getWorldPosition(tmp.m_floats[0], tmp.m_floats[1], tmp.m_floats[2]);
+ trans.setOrigin(tmp);
+
+ float ori[12];
+ motionState->getWorldOrientation(ori);
+ trans.getBasis().setFromOpenGLSubMatrix(ori);
+ //btQuaternion orn;
+ //motionState->getWorldOrientation(orn[0],orn[1],orn[2],orn[3]);
+ //trans.setRotation(orn);
return trans;
}
@@ -118,18 +121,18 @@ public:
}
- virtual void getWorldTransform(btTransform& worldTrans ) const
+ void getWorldTransform(btTransform& worldTrans ) const
{
- float pos[3];
- float quatOrn[4];
+ btVector3 pos;
+ float ori[12];
- m_blenderMotionState->getWorldPosition(pos[0],pos[1],pos[2]);
- m_blenderMotionState->getWorldOrientation(quatOrn[0],quatOrn[1],quatOrn[2],quatOrn[3]);
- worldTrans.setOrigin(btVector3(pos[0],pos[1],pos[2]));
- worldTrans.setBasis(btMatrix3x3(btQuaternion(quatOrn[0],quatOrn[1],quatOrn[2],quatOrn[3])));
+ m_blenderMotionState->getWorldPosition(pos.m_floats[0],pos.m_floats[1],pos.m_floats[2]);
+ m_blenderMotionState->getWorldOrientation(ori);
+ worldTrans.setOrigin(pos);
+ worldTrans.getBasis().setFromOpenGLSubMatrix(ori);
}
- virtual void setWorldTransform(const btTransform& worldTrans)
+ void setWorldTransform(const btTransform& worldTrans)
{
m_blenderMotionState->setWorldPosition(worldTrans.getOrigin().getX(),worldTrans.getOrigin().getY(),worldTrans.getOrigin().getZ());
btQuaternion rotQuat = worldTrans.getRotation();
@@ -493,10 +496,12 @@ void CcdPhysicsController::CreateRigidbody()
//convert collision flags!
//special case: a near/radar sensor controller should not be defined static or it will
//generate loads of static-static collision messages on the console
- if ((m_cci.m_collisionFilterGroup & CcdConstructionInfo::SensorFilter) != 0)
+ if (m_cci.m_bSensor)
{
// reset the flags that have been set so far
GetCollisionObject()->setCollisionFlags(0);
+ // sensor must never go to sleep: they need to detect continously
+ GetCollisionObject()->setActivationState(DISABLE_DEACTIVATION);
}
GetCollisionObject()->setCollisionFlags(m_object->getCollisionFlags() | m_cci.m_collisionFlags);
btRigidBody* body = GetRigidBody();
@@ -613,12 +618,13 @@ bool CcdPhysicsController::SynchronizeMotionStates(float time)
body->setLinearVelocity(linvel * (m_cci.m_clamp_vel_min / len));
}
- const btVector3& worldPos = body->getCenterOfMassPosition();
+ const btTransform& xform = body->getCenterOfMassTransform();
+ const btMatrix3x3& worldOri = xform.getBasis();
+ const btVector3& worldPos = xform.getOrigin();
+ float ori[12];
+ worldOri.getOpenGLSubMatrix(ori);
+ m_MotionState->setWorldOrientation(ori);
m_MotionState->setWorldPosition(worldPos[0],worldPos[1],worldPos[2]);
-
- const btQuaternion& worldquat = body->getOrientation();
- m_MotionState->setWorldOrientation(worldquat[0],worldquat[1],worldquat[2],worldquat[3]);
-
m_MotionState->calculateWorldTransformations();
float scale[3];
@@ -655,8 +661,10 @@ bool CcdPhysicsController::SynchronizeMotionStates(float time)
void CcdPhysicsController::WriteMotionStateToDynamics(bool nondynaonly)
{
-
+ btTransform& xform = CcdPhysicsController::GetTransformFromMotionState(m_MotionState);
+ SetCenterOfMassTransform(xform);
}
+
void CcdPhysicsController::WriteDynamicsToMotionState()
{
}
@@ -673,12 +681,12 @@ void CcdPhysicsController::PostProcessReplica(class PHY_IMotionState* motionsta
if (m_shapeInfo)
{
m_shapeInfo->AddRef();
- m_collisionShape = m_shapeInfo->CreateBulletShape();
+ m_collisionShape = m_shapeInfo->CreateBulletShape(m_cci.m_margin);
if (m_collisionShape)
{
// new shape has no scaling, apply initial scaling
- m_collisionShape->setMargin(m_cci.m_margin);
+ //m_collisionShape->setMargin(m_cci.m_margin);
m_collisionShape->setLocalScaling(m_cci.m_scaling);
if (m_cci.m_mass)
@@ -697,8 +705,10 @@ void CcdPhysicsController::PostProcessReplica(class PHY_IMotionState* motionsta
{
body->setMassProps(m_cci.m_mass, m_cci.m_localInertiaTensor * m_cci.m_inertiaFactor);
}
- }
- m_cci.m_physicsEnv->addCcdPhysicsController(this);
+ }
+ // sensor object are added when needed
+ if (!m_cci.m_bSensor)
+ m_cci.m_physicsEnv->addCcdPhysicsController(this);
/* SM_Object* dynaparent=0;
@@ -773,7 +783,7 @@ void CcdPhysicsController::RelativeTranslate(float dlocX,float dlocY,float dloc
if (m_object)
{
m_object->activate(true);
- if (m_object->isStaticObject())
+ if (m_object->isStaticObject() && !m_cci.m_bSensor)
{
m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
}
@@ -799,7 +809,7 @@ void CcdPhysicsController::RelativeRotate(const float rotval[9],bool local)
if (m_object)
{
m_object->activate(true);
- if (m_object->isStaticObject())
+ if (m_object->isStaticObject() && !m_cci.m_bSensor)
{
m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
}
@@ -843,7 +853,7 @@ void CcdPhysicsController::setOrientation(float quatImag0,float quatImag1,float
if (m_object)
{
m_object->activate(true);
- if (m_object->isStaticObject())
+ if (m_object->isStaticObject() && !m_cci.m_bSensor)
{
m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
}
@@ -866,7 +876,7 @@ void CcdPhysicsController::setWorldOrientation(const btMatrix3x3& orn)
if (m_object)
{
m_object->activate(true);
- if (m_object->isStaticObject())
+ if (m_object->isStaticObject() && !m_cci.m_bSensor)
{
m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
}
@@ -895,7 +905,7 @@ void CcdPhysicsController::setPosition(float posX,float posY,float posZ)
if (m_object)
{
m_object->activate(true);
- if (m_object->isStaticObject())
+ if (m_object->isStaticObject() && !m_cci.m_bSensor)
{
m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
}
@@ -909,9 +919,19 @@ void CcdPhysicsController::setPosition(float posX,float posY,float posZ)
// not required
//m_bulletMotionState->setWorldTransform(xform);
}
+}
-
+void CcdPhysicsController::forceWorldTransform(const btMatrix3x3& mat, const btVector3& pos)
+{
+ if (m_object)
+ {
+ btTransform& xform = m_object->getWorldTransform();
+ xform.setBasis(mat);
+ xform.setOrigin(pos);
+ }
}
+
+
void CcdPhysicsController::resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ)
{
}
@@ -961,7 +981,9 @@ void CcdPhysicsController::ApplyTorque(float torqueX,float torqueY,float torque
m_object->activate();
if (m_object->isStaticObject())
{
- m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+ if (!m_cci.m_bSensor)
+ m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+ return;
}
if (local)
{
@@ -989,27 +1011,26 @@ void CcdPhysicsController::ApplyForce(float forceX,float forceY,float forceZ,bo
m_object->activate();
if (m_object->isStaticObject())
{
- m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+ if (!m_cci.m_bSensor)
+ m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+ return;
}
-
+ btTransform xform = m_object->getWorldTransform();
+
+ if (local)
+ {
+ force = xform.getBasis()*force;
+ }
+ btRigidBody* body = GetRigidBody();
+ if (body)
+ body->applyCentralForce(force);
+ btSoftBody* soft = GetSoftBody();
+ if (soft)
{
- btTransform xform = m_object->getWorldTransform();
-
- if (local)
- {
- force = xform.getBasis()*force;
- }
- btRigidBody* body = GetRigidBody();
- if (body)
- body->applyCentralForce(force);
- btSoftBody* soft = GetSoftBody();
- if (soft)
- {
- // the force is applied on each node, must reduce it in the same extend
- if (soft->m_nodes.size() > 0)
- force /= soft->m_nodes.size();
- soft->addForce(force);
- }
+ // the force is applied on each node, must reduce it in the same extend
+ if (soft->m_nodes.size() > 0)
+ force /= soft->m_nodes.size();
+ soft->addForce(force);
}
}
}
@@ -1021,19 +1042,18 @@ void CcdPhysicsController::SetAngularVelocity(float ang_velX,float ang_velY,flo
m_object->activate(true);
if (m_object->isStaticObject())
{
- m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
- } else
+ if (!m_cci.m_bSensor)
+ m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+ return;
+ }
+ btTransform xform = m_object->getWorldTransform();
+ if (local)
{
- btTransform xform = m_object->getWorldTransform();
- if (local)
- {
- angvel = xform.getBasis()*angvel;
- }
- btRigidBody* body = GetRigidBody();
- if (body)
- body->setAngularVelocity(angvel);
-
+ angvel = xform.getBasis()*angvel;
}
+ btRigidBody* body = GetRigidBody();
+ if (body)
+ body->setAngularVelocity(angvel);
}
}
@@ -1046,7 +1066,8 @@ void CcdPhysicsController::SetLinearVelocity(float lin_velX,float lin_velY,floa
m_object->activate(true);
if (m_object->isStaticObject())
{
- m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+ if (!m_cci.m_bSensor)
+ m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
return;
}
@@ -1080,7 +1101,9 @@ void CcdPhysicsController::applyImpulse(float attachX,float attachY,float attac
m_object->activate();
if (m_object->isStaticObject())
{
- m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+ if (!m_cci.m_bSensor)
+ m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+ return;
}
btVector3 pos(attachX,attachY,attachZ);
@@ -1207,7 +1230,7 @@ PHY_IPhysicsController* CcdPhysicsController::GetReplica()
if (m_shapeInfo)
{
// This situation does not normally happen
- cinfo.m_collisionShape = m_shapeInfo->CreateBulletShape();
+ cinfo.m_collisionShape = m_shapeInfo->CreateBulletShape(0.01);
}
else if (m_collisionShape)
{
@@ -1274,28 +1297,22 @@ void DefaultMotionState::getWorldScaling(float& scaleX,float& scaleY,float& scal
void DefaultMotionState::getWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal)
{
- quatIma0 = m_worldTransform.getRotation().x();
- quatIma1 = m_worldTransform.getRotation().y();
- quatIma2 = m_worldTransform.getRotation().z();
- quatReal = m_worldTransform.getRotation()[3];
+ btQuaternion quat = m_worldTransform.getRotation();
+ quatIma0 = quat.x();
+ quatIma1 = quat.y();
+ quatIma2 = quat.z();
+ quatReal = quat[3];
}
void DefaultMotionState::getWorldOrientation(float* ori)
{
- *ori++ = m_worldTransform.getBasis()[0].x();
- *ori++ = m_worldTransform.getBasis()[1].x();
- *ori++ = m_worldTransform.getBasis()[1].x();
- *ori++ = 0.f;
- *ori++ = m_worldTransform.getBasis()[0].y();
- *ori++ = m_worldTransform.getBasis()[1].y();
- *ori++ = m_worldTransform.getBasis()[1].y();
- *ori++ = 0.f;
- *ori++ = m_worldTransform.getBasis()[0].z();
- *ori++ = m_worldTransform.getBasis()[1].z();
- *ori++ = m_worldTransform.getBasis()[1].z();
- *ori++ = 0.f;
+ m_worldTransform.getBasis().getOpenGLSubMatrix(ori);
}
+void DefaultMotionState::setWorldOrientation(const float* ori)
+{
+ m_worldTransform.getBasis().setFromOpenGLSubMatrix(ori);
+}
void DefaultMotionState::setWorldPosition(float posX,float posY,float posZ)
{
btVector3 pos(posX,posY,posZ);
@@ -1583,7 +1600,7 @@ bool CcdShapeConstructionInfo::SetProxy(CcdShapeConstructionInfo* shapeInfo)
return true;
}
-btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape()
+btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape(btScalar margin)
{
btCollisionShape* collisionShape = 0;
btTriangleMeshShape* concaveShape = 0;
@@ -1591,7 +1608,7 @@ btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape()
CcdShapeConstructionInfo* nextShapeInfo;
if (m_shapeType == PHY_SHAPE_PROXY && m_shapeProxy != NULL)
- return m_shapeProxy->CreateBulletShape();
+ return m_shapeProxy->CreateBulletShape(margin);
switch (m_shapeType)
{
@@ -1600,22 +1617,27 @@ btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape()
case PHY_SHAPE_BOX:
collisionShape = new btBoxShape(m_halfExtend);
+ collisionShape->setMargin(margin);
break;
case PHY_SHAPE_SPHERE:
collisionShape = new btSphereShape(m_radius);
+ collisionShape->setMargin(margin);
break;
case PHY_SHAPE_CYLINDER:
collisionShape = new btCylinderShapeZ(m_halfExtend);
+ collisionShape->setMargin(margin);
break;
case PHY_SHAPE_CONE:
collisionShape = new btConeShapeZ(m_radius, m_height);
+ collisionShape->setMargin(margin);
break;
case PHY_SHAPE_POLYTOPE:
collisionShape = new btConvexHullShape(&m_vertexArray[0], m_vertexArray.size()/3, 3*sizeof(btScalar));
+ collisionShape->setMargin(margin);
break;
case PHY_SHAPE_MESH:
@@ -1638,7 +1660,7 @@ btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape()
);
btGImpactMeshShape* gimpactShape = new btGImpactMeshShape(indexVertexArrays);
-
+ gimpactShape->setMargin(margin);
collisionShape = gimpactShape;
gimpactShape->updateBound();
@@ -1683,6 +1705,7 @@ btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape()
m_unscaledShape->recalcLocalAabb();
}
collisionShape = new btScaledBvhTriangleMeshShape(m_unscaledShape, btVector3(1.0f,1.0f,1.0f));
+ collisionShape->setMargin(margin);
}
break;
@@ -1694,7 +1717,7 @@ btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape()
sit != m_shapeArray.end();
sit++)
{
- collisionShape = (*sit)->CreateBulletShape();
+ collisionShape = (*sit)->CreateBulletShape(margin);
if (collisionShape)
{
collisionShape->setLocalScaling((*sit)->m_childScale);
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h
index 315e2bdf429..fc8de0e2ded 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h
@@ -152,7 +152,7 @@ public:
return m_shapeProxy;
}
- btCollisionShape* CreateBulletShape();
+ btCollisionShape* CreateBulletShape(btScalar margin);
// member variables
PHY_ShapeType m_shapeType;
@@ -222,6 +222,7 @@ struct CcdConstructionInfo
m_collisionFlags(0),
m_bRigid(false),
m_bSoft(false),
+ m_bSensor(false),
m_collisionFilterGroup(DefaultFilter),
m_collisionFilterMask(AllFilter),
m_collisionShape(0),
@@ -288,6 +289,7 @@ struct CcdConstructionInfo
int m_collisionFlags;
bool m_bRigid;
bool m_bSoft;
+ bool m_bSensor;
///optional use of collision group/mask:
///only collision with object goups that match the collision mask.
@@ -326,7 +328,7 @@ class btSoftBody;
///CcdPhysicsController is a physics object that supports continuous collision detection and time of impact based physics resolution.
class CcdPhysicsController : public PHY_IPhysicsController
{
-
+protected:
btCollisionObject* m_object;
@@ -361,8 +363,8 @@ class CcdPhysicsController : public PHY_IPhysicsController
return (--m_registerCount == 0) ? true : false;
}
- protected:
- void setWorldOrientation(const btMatrix3x3& mat);
+ void setWorldOrientation(const btMatrix3x3& mat);
+ void forceWorldTransform(const btMatrix3x3& mat, const btVector3& pos);
public:
@@ -407,6 +409,7 @@ class CcdPhysicsController : public PHY_IPhysicsController
virtual void WriteMotionStateToDynamics(bool nondynaonly);
virtual void WriteDynamicsToMotionState();
+
// controller replication
virtual void PostProcessReplica(class PHY_IMotionState* motionstate,class PHY_IPhysicsController* parentctrl);
@@ -505,7 +508,7 @@ class CcdPhysicsController : public PHY_IPhysicsController
void SetCenterOfMassTransform(btTransform& xform);
- static btTransform GetTransformFromMotionState(PHY_IMotionState* motionState);
+ static btTransform& GetTransformFromMotionState(PHY_IMotionState* motionState);
void setAabb(const btVector3& aabbMin,const btVector3& aabbMax);
@@ -563,6 +566,7 @@ class DefaultMotionState : public PHY_IMotionState
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();
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
index 03c9d13a7dd..ed517e637dc 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
@@ -415,61 +415,7 @@ void CcdPhysicsEnvironment::addCcdPhysicsController(CcdPhysicsController* ctrl)
obj->setActivationState(ISLAND_SLEEPING);
}
-
- //CollisionObject(body,ctrl->GetCollisionFilterGroup(),ctrl->GetCollisionFilterMask());
-
assert(obj->getBroadphaseHandle());
-
- btBroadphaseInterface* scene = getBroadphase();
-
-
- btCollisionShape* shapeinterface = ctrl->GetCollisionShape();
-
- assert(shapeinterface);
-
- const btTransform& t = ctrl->GetCollisionObject()->getWorldTransform();
-
-
- btVector3 minAabb,maxAabb;
-
- shapeinterface->getAabb(t,minAabb,maxAabb);
-
- float timeStep = 0.02f;
-
-
- //extent it with the motion
-
- if (body)
- {
- btVector3 linMotion = body->getLinearVelocity()*timeStep;
-
- float maxAabbx = maxAabb.getX();
- float maxAabby = maxAabb.getY();
- float maxAabbz = maxAabb.getZ();
- float minAabbx = minAabb.getX();
- float minAabby = minAabb.getY();
- float minAabbz = minAabb.getZ();
-
- if (linMotion.x() > 0.f)
- maxAabbx += linMotion.x();
- else
- minAabbx += linMotion.x();
- if (linMotion.y() > 0.f)
- maxAabby += linMotion.y();
- else
- minAabby += linMotion.y();
- if (linMotion.z() > 0.f)
- maxAabbz += linMotion.z();
- else
- minAabbz += linMotion.z();
-
-
- minAabb = btVector3(minAabbx,minAabby,minAabbz);
- maxAabb = btVector3(maxAabbx,maxAabby,maxAabbz);
- }
-
-
-
}
@@ -1884,29 +1830,20 @@ void CcdPhysicsEnvironment::addSensor(PHY_IPhysicsController* ctrl)
// addCcdPhysicsController(ctrl1);
//}
enableCcdPhysicsController(ctrl1);
-
- //Collision filter/mask is now set at the time of the creation of the controller
- //force collision detection with everything, including static objects (might hurt performance!)
- //ctrl1->GetRigidBody()->getBroadphaseHandle()->m_collisionFilterMask = btBroadphaseProxy::AllFilter ^ btBroadphaseProxy::SensorTrigger;
- //ctrl1->GetRigidBody()->getBroadphaseHandle()->m_collisionFilterGroup = btBroadphaseProxy::SensorTrigger;
- //todo: make this 'sensor'!
-
- requestCollisionCallback(ctrl);
- //printf("addSensor\n");
}
-void CcdPhysicsEnvironment::removeCollisionCallback(PHY_IPhysicsController* ctrl)
+bool CcdPhysicsEnvironment::removeCollisionCallback(PHY_IPhysicsController* ctrl)
{
CcdPhysicsController* ccdCtrl = (CcdPhysicsController*)ctrl;
- if (ccdCtrl->Unregister())
- m_triggerControllers.erase(ccdCtrl);
+ if (!ccdCtrl->Unregister())
+ return false;
+ m_triggerControllers.erase(ccdCtrl);
+ return true;
}
void CcdPhysicsEnvironment::removeSensor(PHY_IPhysicsController* ctrl)
{
- removeCollisionCallback(ctrl);
-
disableCcdPhysicsController((CcdPhysicsController*)ctrl);
}
@@ -1942,12 +1879,14 @@ void CcdPhysicsEnvironment::addTouchCallback(int response_class, PHY_ResponseCal
m_triggerCallbacksUserPtrs[response_class] = user;
}
-void CcdPhysicsEnvironment::requestCollisionCallback(PHY_IPhysicsController* ctrl)
+bool CcdPhysicsEnvironment::requestCollisionCallback(PHY_IPhysicsController* ctrl)
{
CcdPhysicsController* ccdCtrl = static_cast<CcdPhysicsController*>(ctrl);
- if (ccdCtrl->Register())
- m_triggerControllers.insert(ccdCtrl);
+ if (!ccdCtrl->Register())
+ return false;
+ m_triggerControllers.insert(ccdCtrl);
+ return true;
}
void CcdPhysicsEnvironment::CallbackTriggers()
@@ -2096,12 +2035,13 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::CreateSphereController(float radi
// declare this object as Dyamic rather then static!!
// The reason as it is designed to detect all type of object, including static object
// It would cause static-static message to be printed on the console otherwise
- cinfo.m_collisionFlags |= btCollisionObject::CF_NO_CONTACT_RESPONSE/* | btCollisionObject::CF_KINEMATIC_OBJECT*/;
+ cinfo.m_collisionFlags |= btCollisionObject::CF_NO_CONTACT_RESPONSE | btCollisionObject::CF_STATIC_OBJECT;
DefaultMotionState* motionState = new DefaultMotionState();
cinfo.m_MotionState = motionState;
// we will add later the possibility to select the filter from option
cinfo.m_collisionFilterMask = CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::SensorFilter;
cinfo.m_collisionFilterGroup = CcdConstructionInfo::SensorFilter;
+ cinfo.m_bSensor = true;
motionState->m_worldTransform.setIdentity();
motionState->m_worldTransform.setOrigin(btVector3(position[0],position[1],position[2]));
@@ -2555,13 +2495,14 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::CreateConeController(float conera
cinfo.m_collisionShape = new btConeShape(coneradius,coneheight);
cinfo.m_MotionState = 0;
cinfo.m_physicsEnv = this;
- cinfo.m_collisionFlags |= btCollisionObject::CF_NO_CONTACT_RESPONSE;
+ cinfo.m_collisionFlags |= btCollisionObject::CF_NO_CONTACT_RESPONSE | btCollisionObject::CF_STATIC_OBJECT;
DefaultMotionState* motionState = new DefaultMotionState();
cinfo.m_MotionState = motionState;
// we will add later the possibility to select the filter from option
cinfo.m_collisionFilterMask = CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::SensorFilter;
cinfo.m_collisionFilterGroup = CcdConstructionInfo::SensorFilter;
+ cinfo.m_bSensor = true;
motionState->m_worldTransform.setIdentity();
// motionState->m_worldTransform.setOrigin(btVector3(position[0],position[1],position[2]));
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
index 5f9fb9511d6..4e39d531cd6 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
@@ -179,8 +179,8 @@ protected:
virtual void addSensor(PHY_IPhysicsController* ctrl);
virtual void removeSensor(PHY_IPhysicsController* ctrl);
virtual void addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user);
- virtual void requestCollisionCallback(PHY_IPhysicsController* ctrl);
- virtual void removeCollisionCallback(PHY_IPhysicsController* ctrl);
+ virtual bool requestCollisionCallback(PHY_IPhysicsController* ctrl);
+ virtual bool removeCollisionCallback(PHY_IPhysicsController* ctrl);
//These two methods are used *solely* to create controllers for Near/Radar sensor! Don't use for anything else
virtual PHY_IPhysicsController* CreateSphereController(float radius,const PHY__Vector3& position);
virtual PHY_IPhysicsController* CreateConeController(float coneradius,float coneheight);
diff --git a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h
index 397a1ba4218..73e7e947355 100644
--- a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h
+++ b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h
@@ -79,8 +79,8 @@ public:
virtual void addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user)
{
}
- virtual void requestCollisionCallback(PHY_IPhysicsController* ctrl) {}
- virtual void removeCollisionCallback(PHY_IPhysicsController* ctrl) {}
+ virtual bool requestCollisionCallback(PHY_IPhysicsController* ctrl) { return false; }
+ virtual bool removeCollisionCallback(PHY_IPhysicsController* ctrl) { return false;}
virtual PHY_IPhysicsController* CreateSphereController(float radius,const PHY__Vector3& position) {return 0;}
virtual PHY_IPhysicsController* CreateConeController(float coneradius,float coneheight) { return 0;}
diff --git a/source/gameengine/Physics/Sumo/SumoPhysicsController.cpp b/source/gameengine/Physics/Sumo/SumoPhysicsController.cpp
index 3451e6c3ec8..56caa9236bf 100644
--- a/source/gameengine/Physics/Sumo/SumoPhysicsController.cpp
+++ b/source/gameengine/Physics/Sumo/SumoPhysicsController.cpp
@@ -390,6 +390,11 @@ void SumoPhysicsController::PostProcessReplica(class PHY_IMotionState* motionst
m_sumoScene->add(* (m_sumoObj));
}
+PHY_IMotionState* SumoPhysicsController::GetMotionState()
+{
+ return m_MotionState;
+}
+
void SumoPhysicsController::SetSimulatedTime(float)
{
}
diff --git a/source/gameengine/Physics/Sumo/SumoPhysicsController.h b/source/gameengine/Physics/Sumo/SumoPhysicsController.h
index 415bc1e3982..adf29649f18 100644
--- a/source/gameengine/Physics/Sumo/SumoPhysicsController.h
+++ b/source/gameengine/Physics/Sumo/SumoPhysicsController.h
@@ -110,6 +110,7 @@ public:
virtual void WriteDynamicsToMotionState() {};
virtual void WriteMotionStateToDynamics(bool nondynaonly);
+ virtual class PHY_IMotionState* GetMotionState();
/**
* call from Scene Graph Node to 'update'.
diff --git a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp
index cc6d5654ec9..b4daf0a3f80 100644
--- a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp
+++ b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp
@@ -213,7 +213,7 @@ void SumoPhysicsEnvironment::addTouchCallback(int response_class, PHY_ResponseCa
m_sumoScene->addTouchCallback(sumoRespClass,SumoPHYCallbackBridge::StaticSolidToPHYCallback,bridge);
}
-void SumoPhysicsEnvironment::requestCollisionCallback(PHY_IPhysicsController* ctrl)
+bool SumoPhysicsEnvironment::requestCollisionCallback(PHY_IPhysicsController* ctrl)
{
SumoPhysicsController* smctrl = dynamic_cast<SumoPhysicsController*>(ctrl);
MT_assert(smctrl);
@@ -225,12 +225,15 @@ void SumoPhysicsEnvironment::requestCollisionCallback(PHY_IPhysicsController* ct
smObject->setPhysicsClientObject(ctrl);
m_sumoScene->requestCollisionCallback(*smObject);
+ return true;
}
+ return false;
}
-void SumoPhysicsEnvironment::removeCollisionCallback(PHY_IPhysicsController* ctrl)
+bool SumoPhysicsEnvironment::removeCollisionCallback(PHY_IPhysicsController* ctrl)
{
// intentionally empty
+ return false;
}
PHY_IPhysicsController* SumoPhysicsEnvironment::CreateSphereController(float radius,const PHY__Vector3& position)
diff --git a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h
index c2b443a2b38..4c9d59e3673 100644
--- a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h
+++ b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h
@@ -83,8 +83,8 @@ public:
virtual void addSensor(PHY_IPhysicsController* ctrl);
virtual void removeSensor(PHY_IPhysicsController* ctrl);
virtual void addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user);
- virtual void requestCollisionCallback(PHY_IPhysicsController* ctrl);
- virtual void removeCollisionCallback(PHY_IPhysicsController* ctrl);
+ virtual bool requestCollisionCallback(PHY_IPhysicsController* ctrl);
+ virtual bool removeCollisionCallback(PHY_IPhysicsController* ctrl);
virtual PHY_IPhysicsController* CreateSphereController(float radius,const PHY__Vector3& position);
virtual PHY_IPhysicsController* CreateConeController(float coneradius,float coneheight);
diff --git a/source/gameengine/Physics/common/PHY_IMotionState.h b/source/gameengine/Physics/common/PHY_IMotionState.h
index 64bb810ee7c..f7bcbd4f2d0 100644
--- a/source/gameengine/Physics/common/PHY_IMotionState.h
+++ b/source/gameengine/Physics/common/PHY_IMotionState.h
@@ -45,10 +45,12 @@ class PHY_IMotionState
virtual void getWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal)=0;
// ori = array 12 floats, [0..3] = first column + 0, [4..7] = second colum, [8..11] = third column
virtual void getWorldOrientation(float* ori)=0;
+ virtual void setWorldOrientation(const float* ori)=0;
virtual void setWorldPosition(float posX,float posY,float posZ)=0;
virtual void setWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal)=0;
+
virtual void calculateWorldTransformations()=0;
};
diff --git a/source/gameengine/Physics/common/PHY_IPhysicsController.h b/source/gameengine/Physics/common/PHY_IPhysicsController.h
index 770426b48db..d7b8cb0b54f 100644
--- a/source/gameengine/Physics/common/PHY_IPhysicsController.h
+++ b/source/gameengine/Physics/common/PHY_IPhysicsController.h
@@ -31,7 +31,7 @@
#include "PHY_IController.h"
-
+class PHY_IMotionState;
/**
PHY_IPhysicsController is the abstract simplified Interface to a physical object.
@@ -53,6 +53,7 @@ class PHY_IPhysicsController : public PHY_IController
virtual void WriteMotionStateToDynamics(bool nondynaonly)=0;
virtual void WriteDynamicsToMotionState()=0;
+ virtual class PHY_IMotionState* GetMotionState() = 0;
// controller replication
virtual void PostProcessReplica(class PHY_IMotionState* motionstate,class PHY_IPhysicsController* parentctrl)=0;
diff --git a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h
index a3605669f70..1939083ef5f 100644
--- a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h
+++ b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h
@@ -152,8 +152,8 @@ class PHY_IPhysicsEnvironment
virtual void addSensor(PHY_IPhysicsController* ctrl)=0;
virtual void removeSensor(PHY_IPhysicsController* ctrl)=0;
virtual void addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user)=0;
- virtual void requestCollisionCallback(PHY_IPhysicsController* ctrl)=0;
- virtual void removeCollisionCallback(PHY_IPhysicsController* ctrl)=0;
+ virtual bool requestCollisionCallback(PHY_IPhysicsController* ctrl)=0;
+ virtual bool removeCollisionCallback(PHY_IPhysicsController* ctrl)=0;
//These two methods are *solely* used to create controllers for sensor! Don't use for anything else
virtual PHY_IPhysicsController* CreateSphereController(float radius,const PHY__Vector3& position) =0;
virtual PHY_IPhysicsController* CreateConeController(float coneradius,float coneheight)=0;
diff --git a/source/gameengine/SceneGraph/SG_IObject.h b/source/gameengine/SceneGraph/SG_IObject.h
index b4dd9a9ddf2..8f448a0e890 100644
--- a/source/gameengine/SceneGraph/SG_IObject.h
+++ b/source/gameengine/SceneGraph/SG_IObject.h
@@ -203,6 +203,13 @@ public:
return m_SGcontrollers;
}
+ /**
+ *
+ */
+ SG_Callbacks& GetCallBackFunctions()
+ {
+ return m_callbacks;
+ }
/**
* Get the client object associated with this
diff --git a/source/gameengine/SceneGraph/SG_Spatial.h b/source/gameengine/SceneGraph/SG_Spatial.h
index d1fc95cceac..6e274487c9d 100644
--- a/source/gameengine/SceneGraph/SG_Spatial.h
+++ b/source/gameengine/SceneGraph/SG_Spatial.h
@@ -148,6 +148,13 @@ public:
SetModified();
}
+ // rot is arrange like openGL matrix
+ void SetLocalOrientation(const float* rot)
+ {
+ m_localRotation.setValue(rot);
+ SetModified();
+ }
+
void SetWorldOrientation(const MT_Matrix3x3& rot)
{
m_worldRotation = rot;