61 lines
1.2 KiB
Rust
61 lines
1.2 KiB
Rust
use rapier2d::{
|
|
dynamics::{
|
|
CCDSolver, ImpulseJointSet, IntegrationParameters, IslandManager, MultibodyJointSet,
|
|
RigidBodySet,
|
|
},
|
|
geometry::{BroadPhase, ColliderSet, NarrowPhase},
|
|
na::vector,
|
|
pipeline::{EventHandler, PhysicsPipeline},
|
|
};
|
|
|
|
pub(crate) struct Wrapper {
|
|
pub rigid_body_set: RigidBodySet,
|
|
pub collider_set: ColliderSet,
|
|
|
|
pub ip: IntegrationParameters,
|
|
pub pp: PhysicsPipeline,
|
|
pub im: IslandManager,
|
|
pub bp: BroadPhase,
|
|
pub np: NarrowPhase,
|
|
pub ij: ImpulseJointSet,
|
|
pub mj: MultibodyJointSet,
|
|
pub ccd: CCDSolver,
|
|
}
|
|
|
|
impl Wrapper {
|
|
pub fn new() -> Self {
|
|
Self {
|
|
rigid_body_set: RigidBodySet::new(),
|
|
collider_set: ColliderSet::new(),
|
|
|
|
ip: IntegrationParameters::default(),
|
|
pp: PhysicsPipeline::new(),
|
|
im: IslandManager::new(),
|
|
bp: BroadPhase::new(),
|
|
np: NarrowPhase::new(),
|
|
ij: ImpulseJointSet::new(),
|
|
mj: MultibodyJointSet::new(),
|
|
ccd: CCDSolver::new(),
|
|
}
|
|
}
|
|
|
|
pub fn step(&mut self, t: f32, handler: &dyn EventHandler) {
|
|
self.ip.dt = t;
|
|
self.pp.step(
|
|
&vector![0.0, 0.0],
|
|
&self.ip,
|
|
&mut self.im,
|
|
&mut self.bp,
|
|
&mut self.np,
|
|
&mut self.rigid_body_set,
|
|
&mut self.collider_set,
|
|
&mut self.ij,
|
|
&mut self.mj,
|
|
&mut self.ccd,
|
|
None,
|
|
&(),
|
|
handler,
|
|
);
|
|
}
|
|
}
|