feat: liquids stabilise a bit better

feat/simulation
hheik 2022-12-25 18:58:38 +02:00
parent ab07b0c06a
commit 4a4d40e0fa
2 changed files with 13 additions and 14 deletions

View File

@ -7,8 +7,8 @@ pub struct TerrainDebugPlugin;
impl Plugin for TerrainDebugPlugin { impl Plugin for TerrainDebugPlugin {
fn build(&self, app: &mut App) { fn build(&self, app: &mut App) {
app.insert_resource(TerrainBrush2D::default()) app.insert_resource(TerrainBrush2D::default())
.add_system(debug_painter) // .add_system_to_stage(TerrainStages::EventHandler, dirty_rect_visualizer)
.add_system_to_stage(TerrainStages::EventHandler, dirty_rect_visualizer); .add_system(debug_painter);
} }
} }

View File

@ -77,17 +77,16 @@ fn terrain_simulation(mut terrain: ResMut<Terrain2D>, frame_counter: Res<FrameCo
.clone(); .clone();
for chunk_index in indices.iter() { for chunk_index in indices.iter() {
// // DEBUG: mark few chunks dirty in interval // Mark few chunks dirty in interval. Should help activate stale chunks
// if let Some(chunk) = terrain.index_to_chunk_mut(&chunk_index) { if let Some(chunk) = terrain.index_to_chunk_mut(&chunk_index) {
// let interval = 2; let interval = 1;
// if frame_counter.frame % interval == 0 { if frame_counter.frame % interval == 0 {
// let i = ((frame_counter.frame / interval) % 100) as i32; let i = ((frame_counter.frame / interval) % 100) as i32;
// if (chunk_index.y % 10) * 10 + (chunk_index.x % 10) == i { if (chunk_index.y % 10) * 10 + (chunk_index.x % 10) == i {
// chunk.mark_all_dirty(); chunk.mark_all_dirty();
// println!("chunk {:?} is now dirty", chunk_index); }
// } }
// } };
// };
if let Some(rect) = &terrain if let Some(rect) = &terrain
.index_to_chunk(&chunk_index) .index_to_chunk(&chunk_index)
@ -144,7 +143,7 @@ fn terrain_simulation(mut terrain: ResMut<Terrain2D>, frame_counter: Res<FrameCo
// Check if there is space to the side // Check if there is space to the side
let mut dirs = vec![Vector2I::RIGHT, Vector2I::LEFT]; let mut dirs = vec![Vector2I::RIGHT, Vector2I::LEFT];
if (frame_counter.frame / 3) % 2 == 0 { if ((frame_counter.frame / 73) % 2) as i32 == global.y % 2 {
dirs.reverse(); dirs.reverse();
} }
for dir in dirs.iter() { for dir in dirs.iter() {