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 /src/render/dust.cc
parent5bffd2fc4ee4ba30a28351d4bf4986d520a27efa (diff)
faster dust calculations
Diffstat (limited to 'src/render/dust.cc')
-rw-r--r--src/render/dust.cc32
1 files changed, 16 insertions, 16 deletions
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);
}