updated rapier.rs to 0.28
This commit is contained in:
36
rapier/px.rs
36
rapier/px.rs
@@ -11,7 +11,6 @@ use self::parry3d::query::*;
|
|||||||
use std::num::NonZeroUsize;
|
use std::num::NonZeroUsize;
|
||||||
use std::arch::asm;
|
use std::arch::asm;
|
||||||
|
|
||||||
#[derive(Default)]
|
|
||||||
pub struct funnyphysics {
|
pub struct funnyphysics {
|
||||||
rigid_body_set: RigidBodySet,
|
rigid_body_set: RigidBodySet,
|
||||||
collider_set: ColliderSet,
|
collider_set: ColliderSet,
|
||||||
@@ -23,23 +22,24 @@ pub struct funnyphysics {
|
|||||||
impulse_joint_set: ImpulseJointSet,
|
impulse_joint_set: ImpulseJointSet,
|
||||||
multibody_joint_set: MultibodyJointSet,
|
multibody_joint_set: MultibodyJointSet,
|
||||||
ccd_solver: CCDSolver,
|
ccd_solver: CCDSolver,
|
||||||
query_pipeline: QueryPipeline,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unsafe(no_mangle)]
|
#[unsafe(no_mangle)]
|
||||||
pub unsafe extern "C" fn px_init() -> *mut funnyphysics {
|
pub unsafe extern "C" fn px_init() -> *mut funnyphysics {
|
||||||
let mut px = Box::new(funnyphysics::default());
|
let mut px = Box::new(funnyphysics
|
||||||
px.rigid_body_set=RigidBodySet::new();
|
{
|
||||||
px.collider_set=ColliderSet::new();
|
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);
|
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.impulse_joint_set,
|
||||||
&mut px.multibody_joint_set,
|
&mut px.multibody_joint_set,
|
||||||
&mut px.ccd_solver,
|
&mut px.ccd_solver,
|
||||||
Some(&mut px.query_pipeline),
|
|
||||||
&physics_hooks,
|
&physics_hooks,
|
||||||
&event_handler,
|
&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_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]];
|
let shape_vel=vector![vel.m[0],vel.m[1],vel.m[2]];
|
||||||
|
|
||||||
if let Some((handle, hit)) = px.query_pipeline.cast_shape(
|
if let Some((handle, hit)) = px.broad_phase.as_query_pipeline(
|
||||||
&px.rigid_body_set, &px.collider_set, &shape_pos, &shape_vel, &c, options, filter
|
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.time=hit.time_of_impact;
|
||||||
res.normal1.m[0] = hit.normal1.x;
|
res.normal1.m[0] = hit.normal1.x;
|
||||||
|
|||||||
Reference in New Issue
Block a user