Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/render')
-rw-r--r--src/render/draw.cc6
-rw-r--r--src/render/draw.h3
-rw-r--r--src/render/dust.cc36
-rw-r--r--src/render/dust.h2
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();
};
}