diff options
Diffstat (limited to 'src/render/dust.cc')
-rw-r--r-- | src/render/dust.cc | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/render/dust.cc b/src/render/dust.cc index 1ca422c..32d2081 100644 --- a/src/render/dust.cc +++ b/src/render/dust.cc @@ -20,9 +20,8 @@ core::Cvar *r_dustsize; const float LOWSPEEDLIMIT = 5.0f; const float TRAILLENGHT = 0.25f; -const float DUSTDISTANCE = 8.0f; -float *dust = 0; +float *dust = 0; size_t dustsize = 0; void Dust::init() @@ -54,7 +53,7 @@ void Dust::reset() } } -void Dust::draw(math::Color const &dustcolor) +void Dust::draw(const Camera &camera, const math::Color &dustcolor) { float alpha = 0.0f; float traillength = 0.0f; @@ -90,7 +89,7 @@ void Dust::draw(math::Color const &dustcolor) return; } - + const float dust_distance = camera.distance() * camera.multiplier(); if (!dust) { con_debug << " generating dust..." << std::endl; @@ -98,9 +97,9 @@ void Dust::draw(math::Color const &dustcolor) dust = (float *) malloc(sizeof(float) * dustsize * 3); for (size_t i = 0; i < dustsize; i++) { - dust[i*3] = core::localcontrol()->location().x() + (math::randomf(2) - 1) * (DUSTDISTANCE + core::localcontrol()->radius() * 2.0f); - dust[i*3+1] = core::localcontrol()->location().y() + (math::randomf(2) - 1) * (DUSTDISTANCE + core::localcontrol()->radius() * 2.0f); - dust[i*3+2] = core::localcontrol()->location().z() + (math::randomf(2) - 1) * (DUSTDISTANCE + core::localcontrol()->radius() * 2.0f); + dust[i*3] = core::localcontrol()->location().x() + (math::randomf(2) - 1) * (dust_distance + core::localcontrol()->radius() * 2.0f); + dust[i*3+1] = core::localcontrol()->location().y() + (math::randomf(2) - 1) * (dust_distance + core::localcontrol()->radius() * 2.0f); + dust[i*3+2] = core::localcontrol()->location().z() + (math::randomf(2) - 1) * (dust_distance + core::localcontrol()->radius() * 2.0f); } } @@ -123,9 +122,9 @@ void Dust::draw(math::Color const &dustcolor) v[j] = dust[i*3+j] - core::localcontrol()->axis().forward()[j] * traillength; } - if (dsquare > (2.0f * core::localcontrol()->radius() + DUSTDISTANCE)*(2.0f * core::localcontrol()->radius() + DUSTDISTANCE)) { + if (dsquare > (2.0f * core::localcontrol()->radius() + dust_distance)*(2.0f * core::localcontrol()->radius() + dust_distance)) { for (size_t j = 0; j < 3; j++) { - dust[i*3+j] = core::localcontrol()->location()[j] + (math::randomf(2) - 1) * (DUSTDISTANCE + core::localcontrol()->radius() * 2.0f); + dust[i*3+j] = core::localcontrol()->location()[j] + (math::randomf(2) - 1) * (dust_distance + core::localcontrol()->radius() * 2.0f); v[j] = dust[i*3+j] - core::localcontrol()->axis().forward()[j] * traillength; } } |