use crate::physics;
use crate::physics::{EventQueue, RapierConfiguration};
use bevy::prelude::*;
use rapier::dynamics::{IntegrationParameters, JointSet, RigidBodySet};
use rapier::geometry::{BroadPhase, ColliderSet, NarrowPhase};
use rapier::pipeline::PhysicsPipeline;
pub struct RapierPhysicsPlugin;
impl Plugin for RapierPhysicsPlugin {
fn build(&self, app: &mut AppBuilder) {
app.add_resource(PhysicsPipeline::new())
.add_resource(RapierConfiguration::default())
.add_resource(IntegrationParameters::default())
.add_resource(BroadPhase::new())
.add_resource(NarrowPhase::new())
.add_resource(RigidBodySet::new())
.add_resource(ColliderSet::new())
.add_resource(JointSet::new())
.add_resource(EventQueue::new(true))
.add_system_to_stage_front(
stage::PRE_UPDATE,
physics::create_body_and_collider_system.system(),
)
.add_system_to_stage(stage::PRE_UPDATE, physics::create_joints_system.system())
.add_system_to_stage(stage::UPDATE, physics::step_world_system.system())
.add_system_to_stage(stage::POST_UPDATE, physics::sync_transform_system.system());
}
}