Skip to content

Commit

Permalink
mod: remove the assets module for now
Browse files Browse the repository at this point in the history
  • Loading branch information
philiplinden committed Nov 22, 2024
1 parent 696266b commit 56c23ee
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 52 deletions.
43 changes: 0 additions & 43 deletions src/assets.rs

This file was deleted.

3 changes: 0 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ mod app3d;
mod controls;
mod simulator;

#[cfg(feature = "config-files")]
mod assets;

use bevy::{asset::AssetMetaCheck, prelude::*};

pub struct YahsPlugin;
Expand Down
26 changes: 20 additions & 6 deletions src/simulator/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@

use std::ops::{Add, Div, Mul, Sub};

use avian3d::{math::{Scalar, PI}, prelude::{ColliderDensity, ColliderMassProperties, PhysicsSet, RigidBody}};
use avian3d::{
math::{Scalar, PI},
prelude::{ColliderDensity, ColliderMassProperties, PhysicsSet, RigidBody},

Check failure on line 9 in src/simulator/properties.rs

View workflow job for this annotation

GitHub Actions / build

unused import: `RigidBody`
};
use bevy::{prelude::*, reflect::Reflect};
#[cfg(feature = "config-files")]
use serde::{Serialize, Deserialize};
use serde::{Deserialize, Serialize};

pub const BOLTZMANN_CONSTANT: f32 = 1.38e-23_f32; // [J/K]
pub const AVOGADRO_CONSTANT: f32 = 6.022e+23_f32; // [1/mol]
Expand Down Expand Up @@ -45,9 +48,14 @@ impl Plugin for CorePropertiesPlugin {
app.register_type::<Mass>();
app.register_type::<MolarMass>();

// Ensure that the Avian density matches our computed density before
// solving physics.
app.add_systems(Update, sync_avian_density.in_set(PhysicsSet::Prepare));
// Ensure that the Avian density matches our computed mass and density
// before it starts solving physics.
app.add_systems(
Update,
(sync_avian_mass, sync_avian_density)
.chain()
.in_set(PhysicsSet::Prepare),
);
}
}

Expand Down Expand Up @@ -268,7 +276,7 @@ impl Div<Scalar> for Density {
}
}

fn sync_avian_density(mut densities: Query<(&mut ColliderDensity, &Volume, &Mass), With<RigidBody>>) {
fn sync_avian_density(mut densities: Query<(&mut ColliderDensity, &Volume, &Mass)>) {
for (mut density, volume, mass) in densities.iter_mut() {
let our_density = mass.kg() / volume.m3();
density.0 = our_density;
Expand Down Expand Up @@ -334,6 +342,12 @@ impl Div<Scalar> for Mass {
}
}

fn sync_avian_mass(mut bodies: Query<(&mut ColliderMassProperties, &Mass)>) {
for (mut mass_props, mass) in bodies.iter_mut() {
mass_props.mass.0 = mass.0;
}
}

/// Molar mass (kg/mol) of a substance.
#[derive(Component, Debug, Default, Clone, Copy, PartialEq, Reflect)]
#[cfg_attr(feature = "config-files", derive(Serialize, Deserialize))]
Expand Down

0 comments on commit 56c23ee

Please sign in to comment.