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-01-27 17:24:16 +0000
committerStijn Buys <ingar@osirion.org>2013-01-27 17:24:16 +0000
commitf4eee214a79634cdd2e6fe576950524170c01fa9 (patch)
treec00f9685202c5c4ae502e2a632d341643e5b1ba8 /src/render
parentfd6663f0d3a4e860c14a0f3279fcce06d27fa283 (diff)
Support for particle ejector timeout value,
do not draw destroyed entity models.,
Diffstat (limited to 'src/render')
-rw-r--r--src/render/draw.h1
-rw-r--r--src/render/particleejector.cc79
-rw-r--r--src/render/particleejector.h1
-rw-r--r--src/render/particleejectorscript.cc2
-rw-r--r--src/render/particleejectorscript.h15
-rw-r--r--src/render/particlesystemscript.cc4
-rw-r--r--src/render/renderext.cc7
7 files changed, 74 insertions, 35 deletions
diff --git a/src/render/draw.h b/src/render/draw.h
index a3b4d30..4b59b63 100644
--- a/src/render/draw.h
+++ b/src/render/draw.h
@@ -61,4 +61,3 @@ public:
}
#endif // __INCLUDED_RENDER_DRAW_H__
-
diff --git a/src/render/particleejector.cc b/src/render/particleejector.cc
index acec84f..29a255d 100644
--- a/src/render/particleejector.cc
+++ b/src/render/particleejector.cc
@@ -21,6 +21,7 @@ ParticleEjector::ParticleEjector(const ParticleEjectorScript &script) : Particle
{
ejector_last_eject = 0;
ejector_enabled = true;
+ ejector_timestamp = 0;
}
ParticleEjector::~ParticleEjector()
@@ -53,45 +54,55 @@ void ParticleEjector::frame(const float seconds, const math::Vector3f & ps_locat
// add new particles
if (ejector_enabled) {
- while (ejector_last_eject > interval()) {
- math::Vector3f particle_location;
- math::Axis particle_axis;
- if (!attached()) {
- particle_location.assign(ps_location);
- particle_axis.assign(ps_axis);
- }
- particle_axis.change_roll(math::randomf(360.0f));
- if (cone() > 0) {
- particle_axis.change_pitch(math::randomf(cone()) - (cone() * 0.5f) );
- }
- if (spawn_radius() > 0) {
- // FIXME find a faster formula
- math::Axis random_axis(ps_axis);
- random_axis.change_roll(math::randomf(360.0f));
- random_axis.change_pitch(math::randomf(180.0f));
- particle_location += random_axis.forward() * spawn_radius();
- }
-
- Particle *particle = new Particle(particle_location, particle_axis, now);
- particle->set_radius(radius_vec()[0]);
- particle->set_alpha(alpha_vec()[0]);
- particle->set_rotation(math::randomf(2.0f * M_PI));
- particle->set_speed(math::randomf(speed_vec()[0], speed_vec()[1]));
- particles().push_front(particle);
+
+ if (!ejector_timestamp) {
+ ejector_timestamp = now;
+ }
+
+ if (!timeout() || (ejector_timestamp + timeout() > now)) {
- if (type() == Streak) {
- Particle *tail = new Particle(particle_location, particle_axis, now);
- tail->set_radius(radius_vec()[0]);
- tail->set_alpha(alpha_vec()[0]);
- tail->set_rotation(particle->rotation());
- tail->set_speed(math::randomf(tailspeed_vec()[0], tailspeed_vec()[1]));
- particles().push_front(tail);
+ while (ejector_last_eject > interval()) {
+ math::Vector3f particle_location;
+ math::Axis particle_axis;
+ if (!attached()) {
+ particle_location.assign(ps_location);
+ particle_axis.assign(ps_axis);
+ }
+ particle_axis.change_roll(math::randomf(360.0f));
+ if (cone() > 0) {
+ particle_axis.change_pitch(math::randomf(cone()) - (cone() * 0.5f) );
+ }
+ if (spawn_radius() > 0) {
+ // FIXME find a faster formula
+ math::Axis random_axis(ps_axis);
+ random_axis.change_roll(math::randomf(360.0f));
+ random_axis.change_pitch(math::randomf(180.0f));
+ particle_location += random_axis.forward() * spawn_radius();
+ }
+
+ Particle *particle = new Particle(particle_location, particle_axis, now);
+ particle->set_radius(radius_vec()[0]);
+ particle->set_alpha(alpha_vec()[0]);
+ particle->set_rotation(math::randomf(2.0f * M_PI));
+ particle->set_speed(math::randomf(speed_vec()[0], speed_vec()[1]));
+ particles().push_front(particle);
+
+ if (type() == Streak) {
+ Particle *tail = new Particle(particle_location, particle_axis, now);
+ tail->set_radius(radius_vec()[0]);
+ tail->set_alpha(alpha_vec()[0]);
+ tail->set_rotation(particle->rotation());
+ tail->set_speed(math::randomf(tailspeed_vec()[0], tailspeed_vec()[1]));
+ particles().push_front(tail);
+ }
+
+ ejector_last_eject -= interval();
}
-
- ejector_last_eject -= interval();
}
+
} else {
ejector_last_eject = 0;
+ ejector_timestamp = 0;
}
for (Particles::iterator it = particles().begin(); it != particles().end(); ++it) {
diff --git a/src/render/particleejector.h b/src/render/particleejector.h
index 743e370..838af12 100644
--- a/src/render/particleejector.h
+++ b/src/render/particleejector.h
@@ -69,6 +69,7 @@ protected:
virtual void draw(const math::Vector3f & ps_location, const math::Axis & ps_axis);
private:
+ unsigned long ejector_timestamp;
unsigned long ejector_last_eject;
Particles ejector_particles;
bool ejector_enabled;
diff --git a/src/render/particleejectorscript.cc b/src/render/particleejectorscript.cc
index 2b6f8ce..b2c84bc 100644
--- a/src/render/particleejectorscript.cc
+++ b/src/render/particleejectorscript.cc
@@ -17,6 +17,7 @@ ParticleEjectorScript::ParticleEjectorScript()
script_cone = 0.0f;
script_offset = 0.5f;
script_lifespan = 1000;
+ script_timeout = 0;
script_acceleration = 0.0f;
script_entity = false;
script_entity_second = false;
@@ -37,6 +38,7 @@ ParticleEjectorScript::ParticleEjectorScript(const ParticleEjectorScript &other)
script_spawn_radius = other.spawn_radius();
script_offset = other.offset();
script_lifespan = other.lifespan();
+ script_timeout = other.timeout();
script_acceleration = other.acceleration();
script_entity = other.entity();
script_entity_second = other.entity_second();
diff --git a/src/render/particleejectorscript.h b/src/render/particleejectorscript.h
index 4ba8dea..535458e 100644
--- a/src/render/particleejectorscript.h
+++ b/src/render/particleejectorscript.h
@@ -51,6 +51,11 @@ public:
return script_interval;
}
+ inline const unsigned long timeout() const
+ {
+ return script_timeout;
+ }
+
/**
* @brief angle of the cone through which to randomly spread ejected particles
* */
@@ -300,6 +305,14 @@ public:
}
/**
+ * @brief set the time after which no more particles are ejected, in milliseconds
+ * */
+ inline void set_timeout(const unsigned long timeout)
+ {
+ script_timeout = timeout;
+ }
+
+ /**
* @brief set particle lifespan, in milliseconds
* */
inline void set_lifespan(const unsigned long lifespan)
@@ -415,6 +428,8 @@ private:
math::Axis script_axis;
/// interval between to ejects, in milliseconds
unsigned long script_interval;
+ /// time after which no more particles are ejected, in milliseconds
+ unsigned long script_timeout;
/// lifespan of a particle, in milliseconds
unsigned long script_lifespan;
/// ejector cone, in default 360 degrees
diff --git a/src/render/particlesystemscript.cc b/src/render/particlesystemscript.cc
index 0fad772..f78fa88 100644
--- a/src/render/particlesystemscript.cc
+++ b/src/render/particlesystemscript.cc
@@ -212,6 +212,10 @@ ParticleSystemScript *ParticleSystemScript::load(const std::string &label)
ejector->set_lifespan((unsigned long) l);
continue;
+ } else if (inifile.got_key_long("timeout", l)) {
+ ejector->set_timeout((unsigned long) l);
+ continue;
+
} else if (inifile.got_key_color("color", ejector->get_color())) {
continue;
diff --git a/src/render/renderext.cc b/src/render/renderext.cc
index 6730aba..7ac5702 100644
--- a/src/render/renderext.cc
+++ b/src/render/renderext.cc
@@ -190,6 +190,13 @@ void RenderExt::frame(float elapsed)
// entity within detail range
state_visible = true;
state_detailvisible = true;
+
+ if ((entity()->type() == core::Entity::Controlable) || (entity()->type() == core::Entity::Dynamic)) {
+
+ if (static_cast<core::EntityDynamic *>(entity())->state() == core::Entity::Destroyed) {
+ state_visible = false;
+ }
+ }
} else if (distance() < core::range::maxdistance) {