mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-22 23:30:14 +00:00
Optimize city performance and harden WMO grounding
This commit is contained in:
parent
dd4b72e046
commit
2219ccde51
8 changed files with 196 additions and 55 deletions
|
|
@ -296,7 +296,8 @@ void AmbientSoundManager::updatePositionalEmitters(float deltaTime, const glm::v
|
|||
const int MAX_ACTIVE_WATER = 3; // Max 3 water sounds at once
|
||||
|
||||
for (auto& emitter : emitters_) {
|
||||
float distance = glm::distance(emitter.position, cameraPos);
|
||||
const glm::vec3 delta = emitter.position - cameraPos;
|
||||
const float distSq = glm::dot(delta, delta);
|
||||
|
||||
// Determine max distance based on type
|
||||
float maxDist = MAX_AMBIENT_DISTANCE;
|
||||
|
|
@ -317,7 +318,8 @@ void AmbientSoundManager::updatePositionalEmitters(float deltaTime, const glm::v
|
|||
}
|
||||
|
||||
// Update active state based on distance AND limits
|
||||
bool withinRange = (distance < maxDist);
|
||||
const float maxDistSq = maxDist * maxDist;
|
||||
const bool withinRange = (distSq < maxDistSq);
|
||||
|
||||
if (isFire && withinRange && activeFireCount < MAX_ACTIVE_FIRE) {
|
||||
emitter.active = true;
|
||||
|
|
@ -336,6 +338,9 @@ void AmbientSoundManager::updatePositionalEmitters(float deltaTime, const glm::v
|
|||
// Update play timer
|
||||
emitter.lastPlayTime += deltaTime;
|
||||
|
||||
// We only need the true distance for volume attenuation once the emitter is active.
|
||||
const float distance = std::sqrt(distSq);
|
||||
|
||||
// Handle different emitter types
|
||||
switch (emitter.type) {
|
||||
case AmbientType::FIREPLACE_SMALL:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue