From c3d90b226bdd83592d08704aa918f155f4c757e2 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Fri, 18 Jul 2008 22:07:46 +0000 Subject: reset spacedust on ship change, audio distance model changes (should fix win32 ui sound dissapearing in the distance) --- src/render/dust.cc | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) (limited to 'src/render/dust.cc') diff --git a/src/render/dust.cc b/src/render/dust.cc index b9e53a5..37dd217 100644 --- a/src/render/dust.cc +++ b/src/render/dust.cc @@ -17,11 +17,11 @@ namespace render core::Cvar *r_dust; core::Cvar *r_dustsize; -const float MAXDUSTDISTANCE = 8.0f; -const float MINDUSTDISTANCE = 6.0f; const float LOWSPEEDLIMIT = 5.0f; const float TRAILLENGHT = 0.25f; -const float MAXDUSTALPHA = 0.8f; +const float DUSTMAXALPHA = 0.8f; +const float DUSTDISTANCE = 8.0f; + float *dust; size_t dustsize; @@ -46,6 +46,12 @@ void Dust::shutdown() } } +void Dust::reset() +{ + delete dust; + dust = 0; +} + void Dust::draw() { if (!r_dust->value()) { @@ -83,9 +89,9 @@ void Dust::draw() dust = new float[dustsize*3]; for (size_t i = 0; i < dustsize; i++) { - dust[i*3] = core::localcontrol()->location().x + (math::randomf(2) - 1) * MINDUSTDISTANCE; - dust[i*3+1] = core::localcontrol()->location().y + (math::randomf(2) - 1) * MINDUSTDISTANCE; - dust[i*3+2] = core::localcontrol()->location().z + (math::randomf(2) - 1) * MINDUSTDISTANCE; + dust[i*3] = core::localcontrol()->location().x + (math::randomf(2) - 1) * (DUSTDISTANCE + core::localcontrol()->radius()); + dust[i*3+1] = core::localcontrol()->location().y + (math::randomf(2) - 1) * (DUSTDISTANCE + core::localcontrol()->radius()); + dust[i*3+2] = core::localcontrol()->location().z + (math::randomf(2) - 1) * (DUSTDISTANCE + core::localcontrol()->radius()); } } @@ -96,7 +102,7 @@ void Dust::draw() if (core::localcontrol()->speed() < LOWSPEEDLIMIT) { color.a = core::localcontrol()->speed() / LOWSPEEDLIMIT; } - color.a *= MAXDUSTALPHA; + color.a *= DUSTMAXALPHA; gl::color(color); gl::begin(gl::Lines); @@ -107,19 +113,11 @@ void Dust::draw() for (size_t j = 0; j < 3; j++) v[j] -= dust[i*3+j]; - if (v.lengthsquared() > (core::localcontrol()->radius() + MAXDUSTDISTANCE)*(core::localcontrol()->radius() + MAXDUSTDISTANCE)) { -/* - v.assign(core::localcontrol()->state()->location()); - v += core::localcontrol()->state()->axis().forward() * (core::localcontrol()->radius() + math::randomf(MAXDUSTDISTANCE)); - v += core::localcontrol()->state()->axis().left() * (math::randomf(2*MINDUSTDISTANCE) - MINDUSTDISTANCE); - v += core::localcontrol()->state()->axis().up() * (math::randomf(2*MINDUSTDISTANCE) - MINDUSTDISTANCE); + if (v.lengthsquared() > (core::localcontrol()->radius() + DUSTDISTANCE)*(core::localcontrol()->radius() + DUSTDISTANCE)) { - for (size_t j = 0; j < 3; j++) - dust[i*3+j] = v[j]; -*/ - dust[i*3] = core::localcontrol()->location().x + (math::randomf(2) - 1) * (MAXDUSTDISTANCE + core::localcontrol()->radius()); - dust[i*3+1] = core::localcontrol()->location().y + (math::randomf(2) - 1) * (MAXDUSTDISTANCE + core::localcontrol()->radius()); - dust[i*3+2] = core::localcontrol()->location().z + (math::randomf(2) - 1) * (MAXDUSTDISTANCE + core::localcontrol()->radius()); + dust[i*3] = core::localcontrol()->location().x + (math::randomf(2) - 1) * (DUSTDISTANCE + core::localcontrol()->radius()); + dust[i*3+1] = core::localcontrol()->location().y + (math::randomf(2) - 1) * (DUSTDISTANCE + core::localcontrol()->radius()); + dust[i*3+2] = core::localcontrol()->location().z + (math::randomf(2) - 1) * (DUSTDISTANCE + core::localcontrol()->radius()); } glVertex3fv(dust+3*i); -- cgit v1.2.3