Simplify squash graphics

This commit is contained in:
Benau 2018-10-25 10:39:36 +08:00
parent 8737b91cb9
commit 378c5c18e7
2 changed files with 35 additions and 41 deletions

View File

@ -361,7 +361,6 @@ void Kart::reset()
m_invulnerable_ticks = 0;
m_min_nitro_ticks = 0;
m_energy_to_min_ratio = 0;
m_squash_time = std::numeric_limits<float>::max();
m_collected_energy = 0;
m_bounce_back_ticks = 0;
m_brake_ticks = 0;
@ -1832,10 +1831,15 @@ bool Kart::setSquash(float time, float slowdown)
m_max_speed->setSlowdown(MaxSpeed::MS_DECREASE_SQUASH, slowdown,
stk_config->time2Ticks(0.1f),
stk_config->time2Ticks(time));
return true;
} // setSquash
#ifndef SERVER_ONLY
if (m_squash_time == std::numeric_limits<float>::max())
//-----------------------------------------------------------------------------
void Kart::setSquashGraphics()
{
#ifndef SERVER_ONLY
if (isGhostKart()) return;
m_node->setScale(core::vector3df(1.0f, 0.5f, 1.0f));
if (m_vehicle->getNumWheels() > 0)
{
@ -1853,11 +1857,8 @@ bool Kart::setSquash(float time, float slowdown)
m_wheel_box->getRelativeTransformationMatrix()
.setScale(core::vector3df(1.0f, 2.0f, 1.0f));
}
m_squash_time = time;
}
#endif
return true;
} // setSquash
} // setSquashGraphics
//-----------------------------------------------------------------------------
void Kart::unsetSquash()
@ -1865,9 +1866,7 @@ void Kart::unsetSquash()
#ifndef SERVER_ONLY
if (isGhostKart()) return;
m_squash_time = std::numeric_limits<float>::max();
m_node->setScale(core::vector3df(1.0f, 1.0f, 1.0f));
if (m_vehicle && m_vehicle->getNumWheels() > 0)
{
scene::ISceneNode** wheels = m_kart_model->getWheelNodes();
@ -3068,15 +3067,13 @@ void Kart::updateGraphics(float dt)
}
*/
#ifndef SERVER_ONLY
if (m_squash_time != std::numeric_limits<float>::max())
{
m_squash_time -= dt;
// If squasing time ends, reset the model
if (m_squash_time <= 0.0f || !isSquashed())
{
if (isSquashed() &&
m_node->getScale() != core::vector3df(1.0f, 0.5f, 1.0f))
setSquashGraphics();
else if (!isSquashed() &&
m_node->getScale() != core::vector3df(1.0f, 1.0f, 1.0f))
unsetSquash();
}
} // if squashed
if (m_graphical_view_blocked_by_plunger > 0.0f)
m_graphical_view_blocked_by_plunger -= dt;
if (m_graphical_view_blocked_by_plunger < 0.0f)

View File

@ -161,10 +161,6 @@ protected:
/** Time a kart is invulnerable. */
int16_t m_invulnerable_ticks;
/** How long a kart is being squashed. If this is >0
* the kart is squashed. */
float m_squash_time;
/** Current leaning of the kart. */
float m_current_lean;
@ -316,6 +312,7 @@ public:
virtual void handleZipper (const Material *m=NULL,
bool play_sound=false) OVERRIDE;
virtual bool setSquash (float time, float slowdown) OVERRIDE;
void setSquashGraphics();
virtual void unsetSquash () OVERRIDE;
virtual void crashed (AbstractKart *k, bool update_attachments) OVERRIDE;