Skip to content

Commit

Permalink
bigger subscriber chunk = less draw calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Uriopass committed Feb 8, 2024
1 parent 4a7e47f commit d73e90d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
13 changes: 13 additions & 0 deletions common/src/chunkid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@ pub struct ChunkID<const LEVEL: u16>(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<const LEVEL: u16> ChunkID<LEVEL> {
/// The size of a chunk in meters. Smallest at Level=0
Expand Down
4 changes: 2 additions & 2 deletions simulation/src/map/change_detection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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)]
Expand Down
4 changes: 2 additions & 2 deletions simulation/src/map/terrain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit d73e90d

Please sign in to comment.