1
0
mirror of https://github.com/XProger/OpenLara.git synced 2025-07-31 18:30:19 +02:00

#9 fix static sounds (no free channels message)

This commit is contained in:
XProger
2017-02-17 04:21:13 +03:00
parent d56c2ecab6
commit 299a6f4f52
4 changed files with 10 additions and 4 deletions

Binary file not shown.

View File

@@ -1365,7 +1365,7 @@ struct Lara : Character {
int q = entityQuadrant(e); int q = entityQuadrant(e);
if (q > -1 && e.isBlock() && e.y == y && alignToWall(-LARA_RADIUS, q, 64 + LARA_RADIUS, 512 - LARA_RADIUS)) { if (q > -1 && e.isBlock() && e.y == y && alignToWall(-LARA_RADIUS, q, 64 + int(LARA_RADIUS), 512 - int(LARA_RADIUS))) {
Block *block = (Block*)e.controller; Block *block = (Block*)e.controller;
block->angle.y = angle.y; block->angle.y = angle.y;
block->updateEntity(); block->updateEntity();

View File

@@ -745,7 +745,7 @@ struct Level : IGame {
initReflections(); initReflections();
for (int i = 0; i < level.soundSourcesCount; i++) { for (int i = 0; i < level.soundSourcesCount; i++) {
TR::SoundSource &src = level.soundSources[i]; TR::SoundSource &src = level.soundSources[i];
lara->playSound(src.id, vec3(float(src.x), float(src.y), float(src.z)), Sound::PAN | Sound::LOOP); lara->playSound(src.id, vec3(float(src.x), float(src.y), float(src.z)), Sound::PAN | Sound::LOOP | Sound::STATIC);
} }
} }

View File

@@ -20,7 +20,7 @@
#include "libs/stb_vorbis/stb_vorbis.c" #include "libs/stb_vorbis/stb_vorbis.c"
#endif #endif
#define SND_CHANNELS_MAX 32 #define SND_CHANNELS_MAX 128
#define SND_FADEOFF_DIST (1024.0f * 8.0f) #define SND_FADEOFF_DIST (1024.0f * 8.0f)
namespace Sound { namespace Sound {
@@ -311,6 +311,7 @@ namespace Sound {
UNIQUE = 4, UNIQUE = 4,
REPLAY = 8, REPLAY = 8,
SYNC = 16, SYNC = 16,
STATIC = 32,
}; };
struct Sample { struct Sample {
@@ -450,7 +451,12 @@ namespace Sound {
Frame *buffer = new Frame[bufSize]; // + 50% for pitch Frame *buffer = new Frame[bufSize]; // + 50% for pitch
for (int i = 0; i < channelsCount; i++) { for (int i = 0; i < channelsCount; i++) {
if (channels[i]->flags & STATIC) {
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;
}
memset(buffer, 0, sizeof(Frame) * bufSize); memset(buffer, 0, sizeof(Frame) * bufSize);
channels[i]->render(buffer, int(count * channels[i]->pitch)); channels[i]->render(buffer, int(count * channels[i]->pitch));