diff --git a/rapier/px.rs b/rapier/px.rs index 5abdb53..ec5c88d 100644 --- a/rapier/px.rs +++ b/rapier/px.rs @@ -11,7 +11,6 @@ use self::parry3d::query::*; use std::num::NonZeroUsize; use std::arch::asm; -#[derive(Default)] pub struct funnyphysics { rigid_body_set: RigidBodySet, collider_set: ColliderSet, @@ -23,23 +22,24 @@ pub struct funnyphysics { impulse_joint_set: ImpulseJointSet, multibody_joint_set: MultibodyJointSet, ccd_solver: CCDSolver, - query_pipeline: QueryPipeline, } #[unsafe(no_mangle)] pub unsafe extern "C" fn px_init() -> *mut funnyphysics { - let mut px = Box::new(funnyphysics::default()); - px.rigid_body_set=RigidBodySet::new(); - px.collider_set=ColliderSet::new(); + let mut px = Box::new(funnyphysics + { + rigid_body_set:RigidBodySet::new(), + collider_set:ColliderSet::new(), + + physics_pipeline : PhysicsPipeline::new(), + island_manager : IslandManager::new(), + broad_phase : DefaultBroadPhase::new(), + narrow_phase : NarrowPhase::new(), + impulse_joint_set : ImpulseJointSet::new(), + multibody_joint_set : MultibodyJointSet::new(), + ccd_solver : CCDSolver::new(), + }); - px.physics_pipeline = PhysicsPipeline::new(); - px.island_manager = IslandManager::new(); - px.broad_phase = DefaultBroadPhase::new(); - px.narrow_phase = NarrowPhase::new(); - px.impulse_joint_set = ImpulseJointSet::new(); - px.multibody_joint_set = MultibodyJointSet::new(); - px.ccd_solver = CCDSolver::new(); - px.query_pipeline = QueryPipeline::new(); return Box::into_raw(px); } @@ -66,7 +66,6 @@ pub unsafe extern "C" fn px_frame(px_world: *mut funnyphysics, delta:f32) { &mut px.impulse_joint_set, &mut px.multibody_joint_set, &mut px.ccd_solver, - Some(&mut px.query_pipeline), &physics_hooks, &event_handler, ); @@ -281,8 +280,13 @@ pub unsafe extern "C" fn px_box_cast(px_world: *mut funnyphysics, x:f32,y:f32,z: let shape_pos = Isometry { translation: Translation{vector: vector![pos.m[0],pos.m[1],pos.m[2]]}, rotation: Rotation::from_euler_angles(rot.m[0], rot.m[1], rot.m[2])}; let shape_vel=vector![vel.m[0],vel.m[1],vel.m[2]]; - if let Some((handle, hit)) = px.query_pipeline.cast_shape( - &px.rigid_body_set, &px.collider_set, &shape_pos, &shape_vel, &c, options, filter + if let Some((handle, hit)) = px.broad_phase.as_query_pipeline( + px.narrow_phase.query_dispatcher(), + &px.rigid_body_set, + &px.collider_set, + QueryFilter::default() + ).cast_shape( + &shape_pos, &shape_vel, &c, options, ) { res.time=hit.time_of_impact; res.normal1.m[0] = hit.normal1.x;