diff options
author | Stijn Buys <ingar@osirion.org> | 2015-02-09 21:43:13 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2015-02-09 21:43:13 +0000 |
commit | 20573c3db1c9ac63500c275b586c32871203ccce (patch) | |
tree | 5ba0b9a846a13d903830e9334bd148a6e83f61a4 | |
parent | 81c5e14a2988a1bca544978f55f519b17ce0635e (diff) |
Don't render slot indicators when the entity is outside fx range,
small optimization when drawing model lights.
-rw-r--r-- | src/render/draw.cc | 51 |
1 files changed, 32 insertions, 19 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc index e099536..c9ccafe 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -852,7 +852,8 @@ void draw_pass_model_fragments() { core::Entity *entity = (*it); - if (entity->model() && ext_render(entity)->visible()) { + if (entity->model() && ext_render(entity)->visible()) + { gl::push(); gl::translate(entity->location()); gl::multmatrix(entity->axis()); @@ -870,7 +871,8 @@ void draw_pass_model_fragments() ext_render(entity)->thrust() ); - if (r_bbox->value()) { + if (r_bbox->value()) + { gl::disable(GL_DEPTH_TEST); gl::color(entity->color().r * 0.5f, entity->color().g * 0.5f, entity->color().b * 0.5f, 0.25f); draw_box(entity->model()->box().min(), entity->model()->box().max()); @@ -880,23 +882,30 @@ void draw_pass_model_fragments() draw_box(entity->model()->box().min(), entity->model()->box().max()); } - if (r_axis->value()) { + if (r_axis->value()) + { draw_model_axis(entity); } - if ((ext_render(entity)->detailvisible()) && (entity->type() == core::Entity::Controlable) && (r_indicators->value())) { - draw_inidicators(static_cast<const core::EntityControlable *>(entity)); - } - - if (entity->slots() && r_slots && r_slots->value()) { - gl::pop(); + if (ext_render(entity)->detailvisible()) + { - gl::push(); - gl::translate(entity->location()); - gl::multmatrix(entity->axis()); - - // not scaled through modelscale - draw_slots(entity); + if ((entity->type() == core::Entity::Controlable) && (r_indicators->value())) + { + draw_inidicators(static_cast<const core::EntityControlable *>(entity)); + } + + if (entity->slots() && r_slots && r_slots->value()) + { + gl::pop(); + + gl::push(); + gl::translate(entity->location()); + gl::multmatrix(entity->axis()); + + // not scaled through modelscale + draw_slots(entity); + } } gl::pop(); } @@ -917,6 +926,8 @@ void draw_model_lights(model::Model *model, const float scale, math::Vector3f offset; math::Color color; math::Axis flare_axis; + + int nbquads = 0; // disable culling by default gl::disable(GL_CULL_FACE); @@ -927,7 +938,7 @@ void draw_model_lights(model::Model *model, const float scale, gl::begin(gl::Quads); // draw model lights - for (model::Model::Lights::iterator lit = model->lights().begin(); lit != model->lights().end(); lit++) { + for (model::Model::Lights::iterator lit = model->lights().begin(); lit != model->lights().end(); ++lit) { model::Light *light = (*lit); // engine activated lights @@ -1005,12 +1016,12 @@ void draw_model_lights(model::Model *model, const float scale, gl::vertex(location + (Camera::axis().up() * -1 + Camera::axis().left()) * light_size); gl::texcoord(1, 1); gl::vertex(location + (Camera::axis().up() * -1 - Camera::axis().left()) * light_size); - Stats::quads++; + nbquads++; } // draw flares - for (model::Model::Flares::iterator flit = model->flares().begin(); flit != model->flares().end(); flit++) { + for (model::Model::Flares::iterator flit = model->flares().begin(); flit != model->flares().end(); ++flit) { model::Flare *flare = (*flit); // engine activated flares @@ -1118,13 +1129,15 @@ void draw_model_lights(model::Model *model, const float scale, gl::texcoord(1, 1); gl::vertex(location + (flare_axis.up() * -1 + flare_axis.left()) * light_size); - Stats::quads++; + nbquads++; } gl::end(); gl::cullface(GL_BACK); gl::enable(GL_CULL_FACE); + + Stats::quads += nbquads; } void draw_pass_model_fx(float elapsed) |