fix: Water no longer corners
This commit is contained in:
parent
4494b62342
commit
b08d07b2ac
2 changed files with 6 additions and 7 deletions
|
|
@ -56,10 +56,10 @@ impl Grid {
|
||||||
(GridElement::Air,GridElement::Water { amount: water_amount, force }) => {
|
(GridElement::Air,GridElement::Water { amount: water_amount, force }) => {
|
||||||
let moved_amount = water_amount.min(transfer_amount);
|
let moved_amount = water_amount.min(transfer_amount);
|
||||||
let remaining_amount = water_amount-moved_amount;
|
let remaining_amount = water_amount-moved_amount;
|
||||||
to_new_value = Some(GridElement::Water { amount: moved_amount, force });
|
to_new_value = Some(GridElement::Water { amount: moved_amount, force: from_force });
|
||||||
from_new_value = if remaining_amount == 0 {Some(GridElement::Air)} else {Some(GridElement::Water { amount: remaining_amount, force: from_force })};
|
from_new_value = if remaining_amount == 0 {Some(GridElement::Air)} else {Some(GridElement::Water { amount: remaining_amount, force })};
|
||||||
},
|
},
|
||||||
(GridElement::Water { amount: mut to_amount, force: to_force }, GridElement::Water { amount: mut from_amount, force: _ }) => {
|
(GridElement::Water { amount: mut to_amount, force: to_force }, GridElement::Water { amount: mut from_amount, force }) => {
|
||||||
let transfer_amount = from_amount.min(transfer_amount);
|
let transfer_amount = from_amount.min(transfer_amount);
|
||||||
let delta = MAX_FLUID_AMOUNT - to_amount;
|
let delta = MAX_FLUID_AMOUNT - to_amount;
|
||||||
if delta < transfer_amount {
|
if delta < transfer_amount {
|
||||||
|
|
@ -72,7 +72,7 @@ impl Grid {
|
||||||
}
|
}
|
||||||
let resulting_force = to_force.midpoint(from_force);
|
let resulting_force = to_force.midpoint(from_force);
|
||||||
to_new_value = Some(GridElement::Water { amount: to_amount, force: resulting_force });
|
to_new_value = Some(GridElement::Water { amount: to_amount, force: resulting_force });
|
||||||
from_new_value = if from_amount == 0 {Some(GridElement::Air)} else {Some(GridElement::Water { amount: from_amount, force: resulting_force })};
|
from_new_value = if from_amount == 0 {Some(GridElement::Air)} else {Some(GridElement::Water { amount: from_amount, force: force })};
|
||||||
},
|
},
|
||||||
(GridElement::Drain, GridElement::Water { amount: from_amount, force }) => {
|
(GridElement::Drain, GridElement::Water { amount: from_amount, force }) => {
|
||||||
let transfer_amount = from_amount.min(transfer_amount);
|
let transfer_amount = from_amount.min(transfer_amount);
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ pub fn tick(mut grid: ResMut<Grid>, options: Res<SimulationOptions>) {
|
||||||
from: vector,
|
from: vector,
|
||||||
to: main_vector.as_uvec3(),
|
to: main_vector.as_uvec3(),
|
||||||
amount: main_amount,
|
amount: main_amount,
|
||||||
with_force: main_vector.as_vec3() * (main_amount as f32) }
|
with_force: resulting_force * (main_amount as f32) }
|
||||||
);
|
);
|
||||||
transfer_amount -= main_amount;
|
transfer_amount -= main_amount;
|
||||||
}
|
}
|
||||||
|
|
@ -92,9 +92,8 @@ pub fn tick(mut grid: ResMut<Grid>, options: Res<SimulationOptions>) {
|
||||||
from: vector,
|
from: vector,
|
||||||
to: side_vector.as_uvec3(),
|
to: side_vector.as_uvec3(),
|
||||||
amount: side_amount,
|
amount: side_amount,
|
||||||
with_force: side_vector.as_vec3() * (side_amount as f32) }
|
with_force: lookup_vector.as_vec3() * (side_amount as f32) }
|
||||||
);
|
);
|
||||||
transfer_amount -= side_amount;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue