Add a slight delay when triggering the falling camera, avoids triggering it too soon when the kart is not yet sure to fall

This commit is contained in:
auria.mg 2017-09-06 19:23:35 -04:00
parent 88972f8308
commit 5e8f25a1fc
2 changed files with 16 additions and 4 deletions

View File

@ -1445,7 +1445,7 @@ void Kart::update(float dt)
}
PROFILER_PUSH_CPU_MARKER("Kart::Update (material)", 0x60, 0x34, 0x7F);
handleMaterialGFX();
handleMaterialGFX(dt);
const Material* material=m_terrain_info->getMaterial();
if (!material) // kart falling off the track
{
@ -1764,7 +1764,7 @@ void Kart::handleMaterialSFX(const Material *material)
* kart is falling, or if the surface the kart is driving on has
* the 'isBelowSurface' property set.
*/
void Kart::handleMaterialGFX()
void Kart::handleMaterialGFX(float dt)
{
const Material *material = getMaterial();
@ -1798,12 +1798,22 @@ void Kart::handleMaterialGFX()
// --------------------------------------------------------------
if (m_controller->isLocalPlayerController() && !hasFinishedRace())
{
bool falling = material && material->hasFallingEffect() && !m_flying;
if (falling)
{
m_falling_time -= dt;
if (m_falling_time < 0.0f)
m_falling_time = 0.0f;
}
else
m_falling_time = 0.35f;
for(unsigned int i=0; i<Camera::getNumCameras(); i++)
{
Camera *camera = Camera::getCamera(i);
if(camera->getKart()!=this) continue;
if (material && material->hasFallingEffect() && !m_flying)
if (falling && m_falling_time <= 0.0f)
{
camera->setMode(Camera::CM_FALLING);
}

View File

@ -193,6 +193,8 @@ protected:
float m_finish_time;
bool m_finished_race;
float m_falling_time = 0.35f;
/** When a kart has its view blocked by the plunger, this variable will be
* > 0 the number it contains is the time left before removing plunger. */
float m_view_blocked_by_plunger;
@ -229,7 +231,7 @@ protected:
void updatePhysics(float dt);
void handleMaterialSFX(const Material *material);
void handleMaterialGFX();
void handleMaterialGFX(float dt);
void updateFlying();
void updateSliding();
void updateEnginePowerAndBrakes(float dt);