Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-07-31 20:05:06 +0000
committerStijn Buys <ingar@osirion.org>2008-07-31 20:05:06 +0000
commit160ba62230a88f589e91322655e1d85d53589289 (patch)
tree0aa299408c4a23c7870b4a5d5d503fc9cc90f3cd
parent5bffd2fc4ee4ba30a28351d4bf4986d520a27efa (diff)
faster dust calculations
-rw-r--r--doc/TODO3
-rw-r--r--src/client/client.cc3
-rw-r--r--src/render/dust.cc32
3 files changed, 19 insertions, 19 deletions
diff --git a/doc/TODO b/doc/TODO
index 4c7d314..8f2c5bf 100644
--- a/doc/TODO
+++ b/doc/TODO
@@ -5,6 +5,8 @@ milestone 1:
fix cl_prediction (or not)
fix autolevel
+ add impulse drive
+
milestone 2:
zones
targetting system
@@ -106,6 +108,7 @@ game:
docking
jumpgates (required docking)
fix autolevel
+ impulse drive
win32 port:
network not functional (ok)
diff --git a/src/client/client.cc b/src/client/client.cc
index ede6b29..f5da1f0 100644
--- a/src/client/client.cc
+++ b/src/client/client.cc
@@ -92,8 +92,6 @@ void Client::init(int count, char **arguments)
cl_framerate = core::Cvar::get("cl_framerate", "125", core::Cvar::Archive);
cl_framerate->set_info("[int] client framerate in frames/sec");
- cl_frametime = core::Cvar::set("cl_frametime", "8", core::Cvar::ReadOnly);
- cl_frametime->set_info("[int] current minimal length of one frame, in milliseconds (read-only)");
// initialize SDL, but do not initialize any subsystems
SDL_Init(0);
@@ -146,7 +144,6 @@ void Client::run()
} else {
client_frame_lenght = 0;
}
- (*cl_frametime) = (float) client_frame_lenght;
// only advance per microsecond frame
Uint32 d = client_current_timestamp - client_previous_timestamp;
diff --git a/src/render/dust.cc b/src/render/dust.cc
index 64969e3..b1d4077 100644
--- a/src/render/dust.cc
+++ b/src/render/dust.cc
@@ -65,6 +65,7 @@ void Dust::draw()
free(dust);
dust = 0;
}
+ dustsize = 0;
return;
}
@@ -75,14 +76,13 @@ void Dust::draw()
dust = 0;
}
}
-
- dustsize = (size_t) r_dustsize->value();
-
- if (!dustsize) {
+
+ if (dustsize <= 0) {
if (dust) {
free(dust);
dust = 0;
}
+ dustsize = 0;
return;
}
@@ -95,6 +95,7 @@ void Dust::draw()
if (!dust) {
con_debug << " generating dust..." << std::endl;
+
dust = (float *) malloc(sizeof(float) * dustsize* 3);
for (size_t i = 0; i < dustsize; i++) {
@@ -120,21 +121,20 @@ void Dust::draw()
math::Vector3f v;
for (size_t i = 0; i < dustsize; i++) {
- v.assign(core::localcontrol()->location());
- for (size_t j = 0; j < 3; j++)
- v[j] -= dust[i*3+j];
-
- if (v.lengthsquared() > (core::localcontrol()->radius() + DUSTDISTANCE)*(core::localcontrol()->radius() + DUSTDISTANCE)) {
-
- 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());
+ float dsquare = 0;
+ for (size_t j = 0; j < 3; j++) {
+ dsquare += (core::localcontrol()->location()[j] - dust[i*3+j]) * (core::localcontrol()->location()[j] - dust[i*3+j]);
+ v[j] = dust[i*3+j] - Camera::eye()[j];
}
- for (size_t j = 0; j < 3; j++)
- v[j] = dust[i*3+j];
- v -= Camera::eye();
+ if (dsquare > (core::localcontrol()->radius() + DUSTDISTANCE)*(core::localcontrol()->radius() + DUSTDISTANCE)) {
+ for (size_t j = 0; j < 3; j++) {
+ dust[i*3+j] = core::localcontrol()->location()[j] + (math::randomf(2) - 1) * (DUSTDISTANCE + core::localcontrol()->radius());
+ v[j] = dust[i*3+j] - Camera::eye()[j];
+ }
+ }
gl::vertex(v);
+
v -= core::localcontrol()->state()->axis().forward() * traillength;
gl::vertex(v);
}