More work on skidding (still disabled by default).
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@10686 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
2a741992e2
commit
79e2b7d0ae
@ -169,12 +169,14 @@
|
||||
post-skid-rotate-factor: a factor to be used to determine how much
|
||||
the chassis of a kart should rotate to match the graphical view.
|
||||
A factor of 1 is identical, a smaller factor will rotate the kart
|
||||
less (which might feel better). -->
|
||||
less (which might feel better).
|
||||
reduce-turn: A factor that's multiplied to the steering when skidding,
|
||||
which is used to reduce the turn angle used to reduce the turn angle. -->
|
||||
<skid increase="1.05" decrease="0.95" max="2.5" time-till-max="0.4"
|
||||
visual="0.16" visual-time="0"
|
||||
visual="1.9" visual-time="0"
|
||||
angular-velocity="0" time-till-bonus="1.5 2"
|
||||
bonus-force="100 200" bonus-time="3.0 3.0"
|
||||
post-skid-rotate-factor="1" />
|
||||
post-skid-rotate-factor="0.33" reduce-turn="0.6"/>
|
||||
|
||||
<!-- Slipstream: length: How far behind a kart slipstream works
|
||||
collect-time: How many seconds of sstream give maximum benefit
|
||||
|
@ -1611,19 +1611,20 @@ void Kart::updatePhysics(float dt)
|
||||
updateSkidding(dt);
|
||||
updateSliding();
|
||||
|
||||
float steering;
|
||||
float steering = getMaxSteerAngle() * m_controls.m_steer;
|
||||
// FIXME: Misuse (for now) the skid visual time to disable the new
|
||||
// skidding code
|
||||
if(m_kart_properties->getSkidVisualTime()==0)
|
||||
{
|
||||
steering = getMaxSteerAngle() * m_controls.m_steer*m_skidding;
|
||||
steering *= m_skidding;
|
||||
}
|
||||
else if(m_controls.m_drift)
|
||||
{
|
||||
steering = getMaxSteerAngle() * m_controls.m_steer/sqrt(m_skidding)*1.2f;
|
||||
steering *= m_kart_properties->getSkidReduceTurn()
|
||||
* sqrt(m_kart_properties->getMaxSkid()/m_skidding);
|
||||
}
|
||||
else
|
||||
steering = getMaxSteerAngle() * m_controls.m_steer*m_skidding*m_skidding;
|
||||
steering *= m_skidding;
|
||||
|
||||
m_vehicle->setSteeringValue(steering, 0);
|
||||
m_vehicle->setSteeringValue(steering, 1);
|
||||
@ -1782,20 +1783,20 @@ void Kart::updateSkidding(float dt)
|
||||
else if(m_skid_time>0 &&
|
||||
// FIXME hiker: remove once the new skidding code is finished.
|
||||
m_kart_properties->getSkidVisualTime()>0)
|
||||
// See if a skid bonus is applied
|
||||
{
|
||||
{
|
||||
// The kart just stopped skidding - see if a skid bonus applies
|
||||
float bonus_time, bonus_force;
|
||||
m_kart_properties->getSkidBonus(m_skid_time,
|
||||
&bonus_time, &bonus_force);
|
||||
// Set skid_time to a negative value indicating how long an
|
||||
// additional rotation is going to be applied to the chassis
|
||||
float t = (m_skid_time <= m_kart_properties->getSkidVisualTime())
|
||||
? m_skid_time
|
||||
: m_kart_properties->getSkidVisualTime();
|
||||
float vso = getVisualSkidOffset();
|
||||
btVector3 rot(0, vso*m_kart_properties->getPostSkidRotateFactor(), 0);
|
||||
m_vehicle->setTimedRotation(t, rot);
|
||||
m_skid_time = 0;
|
||||
// Set skid_time to a negative value indicating how long an
|
||||
// additional rotation is going to be applied to the chassis
|
||||
m_skid_time = -t;
|
||||
if(bonus_time>0)
|
||||
{
|
||||
MaxSpeed::increaseMaxSpeed(MaxSpeed::MS_INCREASE_SKIDDING,
|
||||
@ -2235,15 +2236,22 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz,
|
||||
*/
|
||||
float Kart::getVisualSkidOffset() const
|
||||
{
|
||||
float speed_ratio = getSpeed()/MaxSpeed::getCurrentMaxSpeed();
|
||||
//if(m_kart_properties->getSkidVisualTime()==0)
|
||||
return getSteerPercent()*m_kart_properties->getSkidVisual()
|
||||
* speed_ratio * m_skidding*m_skidding;
|
||||
float f = fabsf(m_skid_time);
|
||||
if(f>m_kart_properties->getSkidVisualTime())
|
||||
f = m_kart_properties->getSkidVisualTime();
|
||||
return getSteerPercent()*m_kart_properties->getSkidVisual()
|
||||
* speed_ratio * sqrt(f/m_kart_properties->getSkidVisualTime());
|
||||
float speed_ratio = getSpeed()/MaxSpeed::getCurrentMaxSpeed();
|
||||
float f = getSteerPercent() * speed_ratio;
|
||||
if(m_kart_properties->getSkidVisualTime()==0 || m_skid_time < 0)
|
||||
{
|
||||
float r = m_skidding / m_kart_properties->getMaxSkid();
|
||||
f *= r;
|
||||
}
|
||||
else
|
||||
{
|
||||
float st = fabsf(m_skid_time);
|
||||
if(st>m_kart_properties->getSkidVisualTime())
|
||||
st = m_kart_properties->getSkidVisualTime();
|
||||
f *= sqrt(st/m_kart_properties->getSkidVisualTime());
|
||||
}
|
||||
printf("f %f visual %f\n", f, f*m_kart_properties->getSkidVisual());
|
||||
return f*m_kart_properties->getSkidVisual();
|
||||
|
||||
} // getVisualSkidOffset
|
||||
|
||||
|
@ -84,7 +84,7 @@ KartProperties::KartProperties(const std::string &filename)
|
||||
m_zipper_time = m_zipper_force = m_zipper_speed_gain =
|
||||
m_zipper_max_speed_increase = m_zipper_fade_out_time =
|
||||
m_time_till_max_skid = m_skid_angular_velocity =
|
||||
m_post_skid_rotate_factor =
|
||||
m_post_skid_rotate_factor = m_skid_reduce_turn =
|
||||
m_skid_decrease = m_skid_increase = m_skid_visual = m_skid_max =
|
||||
m_skid_visual_time = m_slipstream_length = m_slipstream_collect_time =
|
||||
m_slipstream_use_time = m_slipstream_add_power =
|
||||
@ -307,6 +307,7 @@ void KartProperties::getAllData(const XMLNode * root)
|
||||
skid_node->get("bonus-time", &m_skid_bonus_time );
|
||||
skid_node->get("angular-velocity", &m_skid_angular_velocity );
|
||||
skid_node->get("post-skid-rotate-factor",&m_post_skid_rotate_factor);
|
||||
skid_node->get("reduce-turn", &m_skid_reduce_turn );
|
||||
}
|
||||
|
||||
if(const XMLNode *slipstream_node = root->getNode("slipstream"))
|
||||
@ -636,6 +637,7 @@ void KartProperties::checkAllSet(const std::string &filename)
|
||||
CHECK_NEG(m_skid_visual_time, "skid visual-time" );
|
||||
CHECK_NEG(m_skid_angular_velocity, "skid angular-velocity" );
|
||||
CHECK_NEG(m_post_skid_rotate_factor, "skid post-skid-rotate-factor" );
|
||||
CHECK_NEG(m_skid_reduce_turn, "skid reduce-turn" );
|
||||
CHECK_NEG(m_slipstream_length, "slipstream length" );
|
||||
CHECK_NEG(m_slipstream_collect_time, "slipstream collect-time" );
|
||||
CHECK_NEG(m_slipstream_use_time, "slipstream use-time" );
|
||||
|
@ -301,12 +301,14 @@ private:
|
||||
float m_skid_visual_time;
|
||||
/** Angular velocity to be applied when skidding. */
|
||||
float m_skid_angular_velocity;
|
||||
|
||||
/** This factor is used to determine how much the chassis of a kart
|
||||
* should rotate to match the graphical view. A factor of 1 is
|
||||
* identical, a smaller factor will rotate the kart less (which might
|
||||
* feel better). */
|
||||
float m_post_skid_rotate_factor;
|
||||
/** This factor reduces the amount of steering while skidding.
|
||||
*/
|
||||
float m_skid_reduce_turn;
|
||||
|
||||
/** Kart leaves skid marks. */
|
||||
bool m_has_skidmarks;
|
||||
@ -676,6 +678,10 @@ public:
|
||||
* feel better). */
|
||||
float getPostSkidRotateFactor () const {return m_post_skid_rotate_factor;}
|
||||
|
||||
/** Returns the factor by which to recude the amount of steering while
|
||||
skidding. */
|
||||
float getSkidReduceTurn () const { return m_skid_reduce_turn; }
|
||||
|
||||
/** Returns if the kart leaves skidmarks or not. */
|
||||
bool hasSkidmarks () const {return m_has_skidmarks; }
|
||||
|
||||
|
@ -445,10 +445,13 @@ void btKart::updateVehicle( btScalar step )
|
||||
if(m_time_additional_rotation>0)
|
||||
{
|
||||
btTransform &t = m_chassisBody->getWorldTransform();
|
||||
float dt = step > m_time_additional_rotation
|
||||
? m_time_additional_rotation
|
||||
: step;
|
||||
t.setRotation(t.getRotation()
|
||||
*btQuaternion(m_additional_rotation.getY()*step,
|
||||
m_additional_rotation.getX()*step,
|
||||
m_additional_rotation.getZ()*step));
|
||||
*btQuaternion(m_additional_rotation.getY()*dt,
|
||||
m_additional_rotation.getX()*dt,
|
||||
m_additional_rotation.getZ()*dt));
|
||||
m_time_additional_rotation -= step;
|
||||
}
|
||||
} // updateVehicle
|
||||
|
@ -238,7 +238,7 @@ public:
|
||||
* \param torque The rotation to apply. */
|
||||
void setTimedRotation(float t, const btVector3 &rot)
|
||||
{
|
||||
m_additional_rotation = rot;
|
||||
m_additional_rotation = rot/t;
|
||||
m_time_additional_rotation = t;
|
||||
} // setTimedTorque
|
||||
}; // class btKart
|
||||
|
Loading…
Reference in New Issue
Block a user