Merge remote-tracking branch 'origin/move-handleMaterialSFX'
This commit is contained in:
@@ -829,8 +829,7 @@ void SlipStream::update(int ticks)
|
||||
kp->getSlipstreamMaxSpeedIncrease(),
|
||||
kp->getSlipstreamMaxSpeedIncrease(),
|
||||
kp->getSlipstreamAddPower(),
|
||||
m_bonus_time,
|
||||
stk_config->ticks2Time(fade_out) );
|
||||
stk_config->time2Ticks(m_bonus_time), fade_out);
|
||||
}
|
||||
|
||||
if(!is_sstreaming)
|
||||
|
||||
@@ -194,10 +194,10 @@ void RubberBand::update(int ticks)
|
||||
diff.normalize(); // diff can't be zero here
|
||||
m_owner->getBody()->applyCentralForce(diff*force);
|
||||
m_owner->increaseMaxSpeed(MaxSpeed::MS_INCREASE_RUBBER,
|
||||
kp->getPlungerBandSpeedIncrease(),
|
||||
/*engine_force*/ 0.0f,
|
||||
/*duration*/stk_config->time2Ticks(0.1f),
|
||||
kp->getPlungerBandFadeOutTicks());
|
||||
kp->getPlungerBandSpeedIncrease(),
|
||||
/*engine_force*/ 0.0f,
|
||||
/*duration*/stk_config->time2Ticks(0.1f),
|
||||
kp->getPlungerBandFadeOutTicks() );
|
||||
if(m_attached_state==RB_TO_KART)
|
||||
m_hit_kart->getBody()->applyCentralForce(diff*(-force));
|
||||
}
|
||||
|
||||
@@ -307,8 +307,8 @@ public:
|
||||
* \param fade_out_time How long the maximum speed will fade out linearly.
|
||||
*/
|
||||
virtual void increaseMaxSpeed(unsigned int category, float add_speed,
|
||||
float engine_force, float duration,
|
||||
float fade_out_time) = 0;
|
||||
float engine_force, int duration,
|
||||
int fade_out_time) = 0;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** This adjusts the top speed using increaseMaxSpeed, but additionally
|
||||
@@ -323,8 +323,8 @@ public:
|
||||
* \param fade_out_time How long the maximum speed will fade out linearly.
|
||||
*/
|
||||
virtual void instantSpeedIncrease(unsigned int category, float add_max_speed,
|
||||
float speed_boost, float engine_force, float duration,
|
||||
float fade_out_time) = 0;
|
||||
float speed_boost, float engine_force,
|
||||
int duration, int fade_out_time) = 0;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Defines a slowdown, which is in fraction of top speed.
|
||||
|
||||
@@ -197,6 +197,7 @@ Kart::Kart (const std::string& ident, unsigned int world_kart_id,
|
||||
m_skid_sound = SFXManager::get()->createSoundSource( "skid" );
|
||||
m_nitro_sound = SFXManager::get()->createSoundSource( "nitro" );
|
||||
m_terrain_sound = NULL;
|
||||
m_last_sound_material = NULL;
|
||||
m_previous_terrain_sound = NULL;
|
||||
|
||||
} // Kart
|
||||
@@ -460,23 +461,20 @@ void Kart::setXYZ(const Vec3& a)
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
void Kart::increaseMaxSpeed(unsigned int category, float add_speed,
|
||||
float engine_force, float duration,
|
||||
float fade_out_time)
|
||||
float engine_force, int duration,
|
||||
int fade_out_time)
|
||||
{
|
||||
m_max_speed->increaseMaxSpeed(category, add_speed, engine_force,
|
||||
stk_config->time2Ticks(duration),
|
||||
stk_config->time2Ticks(fade_out_time));
|
||||
duration, fade_out_time);
|
||||
} // increaseMaxSpeed
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
void Kart::instantSpeedIncrease(unsigned int category, float add_max_speed,
|
||||
float speed_boost, float engine_force, float duration,
|
||||
float fade_out_time)
|
||||
float speed_boost, float engine_force,
|
||||
int duration, int fade_out_time)
|
||||
{
|
||||
m_max_speed->instantSpeedIncrease(category, add_max_speed, speed_boost,
|
||||
engine_force,
|
||||
stk_config->time2Ticks(duration),
|
||||
stk_config->time2Ticks(fade_out_time) );
|
||||
engine_force, duration, fade_out_time);
|
||||
} // instantSpeedIncrease
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -1205,7 +1203,8 @@ float Kart::getShieldTime() const
|
||||
// ------------------------------------------------------------------------
|
||||
/**
|
||||
* Decreases the kart's shield time.
|
||||
* \param t The time substracted from the shield timer. If t == 0.0f, the default amout of time is substracted.
|
||||
* \param t The time substracted from the shield timer. If t == 0.0f, the
|
||||
default amout of time is substracted.
|
||||
*/
|
||||
void Kart::decreaseShieldTime()
|
||||
{
|
||||
@@ -1586,7 +1585,6 @@ void Kart::update(int ticks)
|
||||
}
|
||||
body->setGravity(gravity);
|
||||
} // if !flying
|
||||
handleMaterialSFX(material);
|
||||
if (material->isDriveReset() && isOnGround())
|
||||
{
|
||||
new RescueAnimation(this);
|
||||
@@ -1780,7 +1778,7 @@ void Kart::setSquash(float time, float slowdown)
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Plays any terrain specific sound effect.
|
||||
*/
|
||||
void Kart::handleMaterialSFX(const Material *material)
|
||||
void Kart::handleMaterialSFX()
|
||||
{
|
||||
// If a terrain specific sfx is already being played, when a new
|
||||
// terrain is entered, an old sfx should be finished (once, not
|
||||
@@ -1793,7 +1791,14 @@ void Kart::handleMaterialSFX(const Material *material)
|
||||
// FIXME: if there are already two sfx playing, don't add another
|
||||
// one. This should reduce the performance impact when driving
|
||||
// on the bridge in Cocoa.
|
||||
if(getLastMaterial()!=material && !m_previous_terrain_sound)
|
||||
const Material *material = m_terrain_info->getMaterial();
|
||||
|
||||
// We can not use getLastMaterial() since, since the last material might
|
||||
// be updated several times during the physics updates, not indicating
|
||||
// that we have reached a new material with regards to the sound effect.
|
||||
// So we separately save the material last used for a sound effect and
|
||||
// then use this for comparison.
|
||||
if(m_last_sound_material!=material)
|
||||
{
|
||||
// First stop any previously playing terrain sound
|
||||
// and remove it, so that m_previous_terrain_sound
|
||||
@@ -1802,19 +1807,21 @@ void Kart::handleMaterialSFX(const Material *material)
|
||||
{
|
||||
m_previous_terrain_sound->deleteSFX();
|
||||
}
|
||||
m_previous_terrain_sound = m_terrain_sound;
|
||||
if(m_previous_terrain_sound)
|
||||
m_previous_terrain_sound->setLoop(false);
|
||||
|
||||
const std::string &s = material->getSFXName();
|
||||
// Disable looping for the current terrain sound, and
|
||||
// make it the previous terrain sound.
|
||||
if (m_terrain_sound) m_terrain_sound->setLoop(false);
|
||||
m_previous_terrain_sound = m_terrain_sound;
|
||||
|
||||
const std::string &sound_name = material ? material->getSFXName() : "";
|
||||
|
||||
// In multiplayer mode sounds are NOT positional, because we have
|
||||
// multiple listeners. This would make the sounds of all AIs be
|
||||
// audible at all times. So silence AI karts.
|
||||
if (s.size()!=0 && (race_manager->getNumPlayers()==1 ||
|
||||
m_controller->isLocalPlayerController() ) )
|
||||
if (!sound_name.empty() && (race_manager->getNumPlayers()==1 ||
|
||||
m_controller->isLocalPlayerController() ) )
|
||||
{
|
||||
m_terrain_sound = SFXManager::get()->createSoundSource(s);
|
||||
m_terrain_sound = SFXManager::get()->createSoundSource(sound_name);
|
||||
m_terrain_sound->play();
|
||||
m_terrain_sound->setLoop(true);
|
||||
}
|
||||
@@ -1824,6 +1831,8 @@ void Kart::handleMaterialSFX(const Material *material)
|
||||
}
|
||||
}
|
||||
|
||||
// Check if a previous terrain sound (now not looped anymore)
|
||||
// is finished and can be deleted.
|
||||
if(m_previous_terrain_sound &&
|
||||
m_previous_terrain_sound->getStatus()==SFXBase::SFX_STOPPED)
|
||||
{
|
||||
@@ -1840,14 +1849,16 @@ void Kart::handleMaterialSFX(const Material *material)
|
||||
|
||||
// terrain sound is not necessarily a looping sound so check its status before
|
||||
// setting its speed, to avoid 'ressuscitating' sounds that had already stopped
|
||||
if(m_terrain_sound && main_loop->isLastSubstep() &&
|
||||
(m_terrain_sound->getStatus()==SFXBase::SFX_PLAYING ||
|
||||
m_terrain_sound->getStatus()==SFXBase::SFX_PAUSED))
|
||||
if(m_terrain_sound &&
|
||||
(m_terrain_sound->getStatus()==SFXBase::SFX_PLAYING ||
|
||||
m_terrain_sound->getStatus()==SFXBase::SFX_PAUSED) )
|
||||
{
|
||||
m_terrain_sound->setPosition(getXYZ());
|
||||
material->setSFXSpeed(m_terrain_sound, m_speed, m_schedule_pause);
|
||||
if(material)
|
||||
material->setSFXSpeed(m_terrain_sound, m_speed, m_schedule_pause);
|
||||
}
|
||||
|
||||
m_last_sound_material = material;
|
||||
} // handleMaterialSFX
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -3041,7 +3052,7 @@ void Kart::updateGraphics(float dt)
|
||||
|
||||
handleMaterialGFX(dt);
|
||||
updateEngineSFX(dt);
|
||||
|
||||
handleMaterialSFX();
|
||||
} // updateGraphics
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
@@ -226,7 +226,12 @@ protected:
|
||||
static const int EMITTER_COUNT = 3;
|
||||
SFXBase *m_emitters[EMITTER_COUNT];
|
||||
SFXBase *m_engine_sound;
|
||||
/** Sound to be played depending on terrain. */
|
||||
SFXBase *m_terrain_sound;
|
||||
|
||||
/** The material for which the last sound effect was played. */
|
||||
const Material *m_last_sound_material;
|
||||
|
||||
SFXBase *m_nitro_sound;
|
||||
/** A pointer to the previous terrain sound needs to be saved so that an
|
||||
* 'older' sfx can be finished and an abrupt end of the sfx is avoided. */
|
||||
@@ -244,7 +249,7 @@ protected:
|
||||
int m_min_nitro_ticks;
|
||||
|
||||
void updatePhysics(int ticks);
|
||||
void handleMaterialSFX(const Material *material);
|
||||
void handleMaterialSFX();
|
||||
void handleMaterialGFX(float dt);
|
||||
void updateFlying();
|
||||
void updateSliding();
|
||||
@@ -278,11 +283,11 @@ public:
|
||||
virtual void startEngineSFX ();
|
||||
virtual void adjustSpeed (float f);
|
||||
virtual void increaseMaxSpeed(unsigned int category, float add_speed,
|
||||
float engine_force, float duration,
|
||||
float fade_out_time);
|
||||
float engine_force, int duration,
|
||||
int fade_out_time) OVERRIDE;
|
||||
virtual void instantSpeedIncrease(unsigned int category, float add_max_speed,
|
||||
float speed_boost, float engine_force, float duration,
|
||||
float fade_out_time);
|
||||
float speed_boost, float engine_force,
|
||||
int duration, int fade_out_time) OVERRIDE;
|
||||
virtual void setSlowdown(unsigned int category, float max_speed_fraction,
|
||||
int fade_in_time);
|
||||
virtual int getSpeedIncreaseTicksLeft(unsigned int category) const;
|
||||
|
||||
@@ -87,8 +87,8 @@ void Skidding::reset()
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Save the skidding state of a kart. It only saves the important physics
|
||||
* values including m_remaining_jump_time (while this is mostly a graphical
|
||||
* effect, ou ycan't skid while still doing a jump, so it does affect the
|
||||
* staet), but not visual only values like m_visual_rotation. Similarly
|
||||
* effect, you can't skid while still doing a jump, so it does affect the
|
||||
* state), but not visual only values like m_visual_rotation. Similarly
|
||||
* m_real_steering is output of updateRewind() and will be recomputed every
|
||||
* frame when update() is called, and similar for m_skid_bonus_ready
|
||||
* \param buffer Buffer for the state information.
|
||||
|
||||
@@ -54,10 +54,6 @@ public:
|
||||
/** Returns true if STK is to be stoppe. */
|
||||
bool isAborted() const { return m_abort; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns if this is the last substep. Used to reduce the amount
|
||||
* of updates (e.g. to sfx position) to once per rendered frame. */
|
||||
bool isLastSubstep() const { return m_is_last_substep; }
|
||||
// ------------------------------------------------------------------------
|
||||
void setFrameBeforeLoadingWorld() { m_frame_before_loading_world = true; }
|
||||
}; // MainLoop
|
||||
|
||||
|
||||
Reference in New Issue
Block a user