Remove particles emiter bounds compute

This commit is contained in:
Atlante45 2015-11-19 15:24:36 -08:00
parent 2cb2ca29e6
commit 0f316e6ae1
3 changed files with 25 additions and 30 deletions

View file

@ -58,7 +58,7 @@ public:
void setModelTransform(const Transform& modelTransform) { _modelTransform = modelTransform; }
const AABox& getBound() const { return _bound; }
void setBound(AABox& bound) { _bound = bound; }
void setBound(const AABox& bound) { _bound = bound; }
BufferPointer getParticleBuffer() { return _particleBuffer; }
const BufferPointer& getParticleBuffer() const { return _particleBuffer; }
@ -242,12 +242,9 @@ void RenderableParticleEffectEntityItem::updateRenderItem() {
Transform transform;
transform.setTranslation(position);
transform.setRotation(rotation);
payload.setModelTransform(transform);
AABox bounds(_particlesBounds);
bounds.rotate(rotation);
bounds.shiftBy(position);
payload.setBound(bounds);
payload.setBound(getAABox());
bool textured = _texture && _texture->isLoaded();
if (textured) {

View file

@ -592,20 +592,17 @@ void ParticleEffectEntityItem::integrateParticle(Particle& particle, float delta
}
void ParticleEffectEntityItem::stepSimulation(float deltaTime) {
_particlesBounds.reset();
// update particles between head and tail
for (Particle& particle : _particles) {
particle.lifetime += deltaTime;
// if particle has died.
if (particle.lifetime >= _lifespan || _lifespan < EPSILON) {
if (particle.lifetime >= _lifespan) {
// move head forward
_particles.pop_front();
} else {
// Otherwise update it
integrateParticle(particle, deltaTime);
_particlesBounds.addPoint(particle.position);
}
}
@ -628,7 +625,6 @@ void ParticleEffectEntityItem::stepSimulation(float deltaTime) {
// Initialize it
integrateParticle(particle, deltaTime);
_particlesBounds.addPoint(particle.position);
// Advance in frame
timeLeftInFrame -= _timeUntilNextEmit;

View file

@ -237,10 +237,7 @@ protected:
// Particles container
Particles _particles;
// bounding volume
Extents _particlesBounds;
// the properties of this entity
// Particles properties
rgbColor _color;
xColor _colorStart = DEFAULT_COLOR;
xColor _colorFinish = DEFAULT_COLOR;
@ -249,25 +246,30 @@ protected:
float _alphaStart = DEFAULT_ALPHA_START;
float _alphaFinish = DEFAULT_ALPHA_FINISH;
float _alphaSpread = DEFAULT_ALPHA_SPREAD;
quint32 _maxParticles = DEFAULT_MAX_PARTICLES;
float _lifespan = DEFAULT_LIFESPAN;
float _emitRate = DEFAULT_EMIT_RATE;
float _emitSpeed = DEFAULT_EMIT_SPEED;
float _speedSpread = DEFAULT_SPEED_SPREAD;
glm::quat _emitOrientation = DEFAULT_EMIT_ORIENTATION;
glm::vec3 _emitDimensions = DEFAULT_EMIT_DIMENSIONS;
float _emitRadiusStart = DEFAULT_EMIT_RADIUS_START;
float _polarStart = DEFAULT_POLAR_START;
float _polarFinish = DEFAULT_POLAR_FINISH;
float _azimuthStart = DEFAULT_AZIMUTH_START;
float _azimuthFinish = DEFAULT_AZIMUTH_FINISH;
glm::vec3 _emitAcceleration = DEFAULT_EMIT_ACCELERATION;
glm::vec3 _accelerationSpread = DEFAULT_ACCELERATION_SPREAD;
float _particleRadius = DEFAULT_PARTICLE_RADIUS;
float _radiusStart = DEFAULT_RADIUS_START;
float _radiusFinish = DEFAULT_RADIUS_FINISH;
float _radiusSpread = DEFAULT_RADIUS_SPREAD;
float _lifespan = DEFAULT_LIFESPAN;
// Emiter properties
quint32 _maxParticles = DEFAULT_MAX_PARTICLES;
float _emitRate = DEFAULT_EMIT_RATE;
float _emitSpeed = DEFAULT_EMIT_SPEED;
float _speedSpread = DEFAULT_SPEED_SPREAD;
glm::quat _emitOrientation = DEFAULT_EMIT_ORIENTATION;
glm::vec3 _emitDimensions = DEFAULT_EMIT_DIMENSIONS;
float _emitRadiusStart = DEFAULT_EMIT_RADIUS_START;
glm::vec3 _emitAcceleration = DEFAULT_EMIT_ACCELERATION;
glm::vec3 _accelerationSpread = DEFAULT_ACCELERATION_SPREAD;
float _polarStart = DEFAULT_POLAR_START;
float _polarFinish = DEFAULT_POLAR_FINISH;
float _azimuthStart = DEFAULT_AZIMUTH_START;
float _azimuthFinish = DEFAULT_AZIMUTH_FINISH;
quint64 _lastSimulated { 0 };
bool _isEmitting { true };