diff options
Diffstat (limited to 'crates/fparkan-terrain/src')
| -rw-r--r-- | crates/fparkan-terrain/src/lib.rs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/crates/fparkan-terrain/src/lib.rs b/crates/fparkan-terrain/src/lib.rs index 7e2ae588..659acf86 100644 --- a/crates/fparkan-terrain/src/lib.rs +++ b/crates/fparkan-terrain/src/lib.rs @@ -251,6 +251,7 @@ impl TerrainWorld { ); areals.push(RuntimeAreal { id, + logic_flag: areal.logic_flag, polygon: areal .vertices .iter() @@ -427,6 +428,12 @@ impl TerrainWorld { self.areals.len() } + /// Logic flag from the prefix of this logical area in `Land.map`. + #[must_use] + pub fn areal_logic_flag(&self, id: ArealId) -> Option<u32> { + self.areals.get(id.0 as usize).map(|areal| areal.logic_flag) + } + /// Returns the midpoint of the boundary edge linking two consecutive areas. /// Links through polygon slots have no boundary midpoint. #[must_use] @@ -974,6 +981,7 @@ impl RuntimeTriangle { #[derive(Clone, Debug)] struct RuntimeAreal { id: ArealId, + logic_flag: u32, polygon: Vec<[f32; 2]>, edge_neighbors: Vec<Option<u32>>, } @@ -1280,10 +1288,15 @@ mod tests { #[test] fn locates_areal_and_routes_synthetic_neighbors() { - let map = synthetic_land_map(); + let mut map = synthetic_land_map(); + map.areals[0].logic_flag = 0; + map.areals[1].logic_flag = 1; let world = TerrainWorld::from_land_map(&map).expect("world"); assert_eq!(world.areal_count(), 2); + assert_eq!(world.areal_logic_flag(ArealId(0)), Some(0)); + assert_eq!(world.areal_logic_flag(ArealId(1)), Some(1)); + assert_eq!(world.areal_logic_flag(ArealId(2)), None); assert_eq!( world.route_crossing(ArealId(0), ArealId(1)), Some([1.0, 0.5]) |
