added some 'angularFactor' for character control (to avoid rotation)
This commit is contained in:
@@ -35,6 +35,7 @@ btRigidBody::btRigidBody(float mass, btMotionState* motionState, btCollisionShap
|
||||
m_totalTorque(0.0f, 0.0f, 0.0f),
|
||||
m_linearVelocity(0.0f, 0.0f, 0.0f),
|
||||
m_angularVelocity(0.f,0.f,0.f),
|
||||
m_angularFactor(1.f),
|
||||
m_linearDamping(0.f),
|
||||
m_angularDamping(0.5f),
|
||||
m_optionalMotionState(motionState),
|
||||
|
@@ -47,6 +47,7 @@ class btRigidBody : public btCollisionObject
|
||||
btVector3 m_linearVelocity;
|
||||
btVector3 m_angularVelocity;
|
||||
btScalar m_inverseMass;
|
||||
btScalar m_angularFactor;
|
||||
|
||||
btVector3 m_gravity;
|
||||
btVector3 m_invInertiaLocal;
|
||||
@@ -159,7 +160,10 @@ public:
|
||||
if (m_inverseMass != 0.f)
|
||||
{
|
||||
applyCentralImpulse(impulse);
|
||||
applyTorqueImpulse(rel_pos.cross(impulse));
|
||||
if (m_angularFactor)
|
||||
{
|
||||
applyTorqueImpulse(rel_pos.cross(impulse)*m_angularFactor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,7 +173,10 @@ public:
|
||||
if (m_inverseMass != 0.f)
|
||||
{
|
||||
m_linearVelocity += linearComponent*impulseMagnitude;
|
||||
m_angularVelocity += angularComponent*impulseMagnitude;
|
||||
if (m_angularFactor)
|
||||
{
|
||||
m_angularVelocity += angularComponent*impulseMagnitude*m_angularFactor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,6 +328,14 @@ public:
|
||||
int m_contactSolverType;
|
||||
int m_frictionSolverType;
|
||||
|
||||
void setAngularFactor(float angFac)
|
||||
{
|
||||
m_angularFactor = angFac;
|
||||
}
|
||||
float getAngularFactor() const
|
||||
{
|
||||
return m_angularFactor;
|
||||
}
|
||||
|
||||
|
||||
int m_debugBodyId;
|
||||
|
@@ -1156,9 +1156,8 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
|
||||
physicscontroller->GetRigidBody()->updateInertiaTensor();
|
||||
*/
|
||||
|
||||
env->createConstraint(physicscontroller,0,PHY_ANGULAR_CONSTRAINT,0,0,0,0,0,1);
|
||||
|
||||
|
||||
//env->createConstraint(physicscontroller,0,PHY_ANGULAR_CONSTRAINT,0,0,0,0,0,1);
|
||||
physicscontroller->GetRigidBody()->setAngularFactor(0.f);
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user