From 127f8fb72bcc371b313d218af55f8c55cc238881 Mon Sep 17 00:00:00 2001 From: Yusuf Bera Ertan Date: Thu, 9 Jan 2020 22:07:55 +0300 Subject: [PATCH] Fix `lpindex` not being updated for culled objects, and don't recalculate frustum for every entity --- voxygen/src/scene/figure/mod.rs | 73 ++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 32 deletions(-) diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 6887710b40..c05211da6a 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -73,6 +73,7 @@ impl FigureMgr { let ecs = client.state().ecs(); let view_distance = client.view_distance().unwrap_or(1); let dt = client.state().get_delta_time(); + let frustum = camera.frustum(client); // Get player position. let player_pos = ecs .read_storage::() @@ -190,8 +191,6 @@ impl FigureMgr { } // Don't process figures outside the frustum spectrum - let frustum = camera.frustum(client); - let (in_frustum, lpindex) = BoundingSphere::new(pos.0.into_array(), scale.unwrap_or(&Scale(1.0)).0 * 2.0) .coherent_test_against_frustum( @@ -242,54 +241,64 @@ impl FigureMgr { if !in_frustum { match body { Body::Humanoid(_) => { - self.character_states - .get_mut(&entity) - .map(|state| state.visible = false); + self.character_states.get_mut(&entity).map(|state| { + state.lpindex = lpindex; + state.visible = false + }); } Body::QuadrupedSmall(_) => { - self.quadruped_small_states - .get_mut(&entity) - .map(|state| state.visible = false); + self.quadruped_small_states.get_mut(&entity).map(|state| { + state.lpindex = lpindex; + state.visible = false + }); } Body::QuadrupedMedium(_) => { - self.quadruped_medium_states - .get_mut(&entity) - .map(|state| state.visible = false); + self.quadruped_medium_states.get_mut(&entity).map(|state| { + state.lpindex = lpindex; + state.visible = false + }); } Body::BirdMedium(_) => { - self.bird_medium_states - .get_mut(&entity) - .map(|state| state.visible = false); + self.bird_medium_states.get_mut(&entity).map(|state| { + state.lpindex = lpindex; + state.visible = false + }); } Body::FishMedium(_) => { - self.fish_medium_states - .get_mut(&entity) - .map(|state| state.visible = false); + self.fish_medium_states.get_mut(&entity).map(|state| { + state.lpindex = lpindex; + state.visible = false + }); } Body::Dragon(_) => { - self.dragon_states - .get_mut(&entity) - .map(|state| state.visible = false); + self.dragon_states.get_mut(&entity).map(|state| { + state.lpindex = lpindex; + state.visible = false + }); } Body::BirdSmall(_) => { - self.bird_small_states - .get_mut(&entity) - .map(|state| state.visible = false); + self.bird_small_states.get_mut(&entity).map(|state| { + state.lpindex = lpindex; + state.visible = false + }); } Body::FishSmall(_) => { - self.fish_small_states - .get_mut(&entity) - .map(|state| state.visible = false); + self.fish_small_states.get_mut(&entity).map(|state| { + state.lpindex = lpindex; + state.visible = false + }); } Body::BipedLarge(_) => { - self.biped_large_states - .get_mut(&entity) - .map(|state| state.visible = false); + self.biped_large_states.get_mut(&entity).map(|state| { + state.lpindex = lpindex; + state.visible = false + }); } Body::Object(_) => { - self.object_states - .get_mut(&entity) - .map(|state| state.visible = false); + self.object_states.get_mut(&entity).map(|state| { + state.lpindex = lpindex; + state.visible = false + }); } } continue;