diff options
Diffstat (limited to 'src/render')
-rw-r--r-- | src/render/draw.cc | 15 | ||||
-rw-r--r-- | src/render/renderext.cc | 55 | ||||
-rw-r--r-- | src/render/renderext.h | 8 |
3 files changed, 50 insertions, 28 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc index 0b6fba2..e9e655c 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -97,7 +97,7 @@ void pass_prepare(float seconds) core::EntityGlobe *globe = static_cast<core::EntityGlobe *>(entity); // add the globe to the globes list - if (globe->visible()) { + if (globe->visible() && !ext_render(globe)->behind()) { globes_list[ext_render(globe)->distance()] = globe; } @@ -495,7 +495,7 @@ void draw_pass_default() for (core::Zone::Content::iterator it = zone->content().begin(); it != zone->content().end(); ++it) { core::Entity *entity = (*it); - if (!entity->serverside() && !entity->model() && (entity->type() != core::Entity::Globe)) { + if (!entity->model() && (entity->type() != core::Entity::Globe) && !entity->serverside() && !ext_render(entity)->behind()) { gl::push(); gl::translate(entity->location()); @@ -854,7 +854,7 @@ void draw_pass_model_fragments() for (core::Zone::Content::iterator it = zone->content().begin(); it != zone->content().end(); it++) { core::Entity *entity = (*it); - if (entity->model() && ext_render(entity)->visible()) { + if (entity->model() && ext_render(entity)->visible() && !ext_render(entity)->behind()) { gl::push(); gl::translate(entity->location()); gl::multmatrix(entity->axis()); @@ -1209,7 +1209,6 @@ void draw(float seconds) gl::enable(GL_CULL_FACE); // enable culling gl::enable(GL_COLOR_MATERIAL); // enable color tracking - gl::enable(GL_LIGHTING); // enable lighting if (r_normalize && r_normalize->value()) { // enable full normalization gl::enable(GL_NORMALIZE); @@ -1217,6 +1216,8 @@ void draw(float seconds) // enable rescaling of normals gl::enable(GL_RESCALE_NORMAL); } + + gl::enable(GL_LIGHTING); // enable lighting draw_pass_globes(); // draw globes @@ -1224,6 +1225,8 @@ void draw(float seconds) draw_pass_model_fragments(); + gl::disable(GL_LIGHTING); // disable lighting + if (r_normalize && r_normalize->value()) { // disable full normalization gl::disable(GL_NORMALIZE); @@ -1231,7 +1234,6 @@ void draw(float seconds) // disable resaling of normals gl::disable(GL_RESCALE_NORMAL); } - gl::disable(GL_LIGHTING); // disable lighting gl::enable(GL_BLEND); gl::depthmask(GL_FALSE); // disable depth buffer writing @@ -1284,6 +1286,7 @@ void draw(float seconds) // GL_BLEND must be enabled for the GUI } +// draw HUD target world space geometry, like dock indicators void draw_target(core::Entity *entity) { model::Model *model = entity->model(); @@ -1294,7 +1297,7 @@ void draw_target(core::Entity *entity) return; float d = math::distance(core::localcontrol()->location(), entity->location()) - entity->radius() - core::localcontrol()->radius(); - if (d > 100.0f) + if (d > core::range::fxdistance) return; gl::enable(GL_DEPTH_TEST); diff --git a/src/render/renderext.cc b/src/render/renderext.cc index b0462d4..b743686 100644 --- a/src/render/renderext.cc +++ b/src/render/renderext.cc @@ -41,7 +41,7 @@ RenderExt::RenderExt(core::Entity *entity) : core::Extension(core::Extension::Re // load light texture std::stringstream flarename; flarename << "textures/fx/flare" << std::setfill('0') << std::setw(2) << light->flare(); - light->render_texture = Textures::load(flarename.str()); + light->set_texture(Textures::load(flarename.str())); } for (model::Model::Flares::iterator flit = model->flares().begin(); flit != model->flares().end(); flit++) { @@ -50,7 +50,7 @@ RenderExt::RenderExt(core::Entity *entity) : core::Extension(core::Extension::Re // load flare texture std::stringstream flarename; flarename << "textures/fx/flare" << std::setfill('0') << std::setw(2) << flare->flare(); - flare->render_texture = Textures::load(flarename.str()); + flare->set_texture(Textures::load(flarename.str())); } for(model::Model::ParticleSystems::iterator pit = model->particles().begin(); pit != model->particles().end(); pit++) { @@ -103,6 +103,10 @@ void RenderExt::frame(float elapsed) state_visible = entity()->visible(); state_detailvisible = false; + state_behind = false; + + if (!state_visible) + return; if ((entity()->type() == core::Entity::Controlable)) { if (static_cast<core::EntityDynamic *>(entity())->state() == core::Entity::Docked) { @@ -111,37 +115,44 @@ void RenderExt::frame(float elapsed) } } - if (state_visible && entity()->model()) { + if (!entity()->model()) + return; - if (distance() < core::range::fxdistance) { - // entity within detail range - state_visible = true; - state_detailvisible = true; + if (distance() < core::range::fxdistance) { + // entity within detail range + state_visible = true; + state_detailvisible = true; + + } else if (distance() < core::range::maxdistance) { + + // funky radius factor + float r = entity()->model()->radius(); + math::clamp(r, entity()->model()->radius(), core::range::maxdistance / core::range::fxdistance); - } else if (distance() < core::range::maxvisible) { + if (distance() < core::range::fxdistance * r) { // entity within drawing distance, outside detail range state_visible = true; state_detailvisible = false; - } else if (distance() < core::range::maxdistance) { - - if ((entity()->type() == core::Entity::Controlable)) { - // controlable entity out of range - state_visible = false; - state_detailvisible = false; - } else { - // entity within drawing distance, outside detail range - state_visible = true; - state_detailvisible = false; - - } } else { - // entity out of range - state_visible = false; + // entity within drawing distance, outside detail range + state_visible = true; state_detailvisible = false; } + + } else { + // entity out of range + state_visible = false; + state_detailvisible = false; + return; } + if (math::dotproduct(Camera::axis().forward(), entity()->location() + Camera::axis().forward() * entity()->radius() - Camera::eye()) < 0.0f) { + state_behind = true; + } + + + } } // namespace render diff --git a/src/render/renderext.h b/src/render/renderext.h index 28a2c23..3834769 100644 --- a/src/render/renderext.h +++ b/src/render/renderext.h @@ -26,8 +26,14 @@ public: virtual void frame(float elapsed); inline bool visible() const { return state_visible; } + inline bool detailvisible() const { return state_detailvisible; } + /** + * true if the entity is behind the camera + */ + inline bool behind() const { return state_behind; } + inline float fuzz() const { return state_fuzz; } /// distance to the camera @@ -35,9 +41,11 @@ public: /// particles inline ParticleSystems &particles() { return state_particles; } + private: bool state_visible; bool state_detailvisible; + bool state_behind; float state_fuzz; float state_distance; |