diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/math/axis.cc | 11 | ||||
-rw-r--r-- | src/math/axis.h | 7 | ||||
-rw-r--r-- | src/model/mapfile.cc | 17 | ||||
-rw-r--r-- | src/model/model.h | 3 | ||||
-rw-r--r-- | src/render/draw.cc | 25 | ||||
-rw-r--r-- | src/render/gl.cc | 16 | ||||
-rw-r--r-- | src/render/gl.h | 3 | ||||
-rw-r--r-- | src/render/particles.cc | 5 |
8 files changed, 60 insertions, 27 deletions
diff --git a/src/math/axis.cc b/src/math/axis.cc index 3710c89..60d3797 100644 --- a/src/math/axis.cc +++ b/src/math/axis.cc @@ -44,6 +44,17 @@ void Axis::assign(const btMatrix3x3 & other) } } +void Axis::assign(const float yaw, const float pitch, const float roll) +{ + clear(); + if (yaw) + change_direction(yaw); + if (pitch) + change_pitch(-pitch); + if (roll) + change_roll(-roll); +} + Axis & Axis::operator=(const Axis & other) { assign(other); diff --git a/src/math/axis.h b/src/math/axis.h index f9da159..3991843 100644 --- a/src/math/axis.h +++ b/src/math/axis.h @@ -26,6 +26,13 @@ public: void assign(const Axis & other); void assign(const btMatrix3x3 & other); + + /** + * @brief assign radiant yaw, pitch and roll angles. + * This method changes the sign of the pitch and roll angles + * before applying them + */ + void assign(const float yaw, const float pitch, const float roll); /// global coordinates of the X-axis in the local coordinates system inline const Vector3f & forward() const { diff --git a/src/model/mapfile.cc b/src/model/mapfile.cc index 560bbc1..b74cdbe 100644 --- a/src/model/mapfile.cc +++ b/src/model/mapfile.cc @@ -808,10 +808,7 @@ bool MapFile::got_key_axis(math::Axis &axis) std::istringstream str(value()); if (str >> pitch >> yaw >> roll) { - axis.clear(); - axis.change_pitch(-pitch); - axis.change_direction(yaw); - axis.change_roll(-roll); + axis.assign(yaw, pitch, roll); } else { unknown_value(); } @@ -820,7 +817,7 @@ bool MapFile::got_key_axis(math::Axis &axis) } else if (got_key_float("pitch", pitch)) { // TODO this warning should eventually disappear - unknown_error("'" + classname() + ":" + key() + "' has changed polarity"); + unknown_error("'" + classname() + ":" + key() + "' has switched sign"); axis.change_pitch(-pitch); return true; @@ -832,7 +829,7 @@ bool MapFile::got_key_axis(math::Axis &axis) } else if (got_key_float("roll", roll)) { // TODO this warning should eventually disappear - unknown_error("'" + classname() + ":" + key() + "' has changed polarity"); + unknown_error("'" + classname() + ":" + key() + "' has switched sign"); axis.change_roll(-roll); return true; @@ -1131,11 +1128,11 @@ Model * MapFile::load(std::string const &name) continue; } else if (mapfile.got_key_float("light", r)) { - tag_light->set_radius(r * LIGHTSCALE); + tag_light->set_radius(r * SCALE); continue; } else if (mapfile.got_key_float("radius", r)) { - tag_light->set_radius(r * LIGHTSCALE); + tag_light->set_radius(r * SCALE); continue; } else if (mapfile.got_key_float("frequency", r)) { @@ -1186,11 +1183,11 @@ Model * MapFile::load(std::string const &name) tag_flare->set_engine(spawnflag_isset(u, 4)); } else if (mapfile.got_key_float("light", r)) { - tag_flare->set_radius(r * LIGHTSCALE); + tag_flare->set_radius(r * SCALE); continue; } else if (mapfile.got_key_float("radius", r)) { - tag_flare->set_radius(r * LIGHTSCALE); + tag_flare->set_radius(r * SCALE); continue; } else if (mapfile.got_key_float("frequency", r)) { diff --git a/src/model/model.h b/src/model/model.h index 9495285..d3973c9 100644 --- a/src/model/model.h +++ b/src/model/model.h @@ -20,9 +20,8 @@ namespace model { -/// scaling factor when loading .map geometry +/// scaling factor when loading model geometry const float SCALE = 1.0f / 1024.0f; -const float LIGHTSCALE = 1.0f / 100.0f; const float ANGLEUP = -1.0f; const float ANGLEDOWN = -2.0f; 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()) { diff --git a/src/render/gl.cc b/src/render/gl.cc index 801c320..fa7c092 100644 --- a/src/render/gl.cc +++ b/src/render/gl.cc @@ -59,35 +59,39 @@ void depthmask(GLenum mode) ::glDepthMask(mode); } +void depthfunc(GLenum func) +{ + ::glDepthFunc(func); +} void frontface(GLenum mode) { - glFrontFace(mode); + ::glFrontFace(mode); } void cullface(GLenum mode) { - glCullFace(mode); + ::glCullFace(mode); } void shademodel(GLenum mode) { - glShadeModel(mode); + ::glShadeModel(mode); } void blendfunc(GLenum sfactor, GLenum dfactor) { - glBlendFunc(sfactor, dfactor); + ::glBlendFunc(sfactor, dfactor); } void enable(GLenum cap) { - glEnable(cap); + ::glEnable(cap); } void disable(GLenum cap) { - glDisable(cap); + ::glDisable(cap); } void clear(GLbitfield mask) diff --git a/src/render/gl.h b/src/render/gl.h index e6d6f92..fc2237e 100644 --- a/src/render/gl.h +++ b/src/render/gl.h @@ -109,6 +109,9 @@ void frontface(GLenum mode); /// glDepthMask void depthmask(GLenum mode); +/// glDepthFunc +void depthfunc(GLenum func); + /// glBlendFunc void blendfunc(GLenum sfactor, GLenum dfactor); diff --git a/src/render/particles.cc b/src/render/particles.cc index 86847c3..7a0094d 100644 --- a/src/render/particles.cc +++ b/src/render/particles.cc @@ -188,10 +188,7 @@ ParticleScript *ParticleScript::load(const std::string &label) std::istringstream str(inifile.value()); if (str >> pitch >> yaw >> roll) { - script->particlescript_axis.clear(); - script->particlescript_axis.change_pitch(-pitch); - script->particlescript_axis.change_direction(yaw); - script->particlescript_axis.change_roll(-roll); + script->particlescript_axis.assign(yaw, pitch, roll); } else { inifile.unknown_value(); } |