From d389a31f9816b55d8c7685ec24b9ab814252d693 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Mon, 28 Jul 2008 19:37:31 +0000 Subject: zone support --- src/render/draw.cc | 46 ++++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-) (limited to 'src/render/draw.cc') diff --git a/src/render/draw.cc b/src/render/draw.cc index 2e72529..b26b8ce 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -41,6 +41,7 @@ math::Vector3f v7(-1, -1, -1); const float drawdistance = 128.0f; const float drawfxdistance = 64.0f; +core::Zone *zone = 0; float angle = 0; @@ -367,10 +368,8 @@ void pass_prepare(float seconds) glGetDoublev(GL_MODELVIEW, gl_model_matrix); glGetIntegerv(GL_VIEWPORT, gl_viewport); - std::map::iterator it; - for (it=core::Entity::registry.begin(); it != core::Entity::registry.end(); it++) { - - core::Entity *entity = (*it).second; + for (core::Zone::Content::iterator it = zone->content().begin(); it != zone->content().end(); it++) { + core::Entity *entity = (*it); // load entity models and light flare textures if (!entity->model() && entity->modelname().size()) { @@ -503,9 +502,8 @@ void pass_prepare(float seconds) /* Draw entities without model */ void draw_pass_default() { - std::map::iterator it; - for (it=core::Entity::registry.begin(); it != core::Entity::registry.end(); it++) { - core::Entity *entity = (*it).second; + for (core::Zone::Content::iterator it = zone->content().begin(); it != zone->content().end(); it++) { + core::Entity *entity = (*it); // draw entities without model if (!entity->model()) { @@ -590,10 +588,9 @@ void draw_pass_default() /* draw model geometry fragments */ void draw_pass_model_fragments() { - std::map::iterator it; - for (it=core::Entity::registry.begin(); it != core::Entity::registry.end(); it++) { + for (core::Zone::Content::iterator it = zone->content().begin(); it != zone->content().end(); it++) { + core::Entity *entity = (*it); - core::Entity *entity = (*it).second; if (entity->model() && entity->state()->visible()) { gl::push(); gl::translate(entity->state()->location()); @@ -619,8 +616,8 @@ void draw_pass_model_fx(float elapsed) gl::begin(gl::Quads); - for (std::map::iterator it=core::Entity::registry.begin(); it != core::Entity::registry.end(); it++) { - core::Entity *entity = (*it).second; + for (core::Zone::Content::iterator it = zone->content().begin(); it != zone->content().end(); it++) { + core::Entity *entity = (*it); if (entity->model() && entity->state()->detailvisible()) { @@ -822,10 +819,10 @@ void draw_pass_model_corona() if (!(r_radius && r_radius->value())) return; - for (std::map::iterator it=core::Entity::registry.begin(); it != core::Entity::registry.end(); it++) { - core::Entity *entity = (*it).second; + for (core::Zone::Content::iterator it = zone->content().begin(); it != zone->content().end(); it++) { + core::Entity *entity = (*it); - if (entity->model() && entity->state() && entity->state()->visible()) { + if (entity->model() && entity->state()->visible()) { gl::push(); gl::translate(entity->state()->location()); math::Color color = entity->color(); @@ -844,9 +841,20 @@ void draw_pass_sky() if (!(r_sky && r_sky->value())) return; - size_t sky_texture = Textures::load("textures/env/sky"); - Textures::bind(sky_texture); + if (!core::localplayer()->zone()) + return; + + if (!core::localplayer()->zone()->sky_texture() && core::localplayer()->zone()->sky().size()) { + std::string texture_name("textures/env/"); + texture_name.append(core::localplayer()->zone()->sky()); + core::localplayer()->zone()->set_sky_texture(Textures::load(texture_name)); + + if (!core::localplayer()->zone()->sky_texture()) + core::localplayer()->zone()->set_sky(""); + } + + Textures::bind(core::localplayer()->zone()->sky_texture()); gl::enable(GL_TEXTURE_2D); gl::push(); @@ -901,7 +909,9 @@ void draw_pass_spacegrid() void draw(float seconds) { - Stats::clear(); + zone = core::localplayer()->zone(); + if (!zone) + return; // used for animations angle += 180.0f * seconds; -- cgit v1.2.3