mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 18:42:58 +02:00
properly pause particles when you look away
This commit is contained in:
parent
82638e47c4
commit
11ad64c606
2 changed files with 6 additions and 5 deletions
|
@ -199,7 +199,7 @@ float importanceSample3DDimension(float startDim) {
|
||||||
return dimension;
|
return dimension;
|
||||||
}
|
}
|
||||||
|
|
||||||
ParticleEffectEntityRenderer::CpuParticle ParticleEffectEntityRenderer::createParticle(uint64_t now, const Transform& baseTransform, const particle::Properties& particleProperties,
|
ParticleEffectEntityRenderer::CpuParticle ParticleEffectEntityRenderer::createParticle(const Transform& baseTransform, const particle::Properties& particleProperties,
|
||||||
const ShapeType& shapeType, const GeometryResource::Pointer& geometryResource,
|
const ShapeType& shapeType, const GeometryResource::Pointer& geometryResource,
|
||||||
const TriangleInfo& triangleInfo) {
|
const TriangleInfo& triangleInfo) {
|
||||||
CpuParticle particle;
|
CpuParticle particle;
|
||||||
|
@ -217,7 +217,7 @@ ParticleEffectEntityRenderer::CpuParticle ParticleEffectEntityRenderer::createPa
|
||||||
const auto& polarFinish = particleProperties.polar.finish;
|
const auto& polarFinish = particleProperties.polar.finish;
|
||||||
|
|
||||||
particle.seed = randFloatInRange(-1.0f, 1.0f);
|
particle.seed = randFloatInRange(-1.0f, 1.0f);
|
||||||
particle.expiration = now + (uint64_t)(particleProperties.lifespan * USECS_PER_SECOND);
|
particle.expiration = (uint64_t)(particleProperties.lifespan * USECS_PER_SECOND);
|
||||||
|
|
||||||
particle.relativePosition = glm::vec3(0.0f);
|
particle.relativePosition = glm::vec3(0.0f);
|
||||||
particle.basePosition = baseTransform.getTranslation();
|
particle.basePosition = baseTransform.getTranslation();
|
||||||
|
@ -403,7 +403,7 @@ void ParticleEffectEntityRenderer::stepSimulation() {
|
||||||
computeTriangles(geometryResource->getHFMModel());
|
computeTriangles(geometryResource->getHFMModel());
|
||||||
}
|
}
|
||||||
// emit particle
|
// emit particle
|
||||||
_cpuParticles.push_back(createParticle(now, modelTransform, particleProperties, shapeType, geometryResource, _triangleInfo));
|
_cpuParticles.push_back(createParticle(modelTransform, particleProperties, shapeType, geometryResource, _triangleInfo));
|
||||||
_timeUntilNextEmit = emitInterval;
|
_timeUntilNextEmit = emitInterval;
|
||||||
if (emitInterval < timeRemaining) {
|
if (emitInterval < timeRemaining) {
|
||||||
timeRemaining -= emitInterval;
|
timeRemaining -= emitInterval;
|
||||||
|
@ -415,7 +415,7 @@ void ParticleEffectEntityRenderer::stepSimulation() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kill any particles that have expired or are over the max size
|
// Kill any particles that have expired or are over the max size
|
||||||
while (_cpuParticles.size() > particleProperties.maxParticles || (!_cpuParticles.empty() && _cpuParticles.front().expiration <= now)) {
|
while (_cpuParticles.size() > particleProperties.maxParticles || (!_cpuParticles.empty() && _cpuParticles.front().expiration == 0)) {
|
||||||
_cpuParticles.pop_front();
|
_cpuParticles.pop_front();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,6 +428,7 @@ void ParticleEffectEntityRenderer::stepSimulation() {
|
||||||
}
|
}
|
||||||
particle.basePosition = modelTransform.getTranslation();
|
particle.basePosition = modelTransform.getTranslation();
|
||||||
}
|
}
|
||||||
|
particle.expiration = particle.expiration >= interval ? particle.expiration - interval : 0;
|
||||||
particle.integrate(deltaTime);
|
particle.integrate(deltaTime);
|
||||||
}
|
}
|
||||||
_prevEmitterShouldTrail = particleProperties.emission.shouldTrail;
|
_prevEmitterShouldTrail = particleProperties.emission.shouldTrail;
|
||||||
|
|
|
@ -88,7 +88,7 @@ private:
|
||||||
glm::mat4 transform;
|
glm::mat4 transform;
|
||||||
} _triangleInfo;
|
} _triangleInfo;
|
||||||
|
|
||||||
static CpuParticle createParticle(uint64_t now, const Transform& baseTransform, const particle::Properties& particleProperties,
|
static CpuParticle createParticle(const Transform& baseTransform, const particle::Properties& particleProperties,
|
||||||
const ShapeType& shapeType, const GeometryResource::Pointer& geometryResource,
|
const ShapeType& shapeType, const GeometryResource::Pointer& geometryResource,
|
||||||
const TriangleInfo& triangleInfo);
|
const TriangleInfo& triangleInfo);
|
||||||
void stepSimulation();
|
void stepSimulation();
|
||||||
|
|
Loading…
Reference in a new issue