Disabled the upright constraint during an explosion, tweaked
parameters somewhat, and made the new explosion code the default. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1888 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
683d423113
commit
17d20ee73f
src
@ -97,10 +97,11 @@ btUprightConstraint::btUprightConstraint(btRigidBody& rbA, const btTransform& fr
|
||||
m_damping = 1.0f;
|
||||
m_limitSoftness = 1.0f;
|
||||
m_maxLimitForce = 3000.0f;
|
||||
m_disable_time = 0.0f;
|
||||
m_limit[0].m_accumulatedImpulse = 0.0f;
|
||||
m_limit[1].m_accumulatedImpulse = 0.0f;
|
||||
m_limit[ 0 ].m_axis = btVector3( 1, 0, 0 );
|
||||
m_limit[ 1 ].m_axis = btVector3( 0, 1, 0 );
|
||||
m_limit[ 0 ].m_axis = btVector3( 1, 0, 0 );
|
||||
m_limit[ 1 ].m_axis = btVector3( 0, 1, 0 );
|
||||
setLimit( SIMD_PI * 0.4f );
|
||||
}
|
||||
|
||||
@ -138,6 +139,14 @@ void btUprightConstraint::solveConstraint(btScalar timeStep)
|
||||
{
|
||||
m_timeStep = timeStep;
|
||||
|
||||
// Update disable time and return if constraint is still disabled
|
||||
if(m_disable_time>0.0f)
|
||||
{
|
||||
m_disable_time -= timeStep;
|
||||
printf("m_disable %f timestep %f\n", m_disable_time, timeStep);
|
||||
if(m_disable_time>0.0f) return;
|
||||
}
|
||||
|
||||
solveAngularLimit( &m_limit[ 0 ], m_timeStep, btScalar(1.) / m_jacAng[ 0 ].getDiagonal(), &m_rbA );
|
||||
solveAngularLimit( &m_limit[ 1 ], m_timeStep, btScalar(1.) / m_jacAng[ 1 ].getDiagonal(), &m_rbA );
|
||||
}
|
||||
|
@ -63,6 +63,7 @@ protected:
|
||||
btScalar m_limitSoftness;
|
||||
btScalar m_hiLimit;
|
||||
btScalar m_loLimit;
|
||||
btScalar m_disable_time;
|
||||
|
||||
btUprightConstraintLimit m_limit[ 2 ];
|
||||
|
||||
@ -118,6 +119,10 @@ public:
|
||||
{
|
||||
m_damping = damping;
|
||||
}
|
||||
void setDisableTime( btScalar t )
|
||||
{
|
||||
m_disable_time = t;
|
||||
}
|
||||
|
||||
virtual void buildJacobian();
|
||||
virtual void solveConstraint(btScalar timeStep);
|
||||
|
14
src/kart.cpp
14
src/kart.cpp
@ -484,18 +484,14 @@ void Kart::handleExplosion(const btVector3& pos, bool direct_hit)
|
||||
{
|
||||
if(direct_hit)
|
||||
{
|
||||
#define WILD_EXPLOSION
|
||||
#ifdef WILD_EXPLOSION
|
||||
btVector3 diff(rand()%16/16, rand()%16/16, 2.0f);
|
||||
btVector3 diff((float)(rand()%16/16), (float)(rand()%16/16), 2.0f);
|
||||
diff.normalize();
|
||||
diff*=stk_config->m_explosion_impulse/5.0f;
|
||||
this->m_uprightConstraint->setDisableTime(10.0f);
|
||||
getVehicle()->getRigidBody()->applyCentralImpulse(diff);
|
||||
getVehicle()->getRigidBody()->applyTorqueImpulse(btVector3(rand()%32*M_PI,
|
||||
rand()%32*M_PI,
|
||||
rand()%32*M_PI));
|
||||
#else
|
||||
forceRescue();
|
||||
#endif
|
||||
getVehicle()->getRigidBody()->applyTorqueImpulse(btVector3(float(rand()%32*5),
|
||||
float(rand()%32*5),
|
||||
float(rand()%32*5)));
|
||||
}
|
||||
else // only affected by a distant explosion
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user