mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Working wind/lift particles
+ clippy fixes
This commit is contained in:
parent
2add795109
commit
283b404724
@ -95,6 +95,7 @@ const int ENERGY_PHOENIX = 55;
|
||||
const int PHOENIX_BEAM = 56;
|
||||
const int PHOENIX_BUILD_UP_AIM = 57;
|
||||
const int CLAY_SHRAPNEL = 58;
|
||||
const int AIRFLOW = 47;
|
||||
|
||||
// meters per second squared (acceleration)
|
||||
const float earth_gravity = 9.807;
|
||||
@ -982,6 +983,13 @@ void main() {
|
||||
vec3(5 * (1 - percent())),
|
||||
vec4(vec3(clay_color * 3, clay_color * 2, clay_color), 1),
|
||||
spin_in_axis(vec3(1,0,0),0)
|
||||
case AIRFLOW:
|
||||
perp_axis = normalize(cross(inst_dir, vec3(0.0, 0.0, 1.0)));
|
||||
attr = Attr(
|
||||
inst_dir * 0.2 * length(inst_dir) * percent() + inst_dir * percent() * 0.08,
|
||||
vec3(0.03 * length(inst_dir), 0.03 * length(inst_dir), 20.0 * length(inst_dir) * percent() * (1 - percent())),
|
||||
vec4(1.1, 1.1, 1.1, 0.3),
|
||||
spin_in_axis(perp_axis, asin(inst_dir.z / length(inst_dir)) + PI / 2.0)
|
||||
);
|
||||
break;
|
||||
default:
|
||||
|
@ -15,7 +15,6 @@ use common::{
|
||||
resources::{DeltaTime, GameMode, TimeOfDay},
|
||||
states,
|
||||
terrain::{Block, BlockKind, CoordinateConversions, SiteKindMeta, TerrainGrid, NEIGHBOR_DELTA},
|
||||
time::DayPeriod,
|
||||
uid::Uid,
|
||||
util::{Projection, SpatialGrid},
|
||||
vol::{BaseVol, ReadVol},
|
||||
@ -29,11 +28,8 @@ use specs::{
|
||||
shred, Entities, Entity, Join, LendJoin, ParJoin, Read, ReadExpect, ReadStorage, SystemData,
|
||||
Write, WriteExpect, WriteStorage,
|
||||
};
|
||||
use std::{f32::consts::PI, ops::Range};
|
||||
use vek::{
|
||||
num_traits::{Pow, Signed},
|
||||
*,
|
||||
};
|
||||
use std::ops::Range;
|
||||
use vek::*;
|
||||
|
||||
/// The density of the fluid as a function of submersion ratio in given fluid
|
||||
/// where it is assumed that any unsubmersed part is is air.
|
||||
@ -612,9 +608,6 @@ impl<'a> PhysicsData<'a> {
|
||||
if let Some(weather) = &read.weather {
|
||||
// 0.0..1.0, 0.25 morning, 0.45 midday, 0.66 evening, 0.79 night, 0.0/1.0
|
||||
// midnight
|
||||
const SECONDS_PER_DAY: f64 = 60.0 * 60.0 * 24.0;
|
||||
let fraction_of_day: f32 =
|
||||
(read.time_of_day.0.rem_euclid(SECONDS_PER_DAY) / SECONDS_PER_DAY) as f32;
|
||||
for (_, state, pos, phys) in (
|
||||
&read.entities,
|
||||
&read.character_states,
|
||||
@ -684,6 +677,7 @@ impl<'a> PhysicsData<'a> {
|
||||
let sun_dir = read.time_of_day.get_sun_dir().normalized();
|
||||
let mut lift = ((sun_dir - normal.normalized()).magnitude() - 0.5).max(0.2) * 3.;
|
||||
|
||||
// TODO: potential source of harsh edges in wind speed.
|
||||
let temperatures = surrounding_chunks_metas.iter().map(|m| m.temp()).minmax();
|
||||
|
||||
// more thermals if hot chunks border cold chunks
|
||||
@ -694,6 +688,7 @@ impl<'a> PhysicsData<'a> {
|
||||
}
|
||||
.min(2.0);
|
||||
|
||||
// TODO: potential source of harsh edges in wind speed.
|
||||
// way more thermals in strong rain as its often caused by strong thermals.
|
||||
// less in weak rain or cloudy..
|
||||
lift *= if interp_weather.rain.is_between(0.5, 1.0)
|
||||
@ -711,6 +706,8 @@ impl<'a> PhysicsData<'a> {
|
||||
lift *= (above_ground / 15.).min(1.);
|
||||
lift *= (220. - above_ground / 20.).clamp(0.0, 1.0);
|
||||
|
||||
// smooth this, and increase height some more (500 isnt that much higher than
|
||||
// the spires)
|
||||
if interp_alt > 500.0 {
|
||||
lift *= 0.8;
|
||||
}
|
||||
@ -744,7 +741,7 @@ impl<'a> PhysicsData<'a> {
|
||||
};
|
||||
|
||||
// Cliffs mean more lift
|
||||
ridge_lift *= (0.9 + (meta.cliff_height() / 44.0) * 1.2); // 44 seems to be max, according to a lerp in WorldSim::generate_cliffs
|
||||
ridge_lift *= 0.9 + (meta.cliff_height() / 44.0) * 1.2; // 44 seems to be max, according to a lerp in WorldSim::generate_cliffs
|
||||
|
||||
// height based fall-off https://www.desmos.com/calculator/jijqfunchg
|
||||
ridge_lift *= 1. / (1. + (1.3f32.powf(0.1 * above_ground - 15.)));
|
||||
|
@ -110,6 +110,7 @@ pub enum ParticleMode {
|
||||
PhoenixBeam = 56,
|
||||
PhoenixBuildUpAim = 57,
|
||||
ClayShrapnel = 58,
|
||||
Airflow = 47,
|
||||
}
|
||||
|
||||
impl ParticleMode {
|
||||
|
@ -39,8 +39,8 @@ use common::{
|
||||
tool::ToolKind,
|
||||
},
|
||||
outcome::Outcome,
|
||||
resources::{DeltaTime, TimeScale, TimeOfDay},
|
||||
terrain::{BlockKind, CoordinateConversions, TerrainChunk, TerrainGrid, NEIGHBOR_DELTA},
|
||||
resources::{DeltaTime, TimeOfDay, TimeScale},
|
||||
terrain::{BlockKind, TerrainChunk, TerrainGrid, CoordinateConversion, NEIGHBOR_DELTA},
|
||||
vol::ReadVol,
|
||||
weather::WeatherGrid,
|
||||
};
|
||||
|
@ -15,7 +15,7 @@ use common::{
|
||||
item::Reagent,
|
||||
object,
|
||||
shockwave::{self, ShockwaveDodgeable},
|
||||
Beam, Body, CharacterActivity, CharacterState, Ori, Pos, Scale, Shockwave, Vel,
|
||||
BeamSegment, Body, CharacterActivity, CharacterState, Fluid, Ori, PhysicsState, Pos, Scale, Shockwave, Vel,
|
||||
},
|
||||
figure::Segment,
|
||||
outcome::Outcome,
|
||||
@ -916,7 +916,7 @@ impl ParticleMgr {
|
||||
let dt = scene_data.state.get_delta_time();
|
||||
let mut rng = thread_rng();
|
||||
|
||||
for (entity, interpolated, vel, character_state, body, ori, character_activity) in (
|
||||
for (entity, interpolated, vel, character_state, body, ori, character_activity, physics) in (
|
||||
&ecs.entities(),
|
||||
&ecs.read_storage::<Interpolated>(),
|
||||
ecs.read_storage::<Vel>().maybe(),
|
||||
@ -924,6 +924,7 @@ impl ParticleMgr {
|
||||
&ecs.read_storage::<Body>(),
|
||||
&ecs.read_storage::<Ori>(),
|
||||
&ecs.read_storage::<CharacterActivity>(),
|
||||
&ecs.read_storage::<PhysicsState>(),
|
||||
)
|
||||
.join()
|
||||
{
|
||||
@ -1317,6 +1318,34 @@ impl ParticleMgr {
|
||||
);
|
||||
}
|
||||
},
|
||||
CharacterState::Glide(_) => {
|
||||
if let Some(Fluid::Air {
|
||||
vel: air_vel,
|
||||
elevation: _,
|
||||
}) = physics.in_fluid
|
||||
{
|
||||
self.particles.resize_with(
|
||||
self.particles.len()
|
||||
+ usize::from(self.scheduler.heartbeats(Duration::from_millis(10))), // scale with wind speed
|
||||
|| {
|
||||
let start_pos = interpolated.pos
|
||||
+ Vec3::new(
|
||||
body.max_radius(),
|
||||
body.max_radius(),
|
||||
body.height() / 2.0,
|
||||
)
|
||||
.map(|d| d * rng.gen_range(-10.0..10.0));
|
||||
Particle::new_directed(
|
||||
Duration::from_millis(300), // scale with wind speed
|
||||
time,
|
||||
ParticleMode::Airflow,
|
||||
start_pos,
|
||||
start_pos + air_vel.0,
|
||||
)
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
|
@ -54,8 +54,7 @@ use common::{
|
||||
resources::TimeOfDay,
|
||||
rtsim::ChunkResource,
|
||||
terrain::{
|
||||
Block, BlockKind, CoordinateConversions, SpriteKind, TerrainChunk, TerrainChunkMeta,
|
||||
TerrainChunkSize, TerrainGrid,
|
||||
Block, BlockKind, SpriteKind, TerrainChunk, TerrainChunkMeta, TerrainChunkSize, TerrainGrid,
|
||||
},
|
||||
vol::{ReadVol, RectVolSize, WriteVol},
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user