Disable smoothing body for network when animation is playing

This commit is contained in:
Benau 2018-12-25 10:02:19 +08:00
parent dba4d05852
commit c98c20e6a5
3 changed files with 17 additions and 0 deletions

View File

@ -51,6 +51,7 @@ AbstractKartAnimation::AbstractKartAnimation(AbstractKart *kart,
m_check_created_ticks = std::make_shared<int>(-1);
m_confirmed_by_network = false;
m_ignore_undo = false;
m_has_smoothing_network_body = false;
// Remove previous animation if there is one
#ifndef DEBUG
// Use this code in non-debug mode to avoid a memory leak (and messed
@ -68,6 +69,11 @@ AbstractKartAnimation::AbstractKartAnimation(AbstractKart *kart,
// later).
if (kart)
{
m_has_smoothing_network_body =
dynamic_cast<SmoothNetworkBody*>(kart)->isEnabled();
// Disable smoothing network body so it doesn't smooth the animation
if (m_has_smoothing_network_body)
dynamic_cast<SmoothNetworkBody*>(kart)->setEnable(false);
kart->setKartAnimation(this);
Physics::getInstance()->removeKart(m_kart);
kart->getSkidding()->reset();
@ -124,6 +130,13 @@ AbstractKartAnimation::~AbstractKartAnimation()
Physics::getInstance()->addKart(kart);
}));
}
if (m_has_smoothing_network_body)
{
dynamic_cast<SmoothNetworkBody*>(m_kart)->setEnable(true);
dynamic_cast<SmoothNetworkBody*>(m_kart)->reset();
dynamic_cast<SmoothNetworkBody*>(m_kart)
->setSmoothedTransform(transform);
}
}
} // ~AbstractKartAnimation

View File

@ -61,6 +61,8 @@ private:
bool m_ignore_undo;
bool m_has_smoothing_network_body;
protected:
/** A pointer to the kart which is animated by this class. */
AbstractKart *m_kart;

View File

@ -88,6 +88,8 @@ public:
// ------------------------------------------------------------------------
void setEnable(bool val) { m_enabled = val; }
// ------------------------------------------------------------------------
bool isEnabled() const { return m_enabled; }
// ------------------------------------------------------------------------
void setSmoothRotation(bool val) { m_smooth_rotation = val; }
// ------------------------------------------------------------------------
void setAdjustVerticalOffset(bool val) { m_adjust_vertical_offset = val; }