Try to stop the karts from hovering.
This commit is contained in:
parent
18cb4f6d12
commit
d26547aa16
@ -2500,40 +2500,29 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz,
|
||||
for(unsigned int i=0; i<4; i++)
|
||||
{
|
||||
// Set the suspension length
|
||||
height_above_terrain[i] =
|
||||
( m_vehicle->getWheelInfo(i).m_raycastInfo.m_hardPointWS
|
||||
- m_vehicle->getWheelInfo(i).m_raycastInfo.m_contactPointWS).length()
|
||||
- m_vehicle->getWheelInfo(i).m_chassisConnectionPointCS.getY();
|
||||
const btWheelInfo &wi = m_vehicle->getWheelInfo(i);
|
||||
height_above_terrain[i] = wi.m_raycastInfo.m_suspensionLength;
|
||||
if(height_above_terrain[i] < min_hat) min_hat = height_above_terrain[i];
|
||||
}
|
||||
float kart_hat = m_kart_model->getLowestPoint();
|
||||
|
||||
float chassis_delta = 0;
|
||||
// Check if the chassis needs to be moved down so that the wheels look
|
||||
// like they are in the rest state, i.e. the wheels are not too far down.
|
||||
if(min_hat > m_kart_model->getLowestPoint())
|
||||
if(min_hat >= kart_hat)
|
||||
{
|
||||
chassis_delta = min_hat - m_kart_model->getLowestPoint();
|
||||
for(unsigned int i=0; i<4; i++)
|
||||
height_above_terrain[i] -= chassis_delta;
|
||||
height_above_terrain[i] = kart_hat;
|
||||
}
|
||||
|
||||
m_kart_model->update(dt, m_wheel_rotation_dt, getSteerPercent(),
|
||||
height_above_terrain, m_speed);
|
||||
|
||||
height_above_terrain, m_speed);
|
||||
|
||||
// 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;
|
||||
|
||||
Vec3 center_shift = m_kart_properties->getGravityCenterShift();
|
||||
|
||||
center_shift.setY(m_skidding->getGraphicalJumpOffset() + lean_height
|
||||
- m_kart_model->getLowestPoint() -chassis_delta );
|
||||
center_shift = getTrans().getBasis() * center_shift;
|
||||
|
||||
float heading = m_skidding->getVisualSkidRotation();
|
||||
center_shift = Vec3(0, m_skidding->getGraphicalJumpOffset() + lean_height, 0);
|
||||
Vec3 center_shift = Vec3(0, m_skidding->getGraphicalJumpOffset() - kart_hat
|
||||
+ lean_height-m_kart_model->getLowestPoint(), 0);
|
||||
center_shift = getTrans().getBasis() * center_shift;
|
||||
|
||||
Moveable::updateGraphics(dt, center_shift,
|
||||
btQuaternion(heading, 0, m_current_lean));
|
||||
|
||||
|
@ -804,7 +804,8 @@ void KartModel::update(float dt, float rotation_dt, float steer,
|
||||
}
|
||||
#endif
|
||||
core::vector3df pos = m_wheel_graphics_position[i].toIrrVector();
|
||||
pos.Y = m_kart_lowest_point - height_above_terrain[i]
|
||||
//
|
||||
pos.Y = - height_above_terrain[i] + m_kart_lowest_point
|
||||
+ m_wheel_graphics_radius[i];
|
||||
m_wheel_node[i]->setPosition(pos);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user