diff options
author | Stijn Buys <ingar@osirion.org> | 2008-07-18 22:07:46 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-07-18 22:07:46 +0000 |
commit | c3d90b226bdd83592d08704aa918f155f4c757e2 (patch) | |
tree | dd9ef9b9ebec66c707744de05ad39fd8918452fa /src/render | |
parent | 2698d8cd1d28cd9649fcfe35a3397d52b28f1b34 (diff) |
reset spacedust on ship change, audio distance model changes (should fix win32 ui sound dissapearing in the distance)
Diffstat (limited to 'src/render')
-rw-r--r-- | src/render/draw.cc | 6 | ||||
-rw-r--r-- | src/render/draw.h | 3 | ||||
-rw-r--r-- | src/render/dust.cc | 36 | ||||
-rw-r--r-- | src/render/dust.h | 2 |
4 files changed, 28 insertions, 19 deletions
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(); }; } |