diff options
author | Stijn Buys <ingar@osirion.org> | 2013-01-21 18:37:59 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2013-01-21 18:37:59 +0000 |
commit | 266d0d2cf6648509650bdd490c8e9c64be75b92e (patch) | |
tree | df5fdb640ed09edcf044efdc8784b18a5881a513 /src/render/particlesystem.cc | |
parent | d4f9da2f3c19511b028da2569d7b6a8d1371e135 (diff) |
Added attached property to draw particle systems in entity space instead of world space,
corrected several bugs in the initial particle system implementation,
added impulse key to have particle systems react on impulse drive.
Diffstat (limited to 'src/render/particlesystem.cc')
-rw-r--r-- | src/render/particlesystem.cc | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/src/render/particlesystem.cc b/src/render/particlesystem.cc index ff9c720..920d77c 100644 --- a/src/render/particlesystem.cc +++ b/src/render/particlesystem.cc @@ -4,6 +4,7 @@ the terms of the GNU General Public License version 2 */ +#include "render/gl.h" #include "render/particlesystem.h" namespace render { @@ -121,23 +122,45 @@ void ParticleSystem::draw(const float seconds) math::Axis current_axis(entity() ? entity()->axis() * axis() : axis()); for (Ejectors::iterator it = ejectors().begin(); it != ejectors().end(); ++it) { - + + ParticleEjector *ejector = (*it); + if (entity()) { bool ejector_active = true; + if (entity()->type() == core::Entity::Controlable) { + const core::EntityControlable *controlable = static_cast<const core::EntityControlable *>(entity()); - if ((*it)->thrust()) { - // thrust activated - const core::EntityControlable *controlable = static_cast<const core::EntityControlable *>(entity()); - if ( controlable->thrust() == 0.0f ) { - ejector_active = false; + if (ejector->impulse() || ejector->thrust()) { + ejector_active = false; + + switch (controlable->state()) { + case core::Entity::Impulse: + case core::Entity::ImpulseInitiate: + if (ejector->impulse() || ejector->thrust()) { + ejector_active = true; + } + break; + + case core::Entity::Normal: + if (ejector->thrust()) { + if (controlable->thrust() > 0.0f) { + ejector_active = true; + } + } + break; + + default: + ejector_active = false; + break; } - (*it)->enable(ejector_active); + ejector->enable(ejector_active); } } } - (*it)->frame(seconds, current_location, current_axis); + (*it)->frame(seconds, current_location, current_axis * ejector->axis()); + } } |