From 844712beaf13127ab7e54cff1a00d87ae260d522 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 20 Oct 2013 11:58:27 +0000 Subject: Make thrust triggered particle ejectors set output particle speed depending on the current entity thrust value. --- src/render/particleejector.cc | 6 +++--- src/render/particleejector.h | 2 +- src/render/particlesystem.cc | 11 +++++++++-- 3 files changed, 13 insertions(+), 6 deletions(-) (limited to 'src/render') diff --git a/src/render/particleejector.cc b/src/render/particleejector.cc index 5fae7d1..22ddf2d 100644 --- a/src/render/particleejector.cc +++ b/src/render/particleejector.cc @@ -38,7 +38,7 @@ void ParticleEjector::clear() ejector_last_eject = 0; } -void ParticleEjector::frame(const float seconds, const math::Vector3f & ps_location, const math::Axis & ps_axis) +void ParticleEjector::frame(const float seconds, const math::Vector3f & ps_location, const math::Axis & ps_axis, const float thrust_factor) { unsigned long now = core::application()->timestamp(); @@ -58,7 +58,7 @@ void ParticleEjector::frame(const float seconds, const math::Vector3f & ps_locat if (!ejector_timestamp) { ejector_timestamp = now; } - + if (!timeout() || (ejector_timestamp + timeout() > now)) { while (ejector_last_eject > interval()) { @@ -87,7 +87,7 @@ void ParticleEjector::frame(const float seconds, const math::Vector3f & ps_locat particle->get_color().a = alpha_vec()[0]; particle->set_rotation(math::randomf(2.0f * M_PI)); - particle->set_speed(math::randomf(speed_vec()[0], speed_vec()[1])); + particle->set_speed(math::randomf(speed_vec()[0], speed_vec()[1]) * thrust_factor ); particles().push_front(particle); if (type() == Streak) { diff --git a/src/render/particleejector.h b/src/render/particleejector.h index 838af12..d68b32f 100644 --- a/src/render/particleejector.h +++ b/src/render/particleejector.h @@ -53,7 +53,7 @@ public: /** * @brief updated the particles attached to the ejector, and drawn them * */ - void frame(const float seconds, const math::Vector3f & ps_location, const math::Axis & ps_axis); + void frame(const float seconds, const math::Vector3f & ps_location, const math::Axis & ps_axis, const float thrust_factor); /** * @brief remove all particles diff --git a/src/render/particlesystem.cc b/src/render/particlesystem.cc index c085d5d..c29243c 100644 --- a/src/render/particlesystem.cc +++ b/src/render/particlesystem.cc @@ -156,8 +156,13 @@ void ParticleSystem::draw(const float seconds) ParticleEjector *ejector = (*it); if (entity()) { + float thrust_factor = 1.0f; bool ejector_active = true; + if (ejector->thrust()) { + thrust_factor = 0.0f; + } + if (ejector->impulse() || ejector->thrust() || ejector->explosion()) { ejector_active = false; } @@ -170,6 +175,7 @@ void ParticleSystem::draw(const float seconds) case core::Entity::ImpulseInitiate: if (ejector->impulse()) { ejector_active = true; + thrust_factor = 1.0f; } break; @@ -177,6 +183,7 @@ void ParticleSystem::draw(const float seconds) if (ejector->thrust()) { if (controlable->thrust() > 0.0f) { ejector_active = true; + thrust_factor = controlable->thrust(); } } break; @@ -223,10 +230,10 @@ void ParticleSystem::draw(const float seconds) } } ejector->enable(ejector_active); + + (*it)->frame(seconds, current_location, current_axis * ejector->axis(), thrust_factor); } - (*it)->frame(seconds, current_location, current_axis * ejector->axis()); - } } -- cgit v1.2.3