From 847f84e1e3797277407bc34f5acc51b801b2bf29 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Thu, 18 Nov 2010 13:50:47 +0000 Subject: Unified radiant angles conversion into a single math::Axis.assign() method, corrected transformation order. Removed unnecessary model::LIGHTSCALE constant, light and flare sizes are rescaled according to the global model::SCALE. Added gl::depthfunc, enabled GL_LEQUAL while drawing lights and flares. --- src/render/draw.cc | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'src/render/draw.cc') diff --git a/src/render/draw.cc b/src/render/draw.cc index cb8649f..9ebe2cc 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -875,6 +875,12 @@ void draw_pass_model_fx(float elapsed) math::Vector3f offset; math::Color color; math::Axis flare_axis; + + // FIXME + // setting the depth buffer comparison function to less-or-equal + // this should prevent z-fighting with model geometry, + // but doesn't seem to perform as generally expected + gl::depthfunc(GL_LEQUAL); for (core::Zone::Content::iterator it = zone->content().begin(); it != zone->content().end(); it++) { core::Entity *entity = (*it); @@ -947,7 +953,8 @@ void draw_pass_model_fx(float elapsed) color.a = a; location.assign(entity->location() + (entity->axis() * light->location()) * modelscale); - light_size = 0.0625f * light->radius() * modelscale; + + light_size = light->radius() * modelscale; // track OpenGL state changes if (current_texture != light->texture()) { @@ -1020,7 +1027,8 @@ void draw_pass_model_fx(float elapsed) color.a = a; location.assign(entity->location() + (entity->axis() * flare->location()) * modelscale ); - light_size = 0.0625f * flare->radius() * modelscale; + + light_size = flare->radius() * modelscale; // track OpenGL state changes if ((current_cull != flare->cull()) || (current_texture != flare->texture())) { @@ -1102,6 +1110,9 @@ void draw_pass_model_fx(float elapsed) } } + // restore the default depth buffer comparison function + gl::depthfunc(GL_LESS); + gl::disable(GL_TEXTURE_2D); gl::cullface(GL_BACK); gl::enable(GL_CULL_FACE); @@ -1173,7 +1184,7 @@ void draw(float seconds) // calculate client state pass_prepare(seconds); - gl::disable(GL_DEPTH_TEST); + gl::disable(GL_DEPTH_TEST); // disable depth testing gl::depthmask(GL_FALSE); // disable depth buffer writing glPolygonMode(GL_FRONT, GL_FILL); @@ -1181,7 +1192,8 @@ void draw(float seconds) draw_pass_sky(); // draw the skybox gl::depthmask(GL_TRUE); // enable writing to the depth buffer - gl::enable(GL_DEPTH_TEST); + gl::depthfunc(GL_LESS); // default depth buffer comparison function + gl::enable(GL_DEPTH_TEST); // enable depth testing gl::enable(GL_CULL_FACE); // enable culling gl::enable(GL_COLOR_MATERIAL); // enable color tracking @@ -1254,8 +1266,11 @@ void draw(float seconds) } // draw entity lights, flares and particles - if (draw_lights || draw_particles) + if (draw_lights || draw_particles) { + draw_pass_model_fx(seconds); + + } // draw entity radius globe if (r_radius && r_radius->value()) { -- cgit v1.2.3