undo my attempts at configuring the attenuation model per-source, after closer inspection OpenAL doesn't support what I was trying to do :(
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@11421 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
60aff6dd1b
commit
9f909b4c26
@ -38,7 +38,6 @@
|
||||
|
||||
SFXBuffer::SFXBuffer(const std::string& file,
|
||||
bool positional,
|
||||
ALuint rolloffType,
|
||||
float rolloff,
|
||||
float gain)
|
||||
{
|
||||
@ -51,7 +50,6 @@ SFXBuffer::SFXBuffer(const std::string& file,
|
||||
m_rolloff = rolloff;
|
||||
m_positional = positional;
|
||||
m_gain = gain;
|
||||
m_rolloffType = rolloffType;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@ -65,21 +63,10 @@ SFXBuffer::SFXBuffer(const std::string& file,
|
||||
m_positional = false;
|
||||
m_loaded = false;
|
||||
m_file = file;
|
||||
m_rolloffType = AL_INVERSE_DISTANCE_CLAMPED;
|
||||
|
||||
node->get("rolloff", &m_rolloff );
|
||||
node->get("positional", &m_positional );
|
||||
node->get("volume", &m_gain );
|
||||
|
||||
std::string rolloffType;
|
||||
node->get("rolloff_type", &rolloffType);
|
||||
|
||||
if (rolloffType == "inverse")
|
||||
m_rolloffType = AL_INVERSE_DISTANCE_CLAMPED;
|
||||
else if (rolloffType == "linear")
|
||||
m_rolloffType = AL_LINEAR_DISTANCE_CLAMPED;
|
||||
else if (rolloffType != "")
|
||||
fprintf(stderr, "[SfxBuffer] Unknown rolloff type '%s'\n", rolloffType.c_str());
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
@ -55,7 +55,6 @@ private:
|
||||
bool m_positional;
|
||||
float m_rolloff;
|
||||
float m_gain;
|
||||
ALuint m_rolloffType;
|
||||
|
||||
bool loadVorbisBuffer(const std::string &name, ALuint buffer);
|
||||
|
||||
@ -63,7 +62,6 @@ public:
|
||||
|
||||
SFXBuffer(const std::string& file,
|
||||
bool positional,
|
||||
ALuint rolloffType,
|
||||
float rolloff,
|
||||
float gain);
|
||||
|
||||
@ -100,9 +98,6 @@ public:
|
||||
std::string getFileName() const { return m_file; }
|
||||
|
||||
void setPositional(bool positional) { m_positional = positional; }
|
||||
|
||||
ALuint getRolloffType() const { return m_rolloffType; }
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -184,12 +184,11 @@ void SFXManager::loadSfx()
|
||||
SFXBuffer* SFXManager::addSingleSfx(const std::string &sfx_name,
|
||||
const std::string &sfx_file,
|
||||
bool positional,
|
||||
ALuint rolloff_type,
|
||||
float rolloff,
|
||||
float gain)
|
||||
{
|
||||
|
||||
SFXBuffer* buffer = new SFXBuffer(sfx_file, positional, rolloff_type, rolloff, gain);
|
||||
SFXBuffer* buffer = new SFXBuffer(sfx_file, positional, rolloff, gain);
|
||||
|
||||
m_all_sfx_types[sfx_name] = buffer;
|
||||
|
||||
@ -250,7 +249,6 @@ SFXBuffer* SFXManager::loadSingleSfx(const XMLNode* node,
|
||||
|
||||
return addSingleSfx(sfx_name, full_path,
|
||||
tmpbuffer.isPositional(),
|
||||
tmpbuffer.getRolloffType(),
|
||||
tmpbuffer.getRolloff(),
|
||||
tmpbuffer.getGain());
|
||||
|
||||
|
@ -109,7 +109,6 @@ public:
|
||||
SFXBuffer* addSingleSfx(const std::string &sfx_name,
|
||||
const std::string &filename,
|
||||
bool positional,
|
||||
ALuint rolloff_type,
|
||||
float rolloff,
|
||||
float gain);
|
||||
|
||||
|
@ -44,7 +44,6 @@ SFXOpenAL::SFXOpenAL(SFXBuffer* buffer, bool positional, float gain) : SFXBase()
|
||||
m_defaultGain = gain;
|
||||
m_loop = false;
|
||||
m_gain = -1.0f;
|
||||
m_rolloffType = buffer->getRolloffType();
|
||||
|
||||
// Don't initialise anything else if the sfx manager was not correctly
|
||||
// initialised. First of all the initialisation will not work, and it
|
||||
@ -86,17 +85,7 @@ bool SFXOpenAL::init()
|
||||
alSource3f(m_soundSource, AL_VELOCITY, 0.0, 0.0, 0.0);
|
||||
alSource3f(m_soundSource, AL_DIRECTION, 0.0, 0.0, 0.0);
|
||||
|
||||
alDistanceModel(m_rolloffType);
|
||||
|
||||
if (m_rolloffType == AL_INVERSE_DISTANCE_CLAMPED)
|
||||
{
|
||||
alSourcef (m_soundSource, AL_ROLLOFF_FACTOR, m_soundBuffer->getRolloff());
|
||||
}
|
||||
else if (m_rolloffType == AL_LINEAR_DISTANCE_CLAMPED)
|
||||
{
|
||||
alSourcef (m_soundSource, AL_MAX_DISTANCE, m_soundBuffer->getRolloff());
|
||||
}
|
||||
|
||||
alSourcef (m_soundSource, AL_ROLLOFF_FACTOR, m_soundBuffer->getRolloff());
|
||||
|
||||
if (m_gain < 0.0f)
|
||||
{
|
||||
@ -242,8 +231,9 @@ void SFXOpenAL::position(const Vec3 &position)
|
||||
if (!m_positional)
|
||||
{
|
||||
// in multiplayer, all sounds are positional, so in this case don't bug users with
|
||||
// an error messageif (race_manager->getNumLocalPlayers() > 1)
|
||||
if (race_manager->getNumLocalPlayers() == 1)
|
||||
// an error message if (race_manager->getNumLocalPlayers() > 1)
|
||||
// (note that 0 players is also possible, in cutscenes)
|
||||
if (race_manager->getNumLocalPlayers() < 2)
|
||||
{
|
||||
fprintf(stderr, "WARNING, position called on non-positional SFX\n");
|
||||
}
|
||||
|
@ -43,8 +43,6 @@ private:
|
||||
bool m_positional;
|
||||
float m_defaultGain;
|
||||
|
||||
int m_rolloffType;
|
||||
|
||||
/** The OpenAL source contains this info, but if audio is disabled initially then
|
||||
the sound source won't be created and we'll be left with no clue when enabling
|
||||
sounds later */
|
||||
|
@ -135,20 +135,9 @@ TrackObject::TrackObject(const XMLNode &xml_node)
|
||||
|
||||
xml_node.get("conditions", &m_trigger_condition);
|
||||
|
||||
ALuint rolloffType = AL_INVERSE_DISTANCE_CLAMPED;
|
||||
std::string rolloffTypeStr;
|
||||
xml_node.get("rolloff_type", &rolloffTypeStr );
|
||||
|
||||
float rolloff_distance = 10.0f;
|
||||
xml_node.get("distance", &rolloff_distance );
|
||||
|
||||
if (rolloffTypeStr == "inverse")
|
||||
rolloffType = AL_INVERSE_DISTANCE_CLAMPED;
|
||||
else if (rolloffTypeStr == "linear")
|
||||
rolloffType = AL_LINEAR_DISTANCE_CLAMPED;
|
||||
else if (rolloffTypeStr != "")
|
||||
fprintf(stderr, "[TrackObject] Unknown rolloff type '%s'\n", rolloffTypeStr.c_str());
|
||||
|
||||
// first try track dir, then global dir
|
||||
std::string soundfile = file_manager->getModelFile(sound);
|
||||
if (!file_manager->fileExists(soundfile))
|
||||
@ -156,16 +145,9 @@ TrackObject::TrackObject(const XMLNode &xml_node)
|
||||
soundfile = file_manager->getSFXFile(sound);
|
||||
}
|
||||
|
||||
float rolloff_param = 1.0f;
|
||||
if (rolloffType == AL_INVERSE_DISTANCE_CLAMPED)
|
||||
rolloff_param = rolloff;
|
||||
else if (rolloffType == AL_LINEAR_DISTANCE_CLAMPED)
|
||||
rolloff_param = rolloff_distance;
|
||||
|
||||
SFXBuffer* buffer = new SFXBuffer(soundfile,
|
||||
true /* positional */,
|
||||
rolloffType,
|
||||
rolloff_param,
|
||||
rolloff,
|
||||
volume);
|
||||
buffer->load();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user