Fix using uninitialized values when init() the first time
This commit is contained in:
parent
03f9fb35da
commit
aaa0e11770
@ -131,6 +131,7 @@ KartModel::KartModel(bool is_master)
|
|||||||
m_min_suspension[i] = -0.07f;
|
m_min_suspension[i] = -0.07f;
|
||||||
m_max_suspension[i] = 0.20f;
|
m_max_suspension[i] = 0.20f;
|
||||||
m_dampen_suspension_amplitude[i] = 2.5f;
|
m_dampen_suspension_amplitude[i] = 2.5f;
|
||||||
|
m_default_physics_suspension[i] = 0.25f;
|
||||||
}
|
}
|
||||||
m_wheel_filename[0] = "";
|
m_wheel_filename[0] = "";
|
||||||
m_wheel_filename[1] = "";
|
m_wheel_filename[1] = "";
|
||||||
@ -861,9 +862,9 @@ void KartModel::update(float dt, float distance, float steer, float speed,
|
|||||||
|
|
||||||
float suspension_length = 0.0f;
|
float suspension_length = 0.0f;
|
||||||
GhostKart* gk = dynamic_cast<GhostKart*>(m_kart);
|
GhostKart* gk = dynamic_cast<GhostKart*>(m_kart);
|
||||||
// Prevent using m_default_physics_suspension uninitialized
|
// Prevent using suspension length uninitialized
|
||||||
if (gk && gt_replay_index == -1) break;
|
if (dt != 0.0f && !(gk && gt_replay_index == -1))
|
||||||
|
{
|
||||||
if (gk)
|
if (gk)
|
||||||
{
|
{
|
||||||
suspension_length = gk->getSuspensionLength(gt_replay_index, i);
|
suspension_length = gk->getSuspensionLength(gt_replay_index, i);
|
||||||
@ -873,6 +874,7 @@ void KartModel::update(float dt, float distance, float steer, float speed,
|
|||||||
suspension_length = m_kart->getVehicle()->getWheelInfo(i).
|
suspension_length = m_kart->getVehicle()->getWheelInfo(i).
|
||||||
m_raycastInfo.m_suspensionLength;
|
m_raycastInfo.m_suspensionLength;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check documentation of Kart::updateGraphics for the following line
|
// Check documentation of Kart::updateGraphics for the following line
|
||||||
pos.Y += m_default_physics_suspension[i]
|
pos.Y += m_default_physics_suspension[i]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user