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-01-01 00:59:56 +0300
committerErwin Coumans <blender@erwincoumans.com>2006-01-01 00:59:56 +0300
commitbab1b90edc55251ceb5e3033d588347b48cceca4 (patch)
tree11a6863f68de3db92bbbfab77ca45c8603e5f5cf
parent9119b6e8a547303ce9a7ccd3a00636153b53cb0e (diff)
more game engine bug-fixes, hooked up 'formfactor' as inertia tensor tweaker, friction/restitution, more scaling related fixes.
-rw-r--r--extern/bullet/BulletDynamics/ConstraintSolver/ContactConstraint.cpp4
-rw-r--r--extern/bullet/BulletDynamics/Dynamics/ContactJoint.cpp2
-rw-r--r--source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp4
-rw-r--r--source/gameengine/Ketsji/KX_KetsjiEngine.cpp11
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsController.cpp21
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsController.h8
6 files changed, 36 insertions, 14 deletions
diff --git a/extern/bullet/BulletDynamics/ConstraintSolver/ContactConstraint.cpp b/extern/bullet/BulletDynamics/ConstraintSolver/ContactConstraint.cpp
index be6793dc192..0c400a84dca 100644
--- a/extern/bullet/BulletDynamics/ConstraintSolver/ContactConstraint.cpp
+++ b/extern/bullet/BulletDynamics/ConstraintSolver/ContactConstraint.cpp
@@ -27,8 +27,8 @@ SimdScalar contactTau = .02f;//0.02f;//*0.02f;
SimdScalar restitutionCurve(SimdScalar rel_vel, SimdScalar restitution)
{
- return 0.f;
-// return restitution * GEN_min(1.0f, rel_vel / ContactThreshold);
+// return 0.f;
+ return restitution * GEN_min(1.0f, rel_vel / ContactThreshold);
}
diff --git a/extern/bullet/BulletDynamics/Dynamics/ContactJoint.cpp b/extern/bullet/BulletDynamics/Dynamics/ContactJoint.cpp
index b60b4eefe34..0a988adcc75 100644
--- a/extern/bullet/BulletDynamics/Dynamics/ContactJoint.cpp
+++ b/extern/bullet/BulletDynamics/Dynamics/ContactJoint.cpp
@@ -165,7 +165,7 @@ void ContactJoint::GetInfo2(Info2 *info)
c2[2] = ccc2[2];
- float friction = 10.1f;//FRICTION_CONSTANT*m_body0->getFriction() * m_body1->getFriction();
+ float friction = FRICTION_CONSTANT*m_body0->getFriction() * m_body1->getFriction();
// first friction direction
if (m_numRows >= 2)
diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
index 646fc93dadb..71a80e01f3b 100644
--- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
+++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
@@ -1014,14 +1014,14 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
ci.m_collisionShape = bm;
ci.m_broadphaseHandle = 0;
- ci.m_friction = smmaterial->m_friction;
+ ci.m_friction = 5.f* smmaterial->m_friction;//tweak the friction a bit, so the default 0.5 works nice
ci.m_restitution = smmaterial->m_restitution;
ci.m_physicsEnv = env;
// drag / damping is inverted
ci.m_linearDamping = 1.f - shapeprops->m_lin_drag;
ci.m_angularDamping = 1.f - shapeprops->m_ang_drag;
//need a bit of damping, else system doesn't behave well
-
+ ci.m_inertiaFactor = shapeprops->m_inertia/0.4f;//defaults to 0.4, don't want to change behaviour
KX_BulletPhysicsController* physicscontroller = new KX_BulletPhysicsController(ci,isbulletdyna);
diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
index e82ecd83fee..bd7ce6cc36d 100644
--- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
+++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
@@ -364,10 +364,14 @@ void KX_KetsjiEngine::NextFrame()
scene->setSuspendedDelta(scene->getSuspendedDelta()+curtime-scene->getSuspendedTime());
m_suspendeddelta = scene->getSuspendedDelta();
- m_logger->StartLog(tc_physics, m_kxsystem->GetTimeInSeconds(), true);
+
m_logger->StartLog(tc_network, m_kxsystem->GetTimeInSeconds(), true);
scene->GetNetworkScene()->proceed(localtime);
+ m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true);
+ scene->UpdateParents(localtime);
+
+ m_logger->StartLog(tc_physics, m_kxsystem->GetTimeInSeconds(), true);
// set Python hooks for each scene
PHY_SetActiveEnvironment(scene->GetPhysicsEnvironment());
PHY_SetActiveScene(scene);
@@ -399,11 +403,11 @@ void KX_KetsjiEngine::NextFrame()
m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true);
scene->UpdateParents(localtime);
+ m_logger->StartLog(tc_physics, m_kxsystem->GetTimeInSeconds(), true);
scene->GetPhysicsEnvironment()->beginFrame();
// Perform physics calculations on the scene. This can involve
// many iterations of the physics solver.
- m_logger->StartLog(tc_physics, m_kxsystem->GetTimeInSeconds(), true);
scene->GetPhysicsEnvironment()->proceedDeltaTime(localtime,realDeltaTime);
m_previoustime = curtime;
@@ -462,6 +466,9 @@ void KX_KetsjiEngine::NextFrame()
PHY_SetActiveEnvironment(scene->GetPhysicsEnvironment());
PHY_SetActiveScene(scene);
+ m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true);
+ scene->UpdateParents(curtime);
+
// Perform physics calculations on the scene. This can involve
// many iterations of the physics solver.
m_logger->StartLog(tc_physics, m_kxsystem->GetTimeInSeconds(), true);
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
index bb4f1465b2d..ee3b0ffb528 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
@@ -63,7 +63,7 @@ void CcdPhysicsController::CreateRigidbody()
// init the rigidbody properly
//
- m_body->setMassProps(m_cci.m_mass, m_cci.m_localInertiaTensor);
+ m_body->setMassProps(m_cci.m_mass, m_cci.m_localInertiaTensor * m_cci.m_inertiaFactor);
m_body->setGravity( m_cci.m_gravity);
m_body->setDamping(m_cci.m_linearDamping, m_cci.m_angularDamping);
m_body->setCenterOfMassTransform( trans );
@@ -237,15 +237,26 @@ void CcdPhysicsController::resolveCombinedVelocities(float linvelX,float linvel
void CcdPhysicsController::getPosition(PHY__Vector3& pos) const
{
- assert(0);
+ const SimdTransform& xform = m_body->getCenterOfMassTransform();
+ pos[0] = xform.getOrigin().x();
+ pos[1] = xform.getOrigin().y();
+ pos[2] = xform.getOrigin().z();
}
void CcdPhysicsController::setScaling(float scaleX,float scaleY,float scaleZ)
{
- if (m_body && m_body->GetCollisionShape())
+ if (!SimdFuzzyZero(m_cci.m_scaling.x()-scaleX) ||
+ !SimdFuzzyZero(m_cci.m_scaling.y()-scaleY) ||
+ !SimdFuzzyZero(m_cci.m_scaling.z()-scaleZ))
{
- SimdVector3 scaling(scaleX,scaleY,scaleZ);
- m_body->GetCollisionShape()->setLocalScaling(scaling);
+ m_cci.m_scaling = SimdVector3(scaleX,scaleY,scaleZ);
+
+ if (m_body && m_body->GetCollisionShape())
+ {
+ m_body->GetCollisionShape()->setLocalScaling(m_cci.m_scaling);
+ m_body->GetCollisionShape()->CalculateLocalInertia(m_cci.m_mass, m_cci.m_localInertiaTensor);
+ m_body->setMassProps(m_cci.m_mass, m_cci.m_localInertiaTensor * m_cci.m_inertiaFactor);
+ }
}
}
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h
index 87290f65fb4..3becd14028a 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h
@@ -29,12 +29,15 @@ struct CcdConstructionInfo
m_angularDamping(0.1f),
m_MotionState(0),
m_collisionShape(0),
- m_physicsEnv(0)
-
+ m_physicsEnv(0),
+ m_inertiaFactor(1.f),
+ m_scaling(1.f,1.f,1.f)
{
}
+
SimdVector3 m_localInertiaTensor;
SimdVector3 m_gravity;
+ SimdVector3 m_scaling;
SimdScalar m_mass;
SimdScalar m_restitution;
SimdScalar m_friction;
@@ -45,6 +48,7 @@ struct CcdConstructionInfo
CollisionShape* m_collisionShape;
CcdPhysicsEnvironment* m_physicsEnv; //needed for self-replication
+ float m_inertiaFactor;//tweak the inertia (hooked up to Blender 'formfactor'
};