Repository navigation
Aravath showcase: bridge reroute, brush digs, integer columns #329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| b663da52ea1d566e | ||
| 0a576578512f25d2 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| //! Integer column hook for the Aravath ground. | ||
| //! | ||
| //! The functions are supplied by the caller (`surface_height` and | ||
| //! `column_material` from the terrain crate). This crate does not depend on | ||
| //! that crate. `FlatColumnBase` stays the unit-test double. | ||
|
|
||
| /// Seed column sampled by function pointer. No heap, no floats. | ||
| #[derive(Clone, Copy, Debug)] | ||
| pub struct ColumnFns { | ||
| pub top: fn(i32, i32) -> i32, | ||
| pub material: fn(i32, i32, i32) -> u16, | ||
| } | ||
|
|
||
| impl ColumnFns { | ||
| pub fn top(self, x: i32, z: i32) -> i32 { | ||
| (self.top)(x, z) | ||
| } | ||
|
|
||
| pub fn material(self, x: i32, y: i32, z: i32) -> u16 { | ||
| (self.material)(x, y, z) | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |
| #![allow(clippy::too_many_arguments, clippy::needless_range_loop)] | ||
|
|
||
| pub mod budget; | ||
| pub mod column_base; | ||
| pub mod command; | ||
| pub mod debris; | ||
| pub mod fracture; | ||
|
|
@@ -34,6 +35,7 @@ pub use budget::{ | |
| DEMOLITION_TICKS as SHOWCASE_TICKS, MAX_BRUSH_CELLS, MAX_LOG_COMMANDS as LATE_JOIN_CAP, | ||
| MAX_NODES_PER_TICK, MAX_SIM_DEBRIS, SLEEP_TICKS, STRESS_ITERS, | ||
| }; | ||
| pub use column_base::ColumnFns; | ||
| pub use command::{CommandError as DestructionCommandError, DestructionCommand as Command}; | ||
| pub use fracture::{bake_bytes, bake_gate, planar_children, BreakRule}; | ||
| pub use graph::{allows_climb, PieceFlags as FractureFlags}; | ||
|
|
@@ -198,6 +200,28 @@ impl DestructionWorld { | |
| &self.terrain | ||
| } | ||
|
|
||
| /// Seed columns for brush replay. The flat test double stays in place until this is called. | ||
| pub fn bind_column_fns(&mut self, fns: ColumnFns) { | ||
| self.terrain.set_column_fns(fns); | ||
| } | ||
|
|
||
| /// Load the brush chunk, record the command, and apply it on this tick. | ||
| pub fn apply_brush_now(&mut self, brush: crate::command::Brush) -> Result<(), CommandError> { | ||
| let chunk = ( | ||
| brush.origin[0].div_euclid(crate::octree::CHUNK_EXTENT), | ||
| brush.origin[2].div_euclid(crate::octree::CHUNK_EXTENT), | ||
| ); | ||
| self.terrain.load(chunk); | ||
|
Comment on lines
+210
to
+214
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a sphere overlaps a 32-unit destruction-chunk boundary, this loads only the chunk containing the origin. Useful? React with 👍 / 👎. |
||
| self.enqueue(DestructionCommand { | ||
| tick: self.tick, | ||
| seq: 0, | ||
| entity_id: 0, | ||
| kind: CommandKind::Brush(brush), | ||
| })?; | ||
| self.tick(); | ||
| Ok(()) | ||
| } | ||
|
|
||
| pub fn debris(&self) -> &DebrisPool { | ||
| &self.debris | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a checkpoint containing earlier digs is loaded,
Ground::restore_editsrecreates the voxel grid but does not restore this newDestructionWorld, sodropis computed from an empty brush log after a restart or a stale log when loading an older checkpoint in-process. A subsequent dig can therefore remove nothing until the log catches up, or over-dig relative to the restored terrain; persist/replay the demolition commands or rebuild its occupancy alongside the voxel edits.Useful? React with 👍 / 👎.