Fix valgrind errors

This commit is contained in:
Benau 2021-12-03 13:41:02 +08:00
parent 4a72a79582
commit 75a5f81578

View File

@ -130,12 +130,19 @@ void GhostKart::update(int ticks)
const float rd = gc->getReplayDelta();
assert(idx < m_all_transform.size());
setXYZ((1- rd)*m_all_transform[idx ].getOrigin()
+ rd *m_all_transform[idx + 1].getOrigin() );
const btQuaternion q = m_all_transform[idx].getRotation()
.slerp(m_all_transform[idx + 1].getRotation(), rd);
setRotation(q);
if (idx >= m_all_transform.size() - 1)
{
setXYZ(m_all_transform.back().getOrigin());
setRotation(m_all_transform.back().getRotation());
}
else
{
setXYZ((1- rd)*m_all_transform[idx ].getOrigin()
+ rd *m_all_transform[idx + 1].getOrigin() );
const btQuaternion q = m_all_transform[idx].getRotation()
.slerp(m_all_transform[idx + 1].getRotation(), rd);
setRotation(q);
}
Moveable::updatePosition();
float dt = stk_config->ticks2Time(ticks);
@ -235,8 +242,8 @@ float GhostKart::getSpeed() const
assert(gc->getCurrentReplayIndex() < m_all_physic_info.size());
if (current_index == m_all_physic_info.size())
return m_all_physic_info[current_index].m_speed;
if (current_index >= m_all_physic_info.size() - 1)
return m_all_physic_info.back().m_speed;
return (1-rd)*m_all_physic_info[current_index ].m_speed
+ rd *m_all_physic_info[current_index + 1].m_speed;