diff options
author | Stijn Buys <ingar@osirion.org> | 2008-07-26 15:44:17 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-07-26 15:44:17 +0000 |
commit | ad4b28abd9a545bebaf4dd77cb6a13863ace9843 (patch) | |
tree | ffd2bc35b18f782166eb5118cd3a1dfe2536c073 /src | |
parent | a9022ae546f92e93c87a08bb18f4c09f815db866 (diff) |
make statefull engine trails
Diffstat (limited to 'src')
-rw-r--r-- | src/core/clientstate.cc | 1 | ||||
-rw-r--r-- | src/core/clientstate.h | 1 | ||||
-rw-r--r-- | src/render/draw.cc | 12 |
3 files changed, 10 insertions, 4 deletions
diff --git a/src/core/clientstate.cc b/src/core/clientstate.cc index 503a71f..8e6606d 100644 --- a/src/core/clientstate.cc +++ b/src/core/clientstate.cc @@ -21,6 +21,7 @@ ClientState::ClientState() state_screenlocation[i] = 0; state_fuzz = math::randomf(); + state_engine_trail_offset = 0; } ClientState::ClientState(Entity *entity) diff --git a/src/core/clientstate.h b/src/core/clientstate.h index 87dd1d7..91cd3e1 100644 --- a/src/core/clientstate.h +++ b/src/core/clientstate.h @@ -65,6 +65,7 @@ public: bool state_targetable; float state_fuzz; + float state_engine_trail_offset; size_t state_enginesound; }; diff --git a/src/render/draw.cc b/src/render/draw.cc index 01cddf3..7866dbe 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -607,7 +607,7 @@ void draw_pass_model_fragments() } /* draw model lights and engines */ -void draw_pass_model_fx() +void draw_pass_model_fx(float elapsed) { float t; @@ -724,8 +724,12 @@ void draw_pass_model_fx() float u = static_cast<core::EntityControlable *>(entity)->thrust(); if (u > 0) { - float fraction = (core::application()->time() + entity->state()->fuzz()) * 4.0f * u; - fraction = fraction - floorf(fraction); + float fraction = entity->state()->state_engine_trail_offset; + fraction += elapsed * 4.0f * u; + + while (fraction - 1.0f > 0) + fraction -= 1.0f; + entity->state()->state_engine_trail_offset = fraction; for(model::Model::Engines::iterator eit = entity->model()->engines().begin(); eit != entity->model()->engines().end(); eit++) { @@ -960,7 +964,7 @@ void draw(float seconds) Dust::draw(); // draw spacedust - draw_pass_model_fx(); // draw entity lights and engines + draw_pass_model_fx(seconds); // draw entity lights and engines gl::enable(GL_LIGHTING); gl::enable(GL_RESCALE_NORMAL); |