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-05-01 16:02:51 +0000
committerStijn Buys <ingar@osirion.org>2008-05-01 16:02:51 +0000
commit4e5343ce9aa83a5c0b04bf744dd287fb56ff39fc (patch)
tree2f5944d3426529a973e78137f8ce5a9a29a7c54f /src/render
parentf5266b403c50cb2b6d712e6d8f41b62ad2433efb (diff)
various silly fixes
Diffstat (limited to 'src/render')
-rw-r--r--src/render/draw.cc92
1 files changed, 37 insertions, 55 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc
index 5697cae..d125420 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -45,14 +45,12 @@ float angle = 0;
inline bool test_draw_distance(core::Entity *entity)
{
- return (entity->model() &&
- (math::distancesquared(camera_eye, entity->location()) <= (drawdistance*drawdistance*entity->model()->radius())));
+ return (entity->entity_renderstate > 0);
}
inline bool test_drawfx_distance(core::Entity *entity)
{
- return (entity->model() &&
- (math::distancesquared(camera_eye, entity->location()) <= (drawfxdistance*drawfxdistance*entity->model()->radius())));
+ return ((entity->entity_renderstate & core::Entity::InCloseRange) == core::Entity::InCloseRange);
}
@@ -247,6 +245,37 @@ void draw_model_shield(core::EntityControlable *entity)
/* ----- Render passes --------------------------------------------- */
+/* calculate entity visibility */
+void pass_visibility()
+{
+ std::map<unsigned int, core::Entity *>::iterator it;
+ for (it=core::Entity::registry.begin(); it != core::Entity::registry.end(); it++) {
+
+ core::Entity *entity = (*it).second;
+ entity->entity_renderstate = 0;
+
+ // load entity models if necessary
+ if (!entity->model() && entity->modelname().size()) {
+ entity->entity_model = core::Model::get(entity->modelname());
+
+ if (!entity->model())
+ entity->entity_modelname.clear();
+ }
+
+ if (entity->model()) {
+ float dq = math::distancesquared(camera_eye, entity->location());
+
+ if (dq <= drawfxdistance*drawfxdistance*entity->model()->radius()) {
+ // entites withint drawfxdistance
+ entity->entity_renderstate = core::Entity::InCloseRange;
+ } else if (dq <= drawdistance*drawdistance*entity->model()->radius()) {
+ // entities within drawdistance
+ entity->entity_renderstate = core::Entity::InRange;
+ }
+ }
+ }
+}
+
/* Draw entities without model */
void draw_pass_default()
{
@@ -298,21 +327,9 @@ void draw_pass_model_vertex()
for (it=core::Entity::registry.begin(); it != core::Entity::registry.end(); it++) {
core::Entity *entity = (*it).second;
-
- // load entity models if necessary
- if (!entity->model() && entity->modelname().size()) {
- entity->entity_model = core::Model::get(entity->modelname());
-
- if (!entity->model())
- entity->entity_modelname.clear();
- }
-
-
if (test_draw_distance(entity)) {
gl::push();
gl::translate(entity->location());
- // FIXME
- //gl::rotate(entity->direction(), 0.0f, 0.0f, 1.0f );
gl::multmatrix(entity->axis());
draw_model_vertex(entity);
@@ -333,8 +350,6 @@ void draw_pass_model_evertex()
if (test_draw_distance(entity)) {
gl::push();
gl::translate(entity->location());
- // FIXME
- //gl::rotate(entity->direction(), 0.0f, 0.0f, 1.0f );
gl::multmatrix(entity->axis());
draw_model_evertex(entity);
@@ -369,7 +384,6 @@ void draw_pass_model_fx() {
}
/* draw model lights */
-
void draw_pass_model_lights()
{
//glPointSize(10);
@@ -403,6 +417,8 @@ void draw_pass_model_lights()
gl::vertex(location + (camera_axis.up() * -1 + camera_axis.left()) * light_size);
glTexCoord2f(-1,1);
gl::vertex(location + (camera_axis.up() * -1 - camera_axis.left()) * light_size);
+
+ Stats::quads++;
}
}
}
@@ -472,42 +488,6 @@ void draw_pass_spacegrid()
gl::pop();
}
-void draw_local_axis()
-{
- if (!core::localcontrol())
- return;
-
- gl::push();
- gl::translate(core::localcontrol()->location());
-
- gl::begin(gl::Lines);
- gl::color(0.5f, 0.0f,0.0f);
- gl::vertex(core::localcontrol()->axis()[0] * -1.0f);
- gl::color(1.0f, 0.0f, 0.0f);
- gl::vertex(core::localcontrol()->axis()[0]);
-
- gl::color(0.5f, 0.5f,0.0f);
- gl::vertex(core::localcontrol()->axis()[1] * -1.0f);
- gl::color(1.0f, 1.0f, 0.0f);
- gl::vertex(0.0f, 0.0f, 0.0f);
-
- gl::color(0.5f, 0.5f,0.0f);
- gl::vertex(core::localcontrol()->axis()[1]);
- gl::color(1.0f, 1.0f, 0.0f);
- gl::vertex(0.0f, 0.0f, 0.0f);
-
- gl::color(0.0f, 0.5f,0.0f);
- gl::vertex(core::localcontrol()->axis()[2] * -1.0f);
- gl::color(0.0f, 1.0f, 0.0f);
- gl::vertex(0.0f, 0.0f, 0.0f);
-
- gl::color(0.0f, 0.5f,0.0f);
- gl::vertex(core::localcontrol()->axis()[2]);
- gl::color(0.0f, 1.0f, 0.0f);
- gl::vertex(0.0f, 0.0f, 0.0f);
-
- gl::pop();
-}
/* ----- Main draw routine ----------------------------------------- */
void draw(math::Axis const &axis, math::Vector3f const &eye, math::Vector3f const &target, float seconds)
@@ -523,6 +503,8 @@ void draw(math::Axis const &axis, math::Vector3f const &eye, math::Vector3f cons
camera_target.assign(target);
camera_eye.assign(eye);
camera_axis.assign(axis);
+
+ pass_visibility();
gl::enable(GL_DEPTH_TEST); // enable depth buffer writing
gl::enable(GL_CULL_FACE); // enable culling