From cf0f21b73e53b4371c42c95e1132b1d3ce69ade5 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Wed, 30 Jul 2008 19:50:51 +0000 Subject: minimize opengl transformation matrix by doing eye-location in software --- src/render/dust.cc | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'src/render/dust.cc') 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); } -- cgit v1.2.3