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>2006-12-01 06:29:20 +0300
committerErwin Coumans <blender@erwincoumans.com>2006-12-01 06:29:20 +0300
commit610026765bbd121fe55a30b19117a28f13769503 (patch)
tree6448798152866ebaad0d7021439e08911e43f3be /source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
parent71da111613758d289209a5df64f722f8c0926767 (diff)
some Bullet compound shape fix
Diffstat (limited to 'source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp143
1 files changed, 75 insertions, 68 deletions
diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
index e7a33fafffb..145b4eb4750 100644
--- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
+++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
@@ -872,7 +872,6 @@ static btCollisionShape* CreateBulletShapeFromMesh(RAS_MeshObject* meshobj, bool
}
-
void KX_ConvertBulletObject( class KX_GameObject* gameobj,
class RAS_MeshObject* meshobj,
class KX_Scene* kxscene,
@@ -884,11 +883,29 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
CcdPhysicsEnvironment* env = (CcdPhysicsEnvironment*)kxscene->GetPhysicsEnvironment();
assert(env);
- bool isbulletdyna = objprop->m_dyna;
+
+ bool isbulletdyna = false;
CcdConstructionInfo ci;
+ class PHY_IMotionState* motionstate = new KX_MotionState(gameobj->GetSGNode());
+
+
+
+ if (!objprop->m_dyna)
+ {
+ ci.m_collisionFlags |= btCollisionObject::CF_STATIC_OBJECT;
+ }
+
+ ci.m_MotionState = motionstate;
+ ci.m_gravity = btVector3(0,0,0);
ci.m_localInertiaTensor =btVector3(0,0,0);
ci.m_mass = objprop->m_dyna ? shapeprops->m_mass : 0.f;
-
+ isbulletdyna = objprop->m_dyna;
+
+ ci.m_localInertiaTensor = btVector3(ci.m_mass/3.f,ci.m_mass/3.f,ci.m_mass/3.f);
+
+ btTransform trans;
+ trans.setIdentity();
+
btCollisionShape* bm = 0;
switch (objprop->m_boundclass)
@@ -1004,57 +1021,63 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
bm->setMargin(0.06);
- if (objprop->m_isCompoundChild)
- {
- //find parent, compound shape and add to it
- //take relative transform into account!
- KX_BulletPhysicsController* parentCtrl = (KX_BulletPhysicsController*)objprop->m_dynamic_parent->GetPhysicsController();
- assert(parentCtrl);
- btRigidBody* rigidbody = parentCtrl->GetRigidBody();
- btCollisionShape* colShape = rigidbody->getCollisionShape();
- assert(colShape->isCompound());
- btCompoundShape* compoundShape = (btCompoundShape*)colShape;
- btTransform childTrans;
- childTrans.setIdentity();
- NodeList& children = objprop->m_dynamic_parent->GetSGNode()->GetSGChildren();
-
- MT_Point3 childPos = gameobj->GetSGNode()->GetLocalPosition();
- MT_Matrix3x3 childRot = gameobj->GetSGNode()->GetLocalOrientation();
- MT_Vector3 childScale = gameobj->GetSGNode()->GetLocalScale();
-
- bm->setLocalScaling(btVector3(childScale.x(),childScale.y(),childScale.z()));
- childTrans.setOrigin(btVector3(childPos.x(),childPos.y(),childPos.z()));
- float rotval[12];
- childRot.getValue(rotval);
- btMatrix3x3 newRot;
- newRot.setValue(rotval[0],rotval[1],rotval[2],rotval[4],rotval[5],rotval[6],rotval[8],rotval[9],rotval[10]);
- newRot = newRot.transpose();
-
- childTrans.setBasis(newRot);
-
- compoundShape->addChildShape(childTrans,bm);
- //do some recalc?
- //recalc inertia for rigidbody
- if (!rigidbody->isStaticOrKinematicObject())
+
+ if (objprop->m_isCompoundChild)
{
- btVector3 localInertia;
- float mass = 1.f/rigidbody->getInvMass();
- compoundShape->calculateLocalInertia(mass,localInertia);
- rigidbody->setMassProps(mass,localInertia);
+ //find parent, compound shape and add to it
+ //take relative transform into account!
+ KX_BulletPhysicsController* parentCtrl = (KX_BulletPhysicsController*)objprop->m_dynamic_parent->GetPhysicsController();
+ assert(parentCtrl);
+ btRigidBody* rigidbody = parentCtrl->GetRigidBody();
+ btCollisionShape* colShape = rigidbody->getCollisionShape();
+ assert(colShape->isCompound());
+ btCompoundShape* compoundShape = (btCompoundShape*)colShape;
+ btTransform childTrans;
+ childTrans.setIdentity();
+ NodeList& children = objprop->m_dynamic_parent->GetSGNode()->GetSGChildren();
+
+ MT_Point3 childPos = gameobj->GetSGNode()->GetLocalPosition();
+ MT_Matrix3x3 childRot = gameobj->GetSGNode()->GetLocalOrientation();
+ MT_Vector3 childScale = gameobj->GetSGNode()->GetLocalScale();
+
+ bm->setLocalScaling(btVector3(childScale.x(),childScale.y(),childScale.z()));
+ childTrans.setOrigin(btVector3(childPos.x(),childPos.y(),childPos.z()));
+ float rotval[12];
+ childRot.getValue(rotval);
+ btMatrix3x3 newRot;
+ newRot.setValue(rotval[0],rotval[1],rotval[2],rotval[4],rotval[5],rotval[6],rotval[8],rotval[9],rotval[10]);
+ newRot = newRot.transpose();
+
+ childTrans.setBasis(newRot);
+
+
+ compoundShape->addChildShape(childTrans,bm);
+ //do some recalc?
+ //recalc inertia for rigidbody
+ if (!rigidbody->isStaticOrKinematicObject())
+ {
+ btVector3 localInertia;
+ float mass = 1.f/rigidbody->getInvMass();
+ compoundShape->calculateLocalInertia(mass,localInertia);
+ rigidbody->setMassProps(mass,localInertia);
+ }
+ return;
}
- return;
- }
- if (objprop->m_hasCompoundChildren)
- {
- //replace shape by compoundShape
- btCompoundShape* compoundShape = new btCompoundShape();
- btTransform identTrans;
- identTrans.setIdentity();
- compoundShape->addChildShape(identTrans,bm);
- bm = compoundShape;
- }
+ if (objprop->m_hasCompoundChildren)
+ {
+ //replace shape by compoundShape
+ btCompoundShape* compoundShape = new btCompoundShape();
+ btTransform identTrans;
+ identTrans.setIdentity();
+ compoundShape->addChildShape(identTrans,bm);
+ bm = compoundShape;
+ }
+
+
+
+
#ifdef TEST_SIMD_HULL
@@ -1087,23 +1110,6 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
ci.m_collisionShape = bm;
- class PHY_IMotionState* motionstate = new KX_MotionState(gameobj->GetSGNode());
-
- if (!objprop->m_dyna)
- {
- ci.m_collisionFlags |= btCollisionObject::CF_STATIC_OBJECT;
- }
-
-
- ci.m_MotionState = motionstate;
- ci.m_gravity = btVector3(0,0,0);
-
- ci.m_localInertiaTensor = btVector3(ci.m_mass/3.f,ci.m_mass/3.f,ci.m_mass/3.f);
-
- btTransform trans;
- trans.setIdentity();
-
-
ci.m_friction = smmaterial->m_friction;//tweak the friction a bit, so the default 0.5 works nice
ci.m_restitution = smmaterial->m_restitution;
@@ -1175,7 +1181,8 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
physicscontroller->SetObject(gameobj->GetSGNode());
}
-
+
+
void KX_ClearBulletSharedShapes()
{
int numshapes = map_gamemesh_to_bulletshape.size();