1
0
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:
XProger
2017-09-29 03:21:00 +03:00
parent e9a88ce5b1
commit 1a2c5c9c1a
3 changed files with 12 additions and 3 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;