From 07df049a14031e1e68aff1aa5042207012361d81 Mon Sep 17 00:00:00 2001 From: Mike Lester Date: Fri, 3 Jan 2025 11:18:21 -0700 Subject: [PATCH] Wind Waker: Add frustum culling for simple emitters --- src/ZeldaWindWaker/d_particle.ts | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/ZeldaWindWaker/d_particle.ts b/src/ZeldaWindWaker/d_particle.ts index 4dc1ead63..7a6ce872d 100644 --- a/src/ZeldaWindWaker/d_particle.ts +++ b/src/ZeldaWindWaker/d_particle.ts @@ -287,20 +287,21 @@ class dPa_simpleEcallBack extends JPAEmitterCallBack { emitter.playCreateParticle(); for (let simple of this.datas) { - // TODO: Frustum culling - emitter.setGlobalTranslation(workData.emitterTranslation); - colorCopy(emitter.globalColorPrm, simple.prmColor); - colorCopy(emitter.globalColorEnv, simple.envColor); - for (let i = 0; i < emitThisFrame; i++) { - const particle = emitter.createParticle(); - if (!particle) - break; - - // NOTE: Overwriting this removes the influence of the local emitter translation (bem.emitterTrs) - // I.e. all simple emitters ignore their local offsets and are fixed to the local origin. - vec3.copy(particle.offsetPosition, simple.pos); - if (simple.isAffectedByWind) { - // TODO: Wind callback + if (!workData.frustum || workData.frustum.containsSphere(simple.pos, 200)) { + emitter.setGlobalTranslation(simple.pos); + colorCopy(emitter.globalColorPrm, simple.prmColor); + colorCopy(emitter.globalColorEnv, simple.envColor); + for (let i = 0; i < emitThisFrame; i++) { + const particle = emitter.createParticle(); + if (!particle) + break; + + // NOTE: Overwriting this removes the influence of the local emitter translation (bem.emitterTrs) + // I.e. all simple emitters ignore their local offsets and are fixed to the local origin. + vec3.copy(particle.offsetPosition, simple.pos); + if (simple.isAffectedByWind) { + // TODO: Wind callback + } } } }