better splash

This commit is contained in:
Isse
2024-11-07 19:20:30 +01:00
parent 2b4e8c3b7d
commit 6cb5fa07f2
2 changed files with 20 additions and 15 deletions

View File

@ -1063,7 +1063,7 @@ void main() {
case WATER_FOAM:
f_reflect = 0.1;
attr = Attr(
inst_dir * pow(percent(), 0.5) * 0.5 + pow(slow_start(0.5) * 2, 2) * vec3(0, 0, -20),
inst_dir * pow(percent(), 0.5) * 0.5 + percent() * percent() * vec3(0, 0, -50),
vec3((1.5 * (1 - slow_start(0.2)))),
vec4(1.0, 1.0, 1.0, 1),
spin_in_axis(vec3(rand6, rand7, rand8), percent() * 10 + 3 * rand9)

View File

@ -516,30 +516,35 @@ impl ParticleMgr {
comp::fluid_dynamics::LiquidKind::Water => ParticleMode::WaterFoam,
comp::fluid_dynamics::LiquidKind::Lava => ParticleMode::CampfireFire,
};
let magnitude = vel.magnitude();
let magnitude = (-vel.z).max(0.0);
let energy = mass * magnitude;
if energy > 0.0 {
let axis = vel / magnitude;
let count = (2.0 * energy.sqrt()).ceil() as usize;
dbg!(count);
// let axis = vel / magnitude;
let count = (0.6 * energy.sqrt()).ceil() as usize;
// dbg!(count);
let mut i = 0;
let r = 0.5 / count as f32;
let plane = if axis == Vec3::unit_z() {
Vec3::unit_x()
} else {
axis.cross(Vec3::unit_z())
};
dbg!(plane);
// let plane = if axis == Vec3::unit_z() {
// Vec3::unit_x()
// } else {
// axis.cross(Vec3::unit_z())
// };
// dbg!(plane);
self.particles
.resize_with(self.particles.len() + count, || {
let t = i as f32 / count as f32 + rng.gen_range(-r..=r);
i += 1;
let angle = t * TAU;
let s = (angle * 0.5).sin();
let c = (angle * 0.5).cos();
let q = Quaternion::<f32>::from((axis * s).with_w(c)).normalized();
let s = angle.sin();
let c = angle.cos();
let energy = energy
* f32::abs(rng.gen_range(0.0..1.0) + rng.gen_range(0.0..1.0) - 0.5);
// let q = Quaternion::<f32>::from((axis * s).with_w(c)).normalized();
let plane = (plane * q).normalized();
// let plane = (plane * q).normalized();
let axis = -Vec3::unit_z();
let plane = Vec3::new(c, s, 0.0);
let pos = *pos + plane * rng.gen_range(0.0..0.5);