summaryrefslogtreecommitdiff
path: root/src/sim
diff options
context:
space:
mode:
Diffstat (limited to 'src/sim')
-rw-r--r--src/sim/cell_manager/chunk.rs2
-rw-r--r--src/sim/cell_manager/manager.rs2
-rw-r--r--src/sim/entity/mod.rs2
-rw-r--r--src/sim/lib/marching_squares.rs12
-rw-r--r--src/sim/rb_manager/mod.rs2
5 files changed, 10 insertions, 10 deletions
diff --git a/src/sim/cell_manager/chunk.rs b/src/sim/cell_manager/chunk.rs
index 48e9d16..2021b97 100644
--- a/src/sim/cell_manager/chunk.rs
+++ b/src/sim/cell_manager/chunk.rs
@@ -72,7 +72,7 @@ impl Marchable for Chunk {
|| material.form == MaterialForm::Powder && cell.settled() >= SETTLED_THRESOHLD
}
}
- fn size(&self) -> IVec2 {
+ fn marchable_size(&self) -> IVec2 {
IVec2::new(CHUNK_SIZE, CHUNK_SIZE)
}
}
diff --git a/src/sim/cell_manager/manager.rs b/src/sim/cell_manager/manager.rs
index 157499d..7478995 100644
--- a/src/sim/cell_manager/manager.rs
+++ b/src/sim/cell_manager/manager.rs
@@ -43,7 +43,7 @@ impl CellManager {
if !sleeping {
self.chunks[idx].sleeping = false;
// remove this
- self.chunks[idx].collider_dirty_seqno = Some(0);
+ self.chunks[idx].mark_collider_dirty(0);
}
self.chunks[idx].needs_texture_update = true;
}
diff --git a/src/sim/entity/mod.rs b/src/sim/entity/mod.rs
index 2f4034b..9425f9b 100644
--- a/src/sim/entity/mod.rs
+++ b/src/sim/entity/mod.rs
@@ -44,7 +44,7 @@ impl Marchable for EntityCells {
self.get_cell_at_local_position(pos).material != MaterialId::Void
}
}
- fn size(&self) -> IVec2 {
+ fn marchable_size(&self) -> IVec2 {
self.size
}
}
diff --git a/src/sim/lib/marching_squares.rs b/src/sim/lib/marching_squares.rs
index ff48fd5..438b16c 100644
--- a/src/sim/lib/marching_squares.rs
+++ b/src/sim/lib/marching_squares.rs
@@ -43,15 +43,15 @@ fn derive_type(tl: bool, tr: bool, br: bool, bl: bool) -> usize {
pub trait Marchable {
fn occupied(&self, pos: IVec2) -> bool;
- fn size(&self) -> IVec2;
+ fn marchable_size(&self) -> IVec2;
}
-pub fn compute_types(marchable: &impl Marchable, w: i32, h: i32) -> Vec<u8> {
+pub fn compute_types(marchable: &impl Marchable) -> Vec<u8> {
// TODO could pre-allocate size
let mut types = Vec::new();
- for y in -1..h {
+ for y in -1..marchable.marchable_size().y {
// TODO precompute per column
- for x in -1..w {
+ for x in -1..marchable.marchable_size().x {
let tl = marchable.occupied(IVec2::new(x, y));
let tr = marchable.occupied(IVec2::new(x + 1, y));
let br = marchable.occupied(IVec2::new(x + 1, y + 1));
@@ -133,11 +133,11 @@ fn toward_side(x: i32, y: i32, exit: Side) -> (i32, i32, Side) {
// outer is cw, inner ccw
pub fn marching_squares_vertex_trace(marchable: &impl Marchable) -> Vec<Vec<Vec2>> {
- let [w, h] = marchable.size().to_array();
+ let [w, h] = marchable.marchable_size().to_array();
let mut visited = vec![0u8; ((w + 1) * (h + 1)) as usize];
let idx = |cx: i32, cy: i32| (((cy + 1) * (w + 1)) + (cx + 1)) as usize;
- let types = compute_types(marchable, w, h);
+ let types = compute_types(marchable);
let mut polys = Vec::new();
for y in -1..h {
diff --git a/src/sim/rb_manager/mod.rs b/src/sim/rb_manager/mod.rs
index 9d183db..2b476d5 100644
--- a/src/sim/rb_manager/mod.rs
+++ b/src/sim/rb_manager/mod.rs
@@ -110,7 +110,7 @@ impl RbManager {
let minimum_verts = minimum_verts_per_poly.unwrap_or(3);
- let centre_offset = (marchable.size() / 2).as_vec2() - 0.5;
+ let centre_offset = (marchable.marchable_size() / 2).as_vec2() - 0.5;
for poly in polys {
let v = vertices.len() as u32;