From 421fc71813f08bfe359f9ac7596933a7e4cea6e0 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Wed, 7 May 2008 18:56:00 +0000 Subject: client-side frame interpolation: network updates, interpolation of position --- src/render/draw.cc | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'src/render/draw.cc') diff --git a/src/render/draw.cc b/src/render/draw.cc index b0671de..26655e0 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -238,12 +238,7 @@ void pass_prepare() for (it=core::Entity::registry.begin(); it != core::Entity::registry.end(); it++) { core::Entity *entity = (*it).second; - if (!entity->state()) { - entity->entity_clientstate = new core::ClientState(); - } - entity->state()->state_visible = false; - entity->state()->state_detailvisible = false; - + // load entity models and light flare textures if (!entity->model() && entity->modelname().size()) { entity->entity_model = model::Model::load(entity->modelname()); @@ -263,7 +258,14 @@ void pass_prepare() } // update client state - if (entity->state() && flag_is_set(entity->flags(), core::Entity::Static)) { + if (!entity->state()) { + entity->entity_clientstate = new core::ClientState(); + entity->state()->assign(entity); + } + entity->state()->state_visible = false; + entity->state()->state_detailvisible = false; + + if (!flag_is_set(entity->flags(), core::Entity::Static)) { entity->state()->state_location = entity->state()->previouslocation() + (entity->location() - entity->state()->previouslocation()) * core::game()->timeoffset(); } @@ -310,7 +312,7 @@ void draw_pass_default() // draw entities without model if (!entity->model()) { gl::push(); - gl::translate(entity->location()); + gl::translate(entity->state()->location()); gl::multmatrix(entity->axis()); if (flag_is_set(entity->flags(), core::Entity::Bright)) { @@ -353,7 +355,7 @@ void draw_pass_model_vertex() core::Entity *entity = (*it).second; if (entity->model() && entity->state()->visible()) { gl::push(); - gl::translate(entity->location()); + gl::translate(entity->state()->location()); gl::multmatrix(entity->axis()); draw_model_vertex(entity); @@ -373,7 +375,7 @@ void draw_pass_model_evertex() if (entity->model() && entity->state()->visible()) { gl::push(); - gl::translate(entity->location()); + gl::translate(entity->state()->location()); gl::multmatrix(entity->axis()); draw_model_evertex(entity); @@ -395,7 +397,7 @@ void draw_pass_model_shields() { if (entity->type() == core::Entity::Controlable) { gl::push(); - gl::translate(entity->location()); + gl::translate(entity->state()->location()); gl::multmatrix(entity->axis()); draw_model_shield((core::EntityControlable *)entity); @@ -432,7 +434,7 @@ void draw_pass_model_fx() t = (core::application()->time() + entity->state()->fuzz() + (*lit)->offset()) * (*lit)->frequency(); if (!(*lit)->strobe() || (( t - floorf(t)) <= (*lit)->time())) { - math::Vector3f location = entity->location() + (entity->axis() * (*lit)->location()); + math::Vector3f location = entity->state()->location() + (entity->axis() * (*lit)->location()); float light_size = 0.0625 * (*lit)->radius(); if ((*lit)->render_texture != flare_texture) { @@ -483,7 +485,7 @@ void draw_pass_model_fx() t = 0.75f + t/2; for(std::list::iterator eit = entity->model()->model_engine.begin(); eit != entity->model()->model_engine.end(); eit++) { - math::Vector3f location = entity->location() + (entity->axis() * (*eit)->location()); + math::Vector3f location = entity->state()->location() + (entity->axis() * (*eit)->location()); float engine_size = 0.0625 * (*eit)->radius() * t; math::Color color(1.0f, 0.0f, 0.0f, 0.9f * u); @@ -518,7 +520,7 @@ void draw_pass_model_corona() if (entity->state()->visible() && (entity->shape() != core::Entity::Sphere)) { gl::push(); - gl::translate(entity->location()); + gl::translate(entity->state()->location()); math::Color color = entity->color(); color.a = 0.25f; draw_sphere(color, entity->model()->radius()); -- cgit v1.2.3