use bevy::{
prelude::{Component, Resource},
reflect::Reflect,
};
use crate::math::{Real, Vect};
#[cfg(doc)]
use {crate::prelude::TransformInterpolation, rapier::dynamics::IntegrationParameters};
#[derive(Copy, Clone, Debug, PartialEq, Resource)]
pub enum TimestepMode {
Fixed {
dt: f32,
substeps: usize,
},
Variable {
max_dt: f32,
time_scale: f32,
substeps: usize,
},
Interpolated {
dt: f32,
time_scale: f32,
substeps: usize,
},
}
impl Default for TimestepMode {
fn default() -> Self {
TimestepMode::Variable {
max_dt: 1.0 / 60.0,
time_scale: 1.0,
substeps: 1,
}
}
}
#[derive(Component, Copy, Clone, Debug, Reflect)]
pub struct RapierConfiguration {
pub gravity: Vect,
pub physics_pipeline_active: bool,
pub scaled_shape_subdivision: u32,
pub force_update_from_transform_changes: bool,
}
impl RapierConfiguration {
pub fn new(length_unit: Real) -> Self {
Self {
gravity: Vect::Y * -9.81 * length_unit,
physics_pipeline_active: true,
scaled_shape_subdivision: 10,
force_update_from_transform_changes: false,
}
}
}