From 930db4020b9af2ccd999cb3a8c980cc9d527f8cf Mon Sep 17 00:00:00 2001
From: Stijn Buys <ingar@osirion.org>
Date: Sat, 10 May 2008 10:19:16 +0000
Subject: client-side axis interpolation

---
 src/render/draw.cc | 39 ++++++++++++++++++---------------------
 1 file changed, 18 insertions(+), 21 deletions(-)

(limited to 'src/render')

diff --git a/src/render/draw.cc b/src/render/draw.cc
index 26655e0..7a780bf 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -174,7 +174,7 @@ void draw_model_evertex(core::Entity *entity)
 		Stats::tris += count/3;
 	}
 }
-
+/*
 void draw_model_engines(core::EntityControlable *entity)
 {
 	model::Model *model = entity->model();
@@ -228,11 +228,12 @@ void draw_model_shield(core::EntityControlable *entity)
 
 	//gl::pop();
 }
+*/
 
 /* ----- Render passes --------------------------------------------- */
 
 /* calculate entity visibility */
-void pass_prepare()
+void pass_prepare(float seconds)
 {
 	std::map<unsigned int, core::Entity *>::iterator it;
 	for (it=core::Entity::registry.begin(); it != core::Entity::registry.end(); it++) {
@@ -257,21 +258,17 @@ void pass_prepare()
 			}
 		}
 
-		// update client state
 		if (!entity->state()) {
-			entity->entity_clientstate = new core::ClientState();
-			entity->state()->assign(entity);
+			entity->entity_clientstate = new core::ClientState(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();
-		}
+		entity->state()->state_visible = true;	
+		entity->state()->state_detailvisible = false;
 
 		// calculate visibility for entities with models
 		if (entity->model()) {
+
+			entity->state()->state_visible = false;
 			float dq = math::distancesquared(camera_eye, entity->location());
 	
 			if (dq <= drawfxdistance*drawfxdistance*entity->model()->radius())  {
@@ -285,9 +282,6 @@ void pass_prepare()
 			}
 
 		} else 	{
-
-			entity->state()->state_visible = true;
-
 			if ((entity->type() == core::Entity::Globe) && flag_is_set(entity->flags(), core::Entity::Bright)) {
 
 				// bright globes set level light
@@ -298,7 +292,8 @@ void pass_prepare()
 	
 				glLightfv(GL_LIGHT0, GL_POSITION, light_position);
 			}		
-		} 
+		}
+		
 	}
 }
 
@@ -313,7 +308,7 @@ void draw_pass_default()
 		if (!entity->model()) {
 			gl::push();
 			gl::translate(entity->state()->location());
-			gl::multmatrix(entity->axis());
+			gl::multmatrix(entity->state()->axis());
 
 			if (flag_is_set(entity->flags(), core::Entity::Bright)) {
 				gl::disable(GL_LIGHTING);
@@ -356,7 +351,7 @@ void draw_pass_model_vertex()
 		if (entity->model() && entity->state()->visible()) {
 			gl::push();
 			gl::translate(entity->state()->location());
-			gl::multmatrix(entity->axis());
+			gl::multmatrix(entity->state()->axis());
 
 			draw_model_vertex(entity);
 
@@ -376,7 +371,7 @@ void draw_pass_model_evertex()
 		if (entity->model() && entity->state()->visible()) {
 			gl::push();
 			gl::translate(entity->state()->location());
-			gl::multmatrix(entity->axis());
+			gl::multmatrix(entity->state()->axis());
 
 			draw_model_evertex(entity);	
 
@@ -386,6 +381,7 @@ void draw_pass_model_evertex()
 }
 
 /* Draw model shields */
+/*
 void draw_pass_model_shields() {
 	
 	for (std::map<unsigned int, core::Entity *>::iterator it=core::Entity::registry.begin(); it != core::Entity::registry.end(); it++) {
@@ -398,7 +394,7 @@ void draw_pass_model_shields() {
 			if (entity->type() == core::Entity::Controlable) {
 				gl::push();
 				gl::translate(entity->state()->location());
-				gl::multmatrix(entity->axis());
+				gl::multmatrix(entity->state()->axis());
 
 				draw_model_shield((core::EntityControlable *)entity);
 				gl::pop();
@@ -407,6 +403,7 @@ void draw_pass_model_shields() {
 		}
 	}
 }
+*/
 
 /* draw model lights and engines */
 void draw_pass_model_fx()
@@ -518,7 +515,7 @@ void draw_pass_model_corona()
 	for (std::map<unsigned int, core::Entity *>::iterator it=core::Entity::registry.begin(); it != core::Entity::registry.end(); it++) {
 		core::Entity *entity = (*it).second;
 
-		if (entity->state()->visible() && (entity->shape() != core::Entity::Sphere)) {
+		if ((entity->shape() != core::Entity::Sphere) && entity->state() && entity->state()->visible()) {
 			gl::push();
 			gl::translate(entity->state()->location());
 			math::Color color = entity->color();
@@ -582,7 +579,7 @@ void draw(math::Axis const &axis, math::Vector3f const &eye, math::Vector3f cons
 	camera_eye.assign(eye);
 	camera_axis.assign(axis);
 
-	pass_prepare();
+	pass_prepare(seconds);
 	
 	gl::enable(GL_DEPTH_TEST);	// enable depth buffer writing
 	gl::enable(GL_CULL_FACE);	// enable culling
-- 
cgit v1.2.3