diff options
author | Erwin Coumans <blender@erwincoumans.com> | 2009-06-06 04:12:49 +0400 |
---|---|---|
committer | Erwin Coumans <blender@erwincoumans.com> | 2009-06-06 04:12:49 +0400 |
commit | 884a6a6573c08d2d0fe7f44994b8a874f45d68f2 (patch) | |
tree | c10be5dc6361472c265ce19556cb1349fd80a472 /source/gameengine/Physics/Bullet | |
parent | 04ccb0caf847b29542618a903f0e4243270f8c82 (diff) |
#18872 bugfix for torque on dynamic objects
#18893, fix to getParam for generic 6dof constraints
Diffstat (limited to 'source/gameengine/Physics/Bullet')
3 files changed, 46 insertions, 5 deletions
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index 3a3c817698b..d22c09b4d3e 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -1019,7 +1019,8 @@ void CcdPhysicsController::ApplyTorque(float torqueX,float torqueY,float torque //workaround for incompatibility between 'DYNAMIC' game object, and angular factor //a DYNAMIC object has some inconsistency: it has no angular effect due to collisions, but still has torque const btVector3& angFac = body->getAngularFactor(); - body->setAngularFactor(1.f); + btVector3 tmpFac(0,0,1); + body->setAngularFactor(tmpFac); body->applyTorque(torque); body->setAngularFactor(angFac); } diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 2dc7bffe618..bc7ccacc39b 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -1786,6 +1786,45 @@ CcdPhysicsEnvironment::~CcdPhysicsEnvironment() } +float CcdPhysicsEnvironment::getConstraintParam(int constraintId,int param) +{ + btTypedConstraint* typedConstraint = getConstraintById(constraintId); + switch (typedConstraint->getUserConstraintType()) + { + case PHY_GENERIC_6DOF_CONSTRAINT: + { + + switch (param) + { + case 0: case 1: case 2: + { + //param = 0..2 are linear constraint values + btGeneric6DofConstraint* genCons = (btGeneric6DofConstraint*)typedConstraint; + genCons->calculateTransforms(); + return genCons->getRelativePivotPosition(param); + break; + } + case 3: case 4: case 5: + { + //param = 3..5 are relative constraint (Euler) angles + btGeneric6DofConstraint* genCons = (btGeneric6DofConstraint*)typedConstraint; + genCons->calculateTransforms(); + return genCons->getAngle(param-3); + break; + } + default: + { + } + } + break; + }; + default: + { + }; + }; + return 0.f; +} + void CcdPhysicsEnvironment::setConstraintParam(int constraintId,int param,float value0,float value1) { btTypedConstraint* typedConstraint = getConstraintById(constraintId); @@ -1835,11 +1874,9 @@ void CcdPhysicsEnvironment::setConstraintParam(int constraintId,int param,float { bool springEnabled = true; genCons->setStiffness(springIndex,value0); + genCons->setDamping(springIndex,value1); genCons->enableSpring(springIndex,springEnabled); - if (value1>0.5f) - { - genCons->setEquilibriumPoint(springIndex); - } + genCons->setEquilibriumPoint(springIndex); } else { bool springEnabled = false; diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h index 4e39d531cd6..bc5491e00cc 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h @@ -149,7 +149,10 @@ protected: const btVector3& angularMaxLimits,int flags ); + virtual void setConstraintParam(int constraintId,int param,float value,float value1); + + virtual float getConstraintParam(int constraintId,int param); virtual void removeConstraint(int constraintid); |