feat: maximum density after disperse (experimental)
parent
183475c60f
commit
8ff232f21b
|
|
@ -32,7 +32,7 @@ pub fn init() {
|
||||||
|
|
||||||
fn setup_window(mut windows: ResMut<Windows>) {
|
fn setup_window(mut windows: ResMut<Windows>) {
|
||||||
if let Some(window) = windows.get_primary_mut() {
|
if let Some(window) = windows.get_primary_mut() {
|
||||||
window.set_resolution(900.0, 450.0);
|
window.set_resolution(1280.0, 720.0);
|
||||||
window.set_title("Kuilu".to_string());
|
window.set_title("Kuilu".to_string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -226,7 +226,7 @@ fn disperse_gas(
|
||||||
.sum::<u32>();
|
.sum::<u32>();
|
||||||
|
|
||||||
// Stop if the gas is already close to a stable state
|
// Stop if the gas is already close to a stable state
|
||||||
const STABLE_TRESHOLD: u8 = 10;
|
const STABLE_TRESHOLD: u8 = 3;
|
||||||
if total_densities.iter().all(|(_, _, min, max)| {
|
if total_densities.iter().all(|(_, _, min, max)| {
|
||||||
if u8::abs_diff(*min, *max) > STABLE_TRESHOLD {
|
if u8::abs_diff(*min, *max) > STABLE_TRESHOLD {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -572,7 +572,17 @@ impl Terrain2D {
|
||||||
let from = self.get_texel(from_global).unwrap_or_default();
|
let from = self.get_texel(from_global).unwrap_or_default();
|
||||||
let to = self.get_texel(to_global).unwrap_or_default();
|
let to = self.get_texel(to_global).unwrap_or_default();
|
||||||
let max_transfer = gravity.abs();
|
let max_transfer = gravity.abs();
|
||||||
let transfer = (u8::MAX - to.density).min(max_transfer).min(from.density);
|
|
||||||
|
// DEBUG: Test this out, another property?
|
||||||
|
const MAX_TARGET_DENSITY: u8 = 25;
|
||||||
|
let transfer = (u8::MAX - to.density)
|
||||||
|
.min(max_transfer)
|
||||||
|
.min(from.density)
|
||||||
|
.min(MAX_TARGET_DENSITY.max(to.density) - to.density);
|
||||||
|
if transfer == 0 {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if from.density - transfer == 0 {
|
if from.density - transfer == 0 {
|
||||||
self.set_texel(&from_global, Texel2D::default(), simulation_frame);
|
self.set_texel(&from_global, Texel2D::default(), simulation_frame);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue