ELGDDPUWFOH6ELJVCFVNUQJQRB44G66BJXVQWQGQHNUWYA3XQJVQC
KYEVTQT5IWDHVCMV2TORNQPODLJBKD3HLS4EIXR5HOL5DZI3UVKQC
WQS2WD437EWG2CKPOY5TDWPEBE3US7LGHVAH2HVYQ7RW2L6FHJ5AC
VICUJP7SGKKCO2ZWO5ACSO3OS4HV4JTXTHQHYSFOADANGUJ5ZDDAC
NWMRJJ6FF223Z37T5JL56ETC24NYVYXATI7EZCFQKH52NBWSQENAC
J32UZAU7V6XDZUSDHMLVA474JC4S4AHMLZZN55XC74YMXW4ZMFKQC
EV477LPQ57FEHMFO6E3LL5MFWZC6NTGER42SKP5CJN73SWXGB5AQC
QX5SFVRZ6YZLBMRMRGGNQJ6U73ES5EYWC4SDAR3XCL563NHZU64AC
MKB2A5XCWBZO2E6QFE6PD36LF3IGMJCGJB5TGMRAPSKCKHS75ISAC
WZNCJURAC7FVWQLHFLXE26CAZVCY4OMCD5U52VEW75LBEVXHHRYQC
R5KHFY6NVDHJJC5WNM4H5MXTVXRRZ2SLGL3LOWHGCEEF66KVBE7AC
EQ6ZV6AZEAW6XVZFIZCMKFFE6EAL2I2XTLDTN7BUC53T5H7FS5FQC
fn update_transform(
/// Speeds below this should be considered 0.
pub const MIN_SPEED: f32 = 1.0;
// highest speed we expect movement-pointered stuff to move at
pub const MAX_SPEED: f32 = 1000.0;
fn fake_friction(mut query: Query<&mut Movable>) {
// TODO Allow this to be determined by tiles!
// This should range from 0.0 to 1.0
const MU: f32 = 0.7;
const MU_STATIC: f32 = 0.9;
const GRAVITY: f32 = 9.8; // m/s^2 on Earth, TODO adjust for feel
for mut movable in query.iter_mut() {
let speed = movable.velocity.length();
if let Some(vnorm) = movable.velocity.try_normalize() {
// Friction = mu * N where N is the normal force
// we assume the only normal force is gravity.
// so friction in our system is
// mu * mass * gravity
let mass = movable.mass;
let friction_magnitude =
if speed <= MIN_SPEED { MU_STATIC } else { MU } * mass.max(1.0) * GRAVITY;
movable.acceleration += -vnorm * friction_magnitude;
}
}
}
fn update_velocity(
for (mut transform, moveable, maybe_pointer) in query.iter_mut() {
for (mut movable, maybe_pointer) in query.iter_mut() {
let acceleration = movable.acceleration;
movable.velocity += acceleration * time.delta_seconds();
// Reset accel
movable.acceleration = Vec2::ZERO;
}
if let Some(mut movable) = movable {
if ui.button("Static").clicked() {
commands.entity(polly_entity).remove::<movement::Movable>();
}
ui.add(egui::Slider::new(&mut movable.mass, 5.0..=100.0).text("Mass"));
} else if ui.button("Dynamic").clicked() {
commands.entity(polly_entity).insert(movement::Movable {
mass: 20.0,
..default()
});
let mtv = (axis * magnitude * (oaabb_min_proj - aabb_min_proj).signum()).extend(0.0);
match (collidable.is_static, ocollidable.is_static) {
let mtv = axis * magnitude * (oaabb_min_proj - aabb_min_proj).signum();
const IMPULSE: f32 = 5_000.0;
// TODO This does not handle rotation, cuz we assume we can't do that.
match (movable, omovable) {