mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fix client-side wind simulation
- Apply local wind on the client WeatherGrid - Set air_vel to zero if not simulating
This commit is contained in:
parent
5c517e88c9
commit
a06e79b089
@ -237,6 +237,7 @@ impl WeatherLerp {
|
||||
.zip(old.iter().zip(new.iter()))
|
||||
.for_each(|((_, current), ((_, old), (_, new)))| {
|
||||
*current = CompressedWeather::lerp_unclamped(old, new, t);
|
||||
current.wind = self.local_wind;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -143,9 +143,7 @@ impl Body {
|
||||
Vec3::zero()
|
||||
} else {
|
||||
let rel_flow_dir = Dir::new(rel_flow.0 / v_sq.sqrt());
|
||||
0.5 * fluid_density
|
||||
* v_sq
|
||||
* match wings {
|
||||
let power_vec = match wings {
|
||||
Some(&Wings {
|
||||
aspect_ratio,
|
||||
planform_area,
|
||||
@ -153,8 +151,8 @@ impl Body {
|
||||
}) => {
|
||||
if aspect_ratio > 25.0 {
|
||||
tracing::warn!(
|
||||
"Calculating lift for wings with an aspect ratio of {}. The \
|
||||
formulas are only valid for aspect ratios below 25.",
|
||||
"Calculating lift for wings with an aspect ratio of {}. The formulas \
|
||||
are only valid for aspect ratios below 25.",
|
||||
aspect_ratio
|
||||
)
|
||||
};
|
||||
@ -207,7 +205,9 @@ impl Body {
|
||||
},
|
||||
|
||||
_ => self.parasite_drag(scale) * *rel_flow_dir,
|
||||
}
|
||||
};
|
||||
|
||||
0.5 * fluid_density * v_sq * power_vec
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -759,35 +759,40 @@ impl<'a> PhysicsData<'a> {
|
||||
)
|
||||
.join()
|
||||
{
|
||||
// Always reset air_vel to zero
|
||||
let mut air_vel = Vec3::zero();
|
||||
|
||||
'simulation: {
|
||||
// Don't simulate for non-gliding, for now
|
||||
if !state.is_glide() {
|
||||
continue;
|
||||
break 'simulation;
|
||||
}
|
||||
|
||||
let pos_2d = pos.0.as_().xy();
|
||||
let chunk_pos: Vec2<i32> = pos_2d.wpos_to_cpos();
|
||||
let Some(current_chunk) = &read.terrain.get_key(chunk_pos) else {
|
||||
// oopsie
|
||||
continue;
|
||||
break 'simulation;
|
||||
};
|
||||
|
||||
let meta = current_chunk.meta();
|
||||
|
||||
// Skip simulating for entites deeply under the ground
|
||||
if pos.0.z < meta.alt() - 25.0 {
|
||||
continue;
|
||||
break 'simulation;
|
||||
}
|
||||
|
||||
// If couldn't simulate wind for some reason, skip
|
||||
let Ok(wind_vel) =
|
||||
if let Ok(simulated_vel) =
|
||||
simulated_wind_vel(pos, weather, &read.terrain, &read.time_of_day)
|
||||
else {
|
||||
continue;
|
||||
{
|
||||
air_vel = simulated_vel
|
||||
};
|
||||
}
|
||||
|
||||
phys.in_fluid = phys.in_fluid.map(|f| match f {
|
||||
Fluid::Air { elevation, .. } => Fluid::Air {
|
||||
vel: Vel(wind_vel),
|
||||
vel: Vel(air_vel),
|
||||
elevation,
|
||||
},
|
||||
fluid => fluid,
|
||||
|
Loading…
Reference in New Issue
Block a user