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/draw.cc | 6 ++++++ src/render/draw.h | 3 +++ src/render/dust.cc | 36 +++++++++++++++++------------------- src/render/dust.h | 2 ++ 4 files changed, 28 insertions(+), 19 deletions(-) (limited to 'src/render') diff --git a/src/render/draw.cc b/src/render/draw.cc index 1f920b0..8855343 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -889,4 +889,10 @@ void draw(float seconds) // GL_BLEND must be enabled for the GUI } +// reset drawing parameters for a new localcontrol +void reset() +{ + Dust::reset(); +} + } diff --git a/src/render/draw.h b/src/render/draw.h index ee9db26..89c5ea7 100644 --- a/src/render/draw.h +++ b/src/render/draw.h @@ -16,6 +16,9 @@ namespace render /// draw the world void draw(float seconds); +/// reset +void reset(); + /// draw a sphere void draw_sphere(math::Color const & color, float radius); 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); diff --git a/src/render/dust.h b/src/render/dust.h index 031743e..6a4b455 100644 --- a/src/render/dust.h +++ b/src/render/dust.h @@ -20,6 +20,8 @@ public: static void shutdown(); static void draw(); + + static void reset(); }; } -- cgit v1.2.3