From d73e90d915669a1e25ae61e0d09c17b36631f232 Mon Sep 17 00:00:00 2001 From: Paris DOUADY Date: Thu, 8 Feb 2024 22:20:57 +0100 Subject: [PATCH] bigger subscriber chunk = less draw calls --- common/src/chunkid.rs | 13 +++++++++++++ simulation/src/map/change_detection.rs | 4 ++-- simulation/src/map/terrain.rs | 4 ++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/common/src/chunkid.rs b/common/src/chunkid.rs index 9a5e4025..f9a07c9e 100644 --- a/common/src/chunkid.rs +++ b/common/src/chunkid.rs @@ -10,6 +10,19 @@ pub struct ChunkID(pub i16, pub i16); /// Minimum chunk size, in meters const CHUNK_ID_BASE_SIZE: u32 = 16; +#[allow(non_camel_case_types)] +mod chunk_types { + use super::ChunkID; + pub type ChunkID_16 = ChunkID<0>; + pub type ChunkID_32 = ChunkID<1>; + pub type ChunkID_64 = ChunkID<2>; + pub type ChunkID_128 = ChunkID<3>; + pub type ChunkID_256 = ChunkID<4>; + pub type ChunkID_512 = ChunkID<5>; + pub type ChunkID_1024 = ChunkID<6>; + pub type ChunkID_2048 = ChunkID<7>; +} +pub use chunk_types::*; impl ChunkID { /// The size of a chunk in meters. Smallest at Level=0 diff --git a/simulation/src/map/change_detection.rs b/simulation/src/map/change_detection.rs index 79b60444..a3e1ba51 100644 --- a/simulation/src/map/change_detection.rs +++ b/simulation/src/map/change_detection.rs @@ -3,7 +3,7 @@ //! It is mostly for rendering purposes by decoupling it from the simulation. use crate::map::{Building, Intersection, Lot, Road}; -use common::ChunkID; +use common::{ChunkID, ChunkID_1024}; use geom::Vec2; use std::collections::BTreeSet; use std::sync::{Arc, Mutex}; @@ -14,7 +14,7 @@ pub trait CanonicalPosition { fn canonical_position(&self) -> Vec2; } -pub type SubscriberChunkID = ChunkID<5>; +pub type SubscriberChunkID = ChunkID_1024; bitflags::bitflags! { #[derive(Debug, Copy, Clone)] diff --git a/simulation/src/map/terrain.rs b/simulation/src/map/terrain.rs index 139b6948..35bc4a34 100644 --- a/simulation/src/map/terrain.rs +++ b/simulation/src/map/terrain.rs @@ -8,11 +8,11 @@ use serde::{Deserialize, Serialize}; use std::collections::HashSet; use std::ops::Mul; -pub type TerrainChunkID = common::ChunkID<5>; +pub type TerrainChunkID = common::ChunkID_512; pub const TERRAIN_CHUNK_RESOLUTION: usize = 32; -pub(super) const CELL_SIZE: f32 = TerrainChunkID::SIZE_F32 / TERRAIN_CHUNK_RESOLUTION as f32; // size is 512m +pub(super) const CELL_SIZE: f32 = TerrainChunkID::SIZE_F32 / TERRAIN_CHUNK_RESOLUTION as f32; // 512 / 32 = 16 const TREE_GRID_SIZE: usize = 256;