diff options
author | Stijn Buys <ingar@osirion.org> | 2008-07-30 19:50:51 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-07-30 19:50:51 +0000 |
commit | cf0f21b73e53b4371c42c95e1132b1d3ce69ade5 (patch) | |
tree | f5efa4f20c581ab6a2672666d4b2df4ee9ce2b44 /src/render/dust.cc | |
parent | 04050c1685855a0640c7c0d5147299fadbd2ebe8 (diff) |
minimize opengl transformation matrix by doing eye-location in software
Diffstat (limited to 'src/render/dust.cc')
-rw-r--r-- | src/render/dust.cc | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/render/dust.cc b/src/render/dust.cc index 05266e8..a3eac6d 100644 --- a/src/render/dust.cc +++ b/src/render/dust.cc @@ -4,6 +4,7 @@ the terms of the GNU General Public License version 2 */ +#include "render/camera.h" #include "render/dust.h" #include "render/gl.h" #include "core/cvar.h" @@ -54,6 +55,9 @@ void Dust::reset() void Dust::draw() { + float alpha = 0.0f; + float traillength = 0.0f; + if (!r_dust->value()) { if (dust) { delete dust; @@ -95,14 +99,19 @@ void Dust::draw() } } - if (!core::localcontrol()->speed()) + if (! core::localcontrol()->speed()) return; - math::Color color; - if (core::localcontrol()->speed() < LOWSPEEDLIMIT) { - color.a = core::localcontrol()->speed() / LOWSPEEDLIMIT; - } - color.a *= DUSTMAXALPHA; + math::Color color(1.0f, 1.0f); + alpha = core::localcontrol()->speed() / LOWSPEEDLIMIT; + if (alpha > DUSTMAXALPHA) + alpha = DUSTMAXALPHA; + color.a = alpha; + + traillength = core::localcontrol()->speed() / LOWSPEEDLIMIT; + if (traillength > 1) + traillength = 1.0f; + traillength *= TRAILLENGHT; gl::color(color); gl::begin(gl::Lines); @@ -120,11 +129,11 @@ void Dust::draw() dust[i*3+2] = core::localcontrol()->location().z + (math::randomf(2) - 1) * (DUSTDISTANCE + core::localcontrol()->radius()); } - glVertex3fv(dust+3*i); - for (size_t j = 0; j < 3; j++) v[j] = dust[i*3+j]; - v -= core::localcontrol()->state()->axis().forward() * color.a * TRAILLENGHT; + v -= Camera::eye(); + gl::vertex(v); + v -= core::localcontrol()->state()->axis().forward() * traillength; gl::vertex(v); } |