mirror of
https://github.com/XProger/OpenLara.git
synced 2025-08-16 01:54:38 +02:00
#23 fix static sounds volime control & flipmaps
This commit is contained in:
@@ -96,6 +96,7 @@ struct Camera : ICamera {
|
||||
}
|
||||
|
||||
void updateListener() {
|
||||
Sound::flipped = level->isFlipped;
|
||||
Sound::listener.matrix = mViewInv;
|
||||
TR::Room &r = level->rooms[getRoomIndex()];
|
||||
int h = (r.info.yBottom - r.info.yTop) / 1024;
|
||||
|
@@ -290,7 +290,7 @@ struct Level : IGame {
|
||||
}
|
||||
}
|
||||
if (b.flags.gain) volume = max(0.0f, volume - randf() * 0.25f);
|
||||
if (b.flags.camera) flags &= ~Sound::PAN;
|
||||
//if (b.flags.camera) flags &= ~Sound::PAN;
|
||||
return Sound::play(level.getSampleStream(index), pos, volume, pitch, flags, group * 1000 + index);
|
||||
}
|
||||
return NULL;
|
||||
@@ -539,7 +539,7 @@ struct Level : IGame {
|
||||
|
||||
for (int i = 0; i < level.soundSourcesCount; i++) {
|
||||
TR::SoundSource &src = level.soundSources[i];
|
||||
lara->playSound(src.id, vec3(float(src.x), float(src.y), float(src.z)), Sound::PAN);
|
||||
lara->playSound(src.id, vec3(float(src.x), float(src.y), float(src.z)), Sound::PAN | src.flags);
|
||||
}
|
||||
|
||||
lastTitle = false;
|
||||
|
10
src/sound.h
10
src/sound.h
@@ -414,8 +414,12 @@ namespace Sound {
|
||||
REPLAY = 8,
|
||||
STATIC = 16,
|
||||
MUSIC = 32,
|
||||
FLIPPED = 64,
|
||||
UNFLIPPED = 128,
|
||||
};
|
||||
|
||||
bool flipped;
|
||||
|
||||
struct Sample {
|
||||
Decoder *decoder;
|
||||
vec3 pos;
|
||||
@@ -505,7 +509,7 @@ namespace Sound {
|
||||
mat4 m = Sound::listener.matrix;
|
||||
vec3 v = pos - m.offset.xyz;
|
||||
|
||||
float dist = max(0.0f, 1.0f - (v.length2() / (SND_FADEOFF_DIST * SND_FADEOFF_DIST)));
|
||||
float dist = max(0.0f, 1.0f - (v.length() / SND_FADEOFF_DIST));
|
||||
float pan = m.right.xyz.dot(v.normal());
|
||||
|
||||
float l = min(1.0f, 1.0f - pan);
|
||||
@@ -575,6 +579,7 @@ namespace Sound {
|
||||
Filter::Reverberation reverb;
|
||||
|
||||
void init() {
|
||||
flipped = false;
|
||||
channelsCount = 0;
|
||||
callback = NULL;
|
||||
buffer = NULL;
|
||||
@@ -603,6 +608,9 @@ namespace Sound {
|
||||
continue;
|
||||
|
||||
if (channels[i]->flags & STATIC) {
|
||||
if (!(channels[i]->flags & (flipped ? FLIPPED : UNFLIPPED)))
|
||||
continue;
|
||||
|
||||
vec3 d = channels[i]->pos - listener.matrix.getPos();
|
||||
if (fabsf(d.x) > SND_FADEOFF_DIST || fabsf(d.y) > SND_FADEOFF_DIST || fabsf(d.z) > SND_FADEOFF_DIST)
|
||||
continue;
|
||||
|
Reference in New Issue
Block a user