Raise karts somewhat when they are leaning (otherwise the
karts will be partially inside of the track). Some dead code removal. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@14394 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
e024b73553
commit
15c26079f1
@ -2400,10 +2400,9 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz,
|
||||
|
||||
Vec3 center_shift = m_kart_properties->getGravityCenterShift();
|
||||
|
||||
float y = m_kart_model->getWheelGraphicsRadius(0)
|
||||
- m_vehicle->getWheelInfo(0).m_wheelsRadius
|
||||
+ m_skidding->getGraphicalJumpOffset();
|
||||
center_shift.setY(y);
|
||||
float kart_y_offset = m_kart_model->getWheelGraphicsRadius(0)
|
||||
- m_vehicle->getWheelInfo(0).m_wheelsRadius
|
||||
+ m_skidding->getGraphicalJumpOffset();
|
||||
|
||||
if ((m_controls.m_nitro || m_min_nitro_time > 0.0f) && isOnGround() && m_collected_energy > 0)
|
||||
{
|
||||
@ -2487,6 +2486,11 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz,
|
||||
}
|
||||
}
|
||||
|
||||
// If the kart is leaning, part of the kart might end up 'in' the track.
|
||||
// To avoid this, raise the kart enough to offset the leaning.
|
||||
float lean_height = tan(fabsf(m_current_lean)) * getKartWidth()*0.5f;
|
||||
|
||||
center_shift.setY(kart_y_offset + lean_height);
|
||||
float heading = m_skidding->getVisualSkidRotation();
|
||||
Moveable::updateGraphics(dt, center_shift,
|
||||
btQuaternion(heading, 0, m_current_lean));
|
||||
|
@ -742,28 +742,7 @@ void KartModel::OnAnimationEnd(scene::IAnimatedMeshSceneNode *node)
|
||||
*/
|
||||
void KartModel::update(float dt, float rotation_dt, float steer, const float suspension[4], float speed)
|
||||
{
|
||||
float clamped_suspension[4];
|
||||
// Clamp suspension to minimum and maximum suspension length, so that
|
||||
// the graphical wheel models don't look too wrong.
|
||||
for(unsigned int i=0; i<4; i++)
|
||||
{
|
||||
const float suspension_length = (m_max_suspension[i]-m_min_suspension[i])/2;
|
||||
|
||||
// limit amplitude between set limits, first dividing it by a
|
||||
// somewhat arbitrary constant to reduce visible wheel movement
|
||||
clamped_suspension[i] = suspension[i]/m_dampen_suspension_amplitude[i];
|
||||
float ratio = clamped_suspension[i] / suspension_length;
|
||||
const int sign = ratio < 0 ? -1 : 1;
|
||||
// expanded form of 1 - (1 - x)^2, i.e. making suspension display
|
||||
// quadratic and not linear
|
||||
ratio = sign * fabsf(ratio*(2-ratio));
|
||||
// clamped_suspension[i] = ratio*suspension_length;
|
||||
clamped_suspension[i] = std::min(std::max(ratio*suspension_length,
|
||||
m_min_suspension[i]),
|
||||
m_max_suspension[i]);
|
||||
} // for i<4
|
||||
|
||||
core::vector3df wheel_steer(0, steer*30.0f, 0);
|
||||
core::vector3df wheel_steer(0, steer*30.0f, 0);
|
||||
|
||||
for(unsigned int i=0; i<4; i++)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user