This commit is contained in:
juliancoffee 2024-01-31 19:39:35 +02:00
parent 283b404724
commit 52328b89d2
7 changed files with 41 additions and 37 deletions

View File

@ -95,7 +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;
const int AIRFLOW = 59;
// meters per second squared (acceleration)
const float earth_gravity = 9.807;
@ -983,6 +983,8 @@ 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)
);
break;
case AIRFLOW:
perp_axis = normalize(cross(inst_dir, vec3(0.0, 0.0, 1.0)));
attr = Attr(

View File

@ -12,7 +12,7 @@ impl TimeOfDay {
fn get_angle_rad(self) -> f32 {
const TIME_FACTOR: f64 = (std::f64::consts::PI * 2.0) / (3600.0 * 24.0);
((self.0 as f32 * TIME_FACTOR) % (std::f64::consts::PI * 2.0)) as f32
((self.0 * TIME_FACTOR) % (std::f64::consts::PI * 2.0)) as f32
}
/// Computes the direction of light from the sun based on the time of day.

View File

@ -619,7 +619,9 @@ impl<'a> PhysicsData<'a> {
prof_span!(guard, "Apply Weather INIT");
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 { continue; };
let Some(current_chunk) = read.terrain.get_key(chunk_pos) else {
continue;
};
let meta = current_chunk.meta();
if !state.is_glide() || meta.alt() - 25. > pos.0.z {

View File

@ -110,7 +110,7 @@ pub enum ParticleMode {
PhoenixBeam = 56,
PhoenixBuildUpAim = 57,
ClayShrapnel = 58,
Airflow = 47,
Airflow = 59,
}
impl ParticleMode {

View File

@ -40,7 +40,7 @@ use common::{
},
outcome::Outcome,
resources::{DeltaTime, TimeOfDay, TimeScale},
terrain::{BlockKind, TerrainChunk, TerrainGrid, CoordinateConversion, NEIGHBOR_DELTA},
terrain::{BlockKind, TerrainChunk, TerrainGrid},
vol::ReadVol,
weather::WeatherGrid,
};
@ -1653,13 +1653,19 @@ impl Scene {
let ecs = client.state().ecs();
let vels = &ecs.read_component::<comp::Vel>();
let Some(vel) = vels.get(client.entity()) else { return; };
let Some(vel) = vels.get(client.entity()) else {
return;
};
let phys_states = &ecs.read_component::<comp::PhysicsState>();
let Some(phys) = phys_states.get(client.entity()) else {return;};
let Some(phys) = phys_states.get(client.entity()) else {
return;
};
let positions = &ecs.read_component::<comp::Pos>();
let Some(pos) = positions.get(client.entity()) else {return;};
let Some(pos) = positions.get(client.entity()) else {
return;
};
let weather = ecs.read_resource::<WeatherGrid>();
// take id and remove to delete the previous lines.
@ -1667,7 +1673,9 @@ impl Scene {
const LINE_WIDTH: f32 = 0.05;
// Fluid Velocity
{
let Some(fluid) = phys.in_fluid else { return;};
let Some(fluid) = phys.in_fluid else {
return;
};
let shape = DebugShape::Line([pos.0, pos.0 + fluid.flow_vel().0 / 2.], LINE_WIDTH);
let id = self.debug.add_shape(shape);
lines.fluid_vel = Some(id);
@ -1676,7 +1684,9 @@ impl Scene {
}
// Chunk Terrain Normal Vector
{
let Some(chunk) = client.current_chunk() else { return;};
let Some(chunk) = client.current_chunk() else {
return;
};
let shape = DebugShape::Line(
[
pos.0,

View File

@ -15,7 +15,8 @@ use common::{
item::Reagent,
object,
shockwave::{self, ShockwaveDodgeable},
BeamSegment, Body, CharacterActivity, CharacterState, Fluid, Ori, PhysicsState, Pos, Scale, Shockwave, Vel,
Beam, Body, CharacterActivity, CharacterState, Fluid, Ori, PhysicsState, Pos, Scale,
Shockwave, Vel,
},
figure::Segment,
outcome::Outcome,
@ -916,17 +917,18 @@ 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, physics) in (
&ecs.entities(),
&ecs.read_storage::<Interpolated>(),
ecs.read_storage::<Vel>().maybe(),
&ecs.read_storage::<CharacterState>(),
&ecs.read_storage::<Body>(),
&ecs.read_storage::<Ori>(),
&ecs.read_storage::<CharacterActivity>(),
&ecs.read_storage::<PhysicsState>(),
)
.join()
for (entity, interpolated, vel, character_state, body, ori, character_activity, physics) in
(
&ecs.entities(),
&ecs.read_storage::<Interpolated>(),
ecs.read_storage::<Vel>().maybe(),
&ecs.read_storage::<CharacterState>(),
&ecs.read_storage::<Body>(),
&ecs.read_storage::<Ori>(),
&ecs.read_storage::<CharacterActivity>(),
&ecs.read_storage::<PhysicsState>(),
)
.join()
{
match character_state {
CharacterState::Boost(_) => {

View File

@ -36,6 +36,7 @@ pub use block::BlockGen;
use civ::WorldCivStage;
pub use column::ColumnSample;
pub use common::terrain::site::{DungeonKindMeta, SettlementKindMeta};
use common::terrain::CoordinateConversions;
pub use index::{IndexOwned, IndexRef};
use sim::WorldSimStage;
@ -372,6 +373,7 @@ impl World {
sim_chunk.tree_density,
sim_chunk.cave.1.alt != 0.0,
sim_chunk.river.is_river(),
sim_chunk.river.near_water(),
sim_chunk.river.velocity,
sim_chunk.temp,
sim_chunk.humidity,
@ -389,21 +391,7 @@ impl World {
.get_origin()
.distance_squared(chunk_center_wpos2d)
})
.map(|id| index.sites[*id].kind.convert_to_meta().unwrap_or_default())
.or_else(|| sim_chunk.poi.map(|poi| self.civs.pois[poi].name.clone())),
sim_chunk.get_biome(),
sim_chunk.alt,
sim_chunk.tree_density,
sim_chunk.cave.1.alt != 0.0,
sim_chunk.river.is_river(),
sim_chunk.river.near_water(),
sim_chunk.river.velocity,
sim_chunk.temp,
sim_chunk.humidity,
sim_chunk
.sites
.iter()
.find_map(|site| index.sites[*site].kind.convert_to_meta()),
.map(|id| index.sites[*id].kind.convert_to_meta().unwrap_or_default()),
self.sim.approx_chunk_terrain_normal(chunk_pos),
sim_chunk.rockiness,
sim_chunk.cliff_height,