Continue optimizing OpenAL sources, see #2921
This commit is contained in:
parent
cb2295c738
commit
beb10863c4
@ -45,6 +45,7 @@ class KartModel;
|
||||
class KartProperties;
|
||||
class Material;
|
||||
class Powerup;
|
||||
class SFXBuffer;
|
||||
class Skidding;
|
||||
class SlipStream;
|
||||
class TerrainInfo;
|
||||
@ -472,7 +473,8 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns whether this kart is jumping. */
|
||||
virtual bool isJumping() const = 0;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void playSound(SFXBuffer* buffer) = 0;
|
||||
}; // AbstractKart
|
||||
|
||||
|
||||
|
@ -65,11 +65,11 @@ LocalPlayerController::LocalPlayerController(AbstractKart *kart,
|
||||
// the right camera once per frame later.
|
||||
Camera *camera = Camera::createCamera(kart);
|
||||
m_camera_index = camera->getIndex();
|
||||
m_bzzt_sound = SFXManager::get()->createSoundSource("bzzt");
|
||||
m_wee_sound = SFXManager::get()->createSoundSource("wee");
|
||||
m_ugh_sound = SFXManager::get()->createSoundSource("ugh");
|
||||
m_grab_sound = SFXManager::get()->createSoundSource("grab_collectable");
|
||||
m_full_sound = SFXManager::get()->createSoundSource("energy_bar_full");
|
||||
m_bzzt_sound = SFXManager::get()->getBuffer("bzzt");
|
||||
m_ugh_sound = SFXManager::get()->getBuffer("ugh");
|
||||
m_grab_sound = SFXManager::get()->getBuffer("grab_collectable");
|
||||
m_full_sound = SFXManager::get()->getBuffer("energy_bar_full");
|
||||
|
||||
// Attach Particle System
|
||||
Track *track = Track::getCurrentTrack();
|
||||
@ -97,11 +97,8 @@ LocalPlayerController::LocalPlayerController(AbstractKart *kart,
|
||||
*/
|
||||
LocalPlayerController::~LocalPlayerController()
|
||||
{
|
||||
m_bzzt_sound->deleteSFX();
|
||||
m_wee_sound ->deleteSFX();
|
||||
m_ugh_sound ->deleteSFX();
|
||||
m_grab_sound->deleteSFX();
|
||||
m_full_sound->deleteSFX();
|
||||
m_wee_sound->deleteSFX();
|
||||
|
||||
if (m_sky_particles_emitter)
|
||||
delete m_sky_particles_emitter;
|
||||
} // ~LocalPlayerController
|
||||
@ -228,7 +225,7 @@ void LocalPlayerController::update(float dt)
|
||||
else if (!m_kart->getKartAnimation() && m_sound_schedule == true)
|
||||
{
|
||||
m_sound_schedule = false;
|
||||
m_bzzt_sound->play();
|
||||
m_kart->playSound(m_bzzt_sound);
|
||||
}
|
||||
} // update
|
||||
|
||||
@ -246,7 +243,7 @@ void LocalPlayerController::displayPenaltyWarning()
|
||||
m->addMessage(_("Don't accelerate before go"), m_kart, 2.0f,
|
||||
GUIEngine::getSkin()->getColor("font::normal"));
|
||||
}
|
||||
m_bzzt_sound->play();
|
||||
m_kart->playSound(m_bzzt_sound);
|
||||
} // displayPenaltyWarning
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -326,31 +323,31 @@ void LocalPlayerController::collectedItem(const Item &item, int add_info,
|
||||
if (old_energy < m_kart->getKartProperties()->getNitroMax() &&
|
||||
m_kart->getEnergy() == m_kart->getKartProperties()->getNitroMax())
|
||||
{
|
||||
m_full_sound->play();
|
||||
m_kart->playSound(m_full_sound);
|
||||
}
|
||||
else if (race_manager->getCoinTarget() > 0 &&
|
||||
old_energy < race_manager->getCoinTarget() &&
|
||||
m_kart->getEnergy() == race_manager->getCoinTarget())
|
||||
{
|
||||
m_full_sound->play();
|
||||
m_kart->playSound(m_full_sound);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(item.getType())
|
||||
{
|
||||
case Item::ITEM_BANANA:
|
||||
m_ugh_sound->play();
|
||||
m_kart->playSound(m_ugh_sound);
|
||||
break;
|
||||
case Item::ITEM_BUBBLEGUM:
|
||||
//More sounds are played by the kart class
|
||||
//See Kart::collectedItem()
|
||||
m_ugh_sound->play();
|
||||
m_kart->playSound(m_ugh_sound);
|
||||
break;
|
||||
case Item::ITEM_TRIGGER:
|
||||
// no default sound for triggers
|
||||
break;
|
||||
default:
|
||||
m_grab_sound->play();
|
||||
m_kart->playSound(m_grab_sound);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@
|
||||
class AbstractKart;
|
||||
class ParticleEmitter;
|
||||
class SFXBase;
|
||||
class SFXBuffer;
|
||||
|
||||
/** PlayerKart manages control events from the player and moves
|
||||
* them to the Kart
|
||||
@ -47,11 +48,11 @@ private:
|
||||
* camera object is managed in the Camera class, so no need to free it. */
|
||||
int m_camera_index;
|
||||
|
||||
SFXBase *m_bzzt_sound;
|
||||
SFXBase *m_wee_sound;
|
||||
SFXBase *m_ugh_sound;
|
||||
SFXBase *m_grab_sound;
|
||||
SFXBase *m_full_sound;
|
||||
SFXBase *m_wee_sound;
|
||||
SFXBuffer *m_bzzt_sound;
|
||||
SFXBuffer *m_ugh_sound;
|
||||
SFXBuffer *m_grab_sound;
|
||||
SFXBuffer *m_full_sound;
|
||||
|
||||
virtual void steer(float, int) OVERRIDE;
|
||||
virtual void displayPenaltyWarning() OVERRIDE;
|
||||
|
@ -2994,4 +2994,11 @@ const Vec3& Kart::getNormal() const
|
||||
return m_terrain_info->getNormal();
|
||||
} // getNormal
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
void Kart::playSound(SFXBuffer* buffer)
|
||||
{
|
||||
getNextEmitter()->play(getXYZ(), buffer);
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
@ -241,7 +241,6 @@ protected:
|
||||
float getActualWheelForce();
|
||||
void playCrashSFX(const Material* m, AbstractKart *k);
|
||||
void loadData(RaceManager::KartType type, bool animatedModel);
|
||||
SFXBase* getNextEmitter();
|
||||
|
||||
public:
|
||||
Kart(const std::string& ident, unsigned int world_kart_id,
|
||||
@ -478,7 +477,10 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns whether this kart is jumping. */
|
||||
virtual bool isJumping() const { return m_is_jumping; };
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
SFXBase* getNextEmitter();
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void playSound(SFXBuffer* buffer);
|
||||
}; // Kart
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user