mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Use treeculler
crate
This commit is contained in:
parent
0b67dad4a5
commit
24013f1a32
17
Cargo.lock
generated
17
Cargo.lock
generated
@ -1052,11 +1052,6 @@ name = "foreign-types-shared"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "frustum_culling"
|
||||
version = "0.1.0"
|
||||
source = "git+https://gitlab.com/yusdacra/frustum_culling#7145dbee5eadf4df0cbe5aeda856a0967f47ace4"
|
||||
|
||||
[[package]]
|
||||
name = "fsevent"
|
||||
version = "0.4.0"
|
||||
@ -3308,6 +3303,14 @@ dependencies = [
|
||||
"serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "treeculler"
|
||||
version = "0.1.0"
|
||||
source = "git+https://gitlab.com/yusdacra/treeculler.git#6c0fdf1c1cbf00be22e37410985d6a3973cd9bed"
|
||||
dependencies = [
|
||||
"num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tuple_utils"
|
||||
version = "0.3.0"
|
||||
@ -3522,7 +3525,6 @@ dependencies = [
|
||||
"euc 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"fern 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"frustum_culling 0.1.0 (git+https://gitlab.com/yusdacra/frustum_culling)",
|
||||
"gfx 0.18.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gfx_device_gl 0.16.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gfx_window_glutin 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -3542,6 +3544,7 @@ dependencies = [
|
||||
"serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"specs 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"treeculler 0.1.0 (git+https://gitlab.com/yusdacra/treeculler.git)",
|
||||
"vek 0.9.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"veloren-client 0.4.0",
|
||||
"veloren-common 0.4.0",
|
||||
@ -3952,7 +3955,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3"
|
||||
"checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
|
||||
"checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
|
||||
"checksum frustum_culling 0.1.0 (git+https://gitlab.com/yusdacra/frustum_culling)" = "<none>"
|
||||
"checksum fsevent 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5ab7d1bd1bd33cc98b0889831b72da23c0aa4df9cec7e0702f46ecea04b35db6"
|
||||
"checksum fsevent-sys 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f41b048a94555da0f42f1d632e2e19510084fb8e303b0daa2816e733fb3644a0"
|
||||
"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
|
||||
@ -4201,6 +4203,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum tiny_http 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1661fa0a44c95d01604bd05c66732a446c657efb62b5164a7a083a3b552b4951"
|
||||
"checksum tinytemplate 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4574b75faccaacddb9b284faecdf0b544b80b6b294f3d062d325c5726a209c20"
|
||||
"checksum toml 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "01d1404644c8b12b16bfcffa4322403a91a451584daaaa7c28d3152e6cbc98cf"
|
||||
"checksum treeculler 0.1.0 (git+https://gitlab.com/yusdacra/treeculler.git)" = "<none>"
|
||||
"checksum tuple_utils 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44834418e2c5b16f47bedf35c28e148db099187dd5feee6367fb2525863af4f1"
|
||||
"checksum twoway 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "59b11b2b5241ba34be09c3cc85a36e56e48f9888862e19cedf23336d35316ed1"
|
||||
"checksum ucd-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa9b3b49edd3468c0e6565d85783f51af95212b6fa3986a5500954f00b460874"
|
||||
|
@ -55,7 +55,7 @@ directories = "2.0.2"
|
||||
num = "0.2.0"
|
||||
backtrace = "0.3.40"
|
||||
rand = "0.7.2"
|
||||
frustum_culling = { git = "https://gitlab.com/yusdacra/frustum_culling" }
|
||||
treeculler = { git = "https://gitlab.com/yusdacra/treeculler.git" }
|
||||
# context for pinning to commit: https://gitlab.com/veloren/veloren/issues/280
|
||||
rodio = { git = "https://github.com/RustAudio/rodio", rev = "e5474a2"}
|
||||
cpal = "0.10"
|
||||
|
@ -1,6 +1,6 @@
|
||||
use client::Client;
|
||||
use common::vol::{ReadVol, Vox};
|
||||
use frustum_culling::Frustum;
|
||||
use treeculler::Frustum;
|
||||
use std::f32::consts::PI;
|
||||
use vek::*;
|
||||
|
||||
@ -100,7 +100,7 @@ impl Camera {
|
||||
(view_mat, proj_mat, cam_pos)
|
||||
}
|
||||
|
||||
pub fn frustum(&self, client: &Client) -> Frustum {
|
||||
pub fn frustum(&self, client: &Client) -> Frustum<f32> {
|
||||
let (view_mat, proj_mat, _) = self.compute_dependents(client);
|
||||
|
||||
Frustum::from_modelview_projection((proj_mat * view_mat).into_col_arrays())
|
||||
|
@ -27,6 +27,7 @@ use common::{
|
||||
use hashbrown::HashMap;
|
||||
use log::trace;
|
||||
use specs::{Entity as EcsEntity, Join, WorldExt};
|
||||
use treeculler::{BoundingSphere, BVol};
|
||||
use vek::*;
|
||||
|
||||
const DAMAGE_FADE_COEFFICIENT: f64 = 5.0;
|
||||
@ -171,9 +172,8 @@ impl FigureMgr {
|
||||
// Don't process figures outside the frustum spectrum
|
||||
let frustum = camera.frustum(client);
|
||||
|
||||
let (in_frustum, lpindex) = frustum.test_sphere_coherence(
|
||||
pos.0.into_array(),
|
||||
scale.unwrap_or(&Scale(1.0)).0 * 2.0,
|
||||
let (in_frustum, lpindex) = BoundingSphere::new(pos.0.into_array(), scale.unwrap_or(&Scale(1.0)).0 * 2.0).coherent_test_against_frustum(
|
||||
&frustum,
|
||||
match body {
|
||||
Body::Humanoid(_) => {
|
||||
self.character_states.get(&entity).map(|state| state.lpindex)
|
||||
@ -208,40 +208,39 @@ impl FigureMgr {
|
||||
}.unwrap_or(0),
|
||||
);
|
||||
|
||||
match body {
|
||||
Body::Humanoid(_) => {
|
||||
self.character_states.get_mut(&entity).map(|state| state.visible = in_frustum);
|
||||
}
|
||||
Body::QuadrupedSmall(_) => {
|
||||
self.quadruped_small_states.get_mut(&entity).map(|state| state.visible = in_frustum);
|
||||
}
|
||||
Body::QuadrupedMedium(_) => {
|
||||
self.quadruped_medium_states.get_mut(&entity).map(|state| state.visible = in_frustum);
|
||||
}
|
||||
Body::BirdMedium(_) => {
|
||||
self.bird_medium_states.get_mut(&entity).map(|state| state.visible = in_frustum);
|
||||
}
|
||||
Body::FishMedium(_) => {
|
||||
self.fish_medium_states.get_mut(&entity).map(|state| state.visible = in_frustum);
|
||||
}
|
||||
Body::Dragon(_) => {
|
||||
self.dragon_states.get_mut(&entity).map(|state| state.visible = in_frustum);
|
||||
}
|
||||
Body::BirdSmall(_) => {
|
||||
self.bird_small_states.get_mut(&entity).map(|state| state.visible = in_frustum);
|
||||
}
|
||||
Body::FishSmall(_) => {
|
||||
self.fish_small_states.get_mut(&entity).map(|state| state.visible = in_frustum);
|
||||
}
|
||||
Body::BipedLarge(_) => {
|
||||
self.biped_large_states.get_mut(&entity).map(|state| state.visible = in_frustum);
|
||||
}
|
||||
Body::Object(_) => {
|
||||
self.object_states.get_mut(&entity).map(|state| state.visible = in_frustum);
|
||||
}
|
||||
}
|
||||
|
||||
if !in_frustum {
|
||||
match body {
|
||||
Body::Humanoid(_) => {
|
||||
self.character_states.get_mut(&entity).map(|state| state.visible = false);
|
||||
}
|
||||
Body::QuadrupedSmall(_) => {
|
||||
self.quadruped_small_states.get_mut(&entity).map(|state| state.visible = false);
|
||||
}
|
||||
Body::QuadrupedMedium(_) => {
|
||||
self.quadruped_medium_states.get_mut(&entity).map(|state| state.visible = false);
|
||||
}
|
||||
Body::BirdMedium(_) => {
|
||||
self.bird_medium_states.get_mut(&entity).map(|state| state.visible = false);
|
||||
}
|
||||
Body::FishMedium(_) => {
|
||||
self.fish_medium_states.get_mut(&entity).map(|state| state.visible = false);
|
||||
}
|
||||
Body::Dragon(_) => {
|
||||
self.dragon_states.get_mut(&entity).map(|state| state.visible = false);
|
||||
}
|
||||
Body::BirdSmall(_) => {
|
||||
self.bird_small_states.get_mut(&entity).map(|state| state.visible = false);
|
||||
}
|
||||
Body::FishSmall(_) => {
|
||||
self.fish_small_states.get_mut(&entity).map(|state| state.visible = false);
|
||||
}
|
||||
Body::BipedLarge(_) => {
|
||||
self.biped_large_states.get_mut(&entity).map(|state| state.visible = false);
|
||||
}
|
||||
Body::Object(_) => {
|
||||
self.object_states.get_mut(&entity).map(|state| state.visible = false);
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -16,9 +16,9 @@ use common::{
|
||||
};
|
||||
use crossbeam::channel;
|
||||
use dot_vox::DotVoxData;
|
||||
use frustum_query::Frustum;
|
||||
use treeculler::{Frustum, AABB, BVol};
|
||||
use hashbrown::{hash_map::Entry, HashMap};
|
||||
use std::{f32, fmt::Debug, i32, marker::PhantomData, ops::Mul, time::Duration};
|
||||
use std::{f32, fmt::Debug, i32, marker::PhantomData, time::Duration};
|
||||
use vek::*;
|
||||
|
||||
struct TerrainChunkData {
|
||||
@ -1062,7 +1062,7 @@ impl<V: RectRasterableVol> Terrain<V> {
|
||||
chunk.z_bounds.1,
|
||||
];
|
||||
|
||||
let (in_frustum, last_plane_index) = frustum.test_aabb_coherence(chunk_min, chunk_max, chunk.frustum_last_plane_index);
|
||||
let (in_frustum, last_plane_index) = AABB::new(chunk_min, chunk_max).coherent_test_against_frustum(&frustum, chunk.frustum_last_plane_index);
|
||||
|
||||
chunk.frustum_last_plane_index = last_plane_index;
|
||||
chunk.visible = in_frustum;
|
||||
|
Loading…
Reference in New Issue
Block a user