Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2013-10-20 11:58:27 +0000
committerStijn Buys <ingar@osirion.org>2013-10-20 11:58:27 +0000
commit844712beaf13127ab7e54cff1a00d87ae260d522 (patch)
tree0d3f47a4608f62d31bc118782a32e23b1ffd024b
parent55f9c240525d77686d00d43f627db7892f27e1de (diff)
Make thrust triggered particle ejectors set output particle speed depending on the current entity thrust value.
-rw-r--r--src/render/particleejector.cc6
-rw-r--r--src/render/particleejector.h2
-rw-r--r--src/render/particlesystem.cc11
3 files changed, 13 insertions, 6 deletions
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());
-
}
}