#![allow(
unsafe_code,
non_upper_case_globals,
non_camel_case_types,
non_snake_case,
clippy::doc_markdown, // TODO: fixup comments and docs (though annoyingly complains about "PhysX")
clippy::unreadable_literal,
clippy::unused_unit,
clippy::upper_case_acronyms
)]
#[cfg(feature = "structgen")]
include!(concat!(env!("OUT_DIR"), "/structgen_out.rs"));
#[cfg(all(
not(feature = "structgen"),
target_os = "linux",
target_arch = "x86_64",
))]
include!("generated/unix/structgen.rs");
#[cfg(all(
not(feature = "structgen"),
target_os = "linux",
target_arch = "aarch64",
))]
include!("generated/unix/structgen.rs");
#[cfg(all(
not(feature = "structgen"),
target_os = "android",
target_arch = "x86_64",
))]
include!("generated/unix/structgen.rs");
#[cfg(all(
not(feature = "structgen"),
target_os = "android",
target_arch = "aarch64",
))]
include!("generated/unix/structgen.rs");
#[cfg(all(
not(feature = "structgen"),
target_os = "macos",
target_arch = "x86_64",
))]
include!("generated/unix/structgen.rs");
#[cfg(all(
not(feature = "structgen"),
target_os = "macos",
target_arch = "aarch64",
))]
include!("generated/unix/structgen.rs");
#[cfg(all(
not(feature = "structgen"),
target_os = "windows",
target_arch = "x86_64",
target_env = "msvc",
))]
include!("generated/x86_64-pc-windows-msvc/structgen.rs");
include!("physx_generated.rs");
use std::ffi::c_void;
pub const fn version(major: u32, minor: u32, patch: u32) -> u32 {
(major << 24) + (minor << 16) + (patch << 8)
}
pub type CollisionCallback =
unsafe extern "C" fn(*mut c_void, *const PxContactPairHeader, *const PxContactPair, u32);
pub type TriggerCallback = unsafe extern "C" fn(*mut c_void, *const PxTriggerPair, u32);
pub type ConstraintBreakCallback = unsafe extern "C" fn(*mut c_void, *const PxConstraintInfo, u32);
pub type WakeSleepCallback = unsafe extern "C" fn(*mut c_void, *const *const PxActor, u32, bool);
pub type AdvanceCallback =
unsafe extern "C" fn(*mut c_void, *const *const PxRigidBody, *const PxTransform, u32);
#[repr(C)]
pub struct SimulationEventCallbackInfo {
pub collision_callback: Option<CollisionCallback>,
pub collision_user_data: *mut c_void,
pub trigger_callback: Option<TriggerCallback>,
pub trigger_user_data: *mut c_void,
pub constraint_break_callback: Option<ConstraintBreakCallback>,
pub constraint_break_user_data: *mut c_void,
pub wake_sleep_callback: Option<WakeSleepCallback>,
pub wake_sleep_user_data: *mut c_void,
pub advance_callback: Option<AdvanceCallback>,
pub advance_user_data: *mut c_void,
}
impl Default for SimulationEventCallbackInfo {
fn default() -> Self {
Self {
collision_callback: None,
collision_user_data: std::ptr::null_mut(),
trigger_callback: None,
trigger_user_data: std::ptr::null_mut(),
constraint_break_callback: None,
constraint_break_user_data: std::ptr::null_mut(),
wake_sleep_callback: None,
wake_sleep_user_data: std::ptr::null_mut(),
advance_callback: None,
advance_user_data: std::ptr::null_mut(),
}
}
}
pub type RaycastHitCallback = unsafe extern "C" fn(
*const PxRigidActor,
*const PxFilterData,
*const PxShape,
hit_flags: u32,
*const c_void,
) -> PxQueryHitType;
pub type PostFilterCallback =
unsafe extern "C" fn(*const PxFilterData, *const PxQueryHit, *const c_void) -> PxQueryHitType;
#[repr(C)]
pub struct FilterShaderCallbackInfo {
pub attributes0: u32,
pub attributes1: u32,
pub filterData0: PxFilterData,
pub filterData1: PxFilterData,
pub pairFlags: *mut PxPairFlags,
pub constantBlock: *const std::ffi::c_void,
pub constantBlockSize: u32,
}
pub type SimulationFilterShader =
unsafe extern "C" fn(*mut FilterShaderCallbackInfo) -> PxFilterFlags;
pub type RaycastProcessTouchesCallback =
unsafe extern "C" fn(*const PxRaycastHit, u32, *mut c_void) -> bool;
pub type SweepProcessTouchesCallback =
unsafe extern "C" fn(*const PxSweepHit, u32, *mut c_void) -> bool;
pub type OverlapProcessTouchesCallback =
unsafe extern "C" fn(*const PxOverlapHit, u32, *mut c_void) -> bool;
pub type FinalizeQueryCallback = unsafe extern "C" fn(*mut c_void);
pub type AllocCallback =
unsafe extern "C" fn(u64, *const c_void, *const c_void, u32, *const c_void) -> *mut c_void;
pub type DeallocCallback = unsafe extern "C" fn(*const c_void, *const c_void);
pub type ZoneStartCallback =
unsafe extern "C" fn(*const i8, bool, u64, *const c_void) -> *mut c_void;
pub type ZoneEndCallback = unsafe extern "C" fn(*const c_void, *const i8, bool, u64, *const c_void);
pub type ErrorCallback =
unsafe extern "C" fn(PxErrorCode, *const i8, *const i8, u32, *const c_void);
pub type AssertHandler = unsafe extern "C" fn(*const i8, *const i8, u32, *mut bool, *const c_void);
extern "C" {
pub fn physx_create_foundation() -> *mut PxFoundation;
pub fn physx_create_foundation_with_alloc(
allocator: *mut PxDefaultAllocator,
) -> *mut PxFoundation;
pub fn physx_create_physics(foundation: *mut PxFoundation) -> *mut PxPhysics;
pub fn get_default_allocator() -> *mut PxDefaultAllocator;
pub fn get_default_error_callback() -> *mut PxDefaultErrorCallback;
pub fn create_raycast_filter_callback(
actor_to_ignore: *const PxRigidActor,
) -> *mut PxQueryFilterCallback;
pub fn create_raycast_filter_callback_func(
callback: RaycastHitCallback,
userdata: *mut c_void,
) -> *mut PxQueryFilterCallback;
pub fn create_pre_and_post_raycast_filter_callback_func(
preFilter: RaycastHitCallback,
postFilter: PostFilterCallback,
userdata: *mut c_void,
) -> *mut PxQueryFilterCallback;
pub fn create_raycast_buffer() -> *mut PxRaycastCallback;
pub fn create_sweep_buffer() -> *mut PxSweepCallback;
pub fn create_overlap_buffer() -> *mut PxOverlapCallback;
pub fn create_raycast_callback(
process_touches_callback: RaycastProcessTouchesCallback,
finalize_query_callback: FinalizeQueryCallback,
touches_buffer: *mut PxRaycastHit,
num_touches: u32,
userdata: *mut c_void,
) -> *mut PxRaycastCallback;
pub fn create_sweep_callback(
process_touches_callback: SweepProcessTouchesCallback,
finalize_query_callback: FinalizeQueryCallback,
touches_buffer: *mut PxSweepHit,
num_touches: u32,
userdata: *mut c_void,
) -> *mut PxSweepCallback;
pub fn create_overlap_callback(
process_touches_callback: OverlapProcessTouchesCallback,
finalize_query_callback: FinalizeQueryCallback,
touches_buffer: *mut PxOverlapHit,
num_touches: u32,
userdata: *mut c_void,
) -> *mut PxOverlapCallback;
pub fn delete_raycast_callback(callback: *mut PxRaycastCallback);
pub fn delete_sweep_callback(callback: *mut PxSweepCallback);
pub fn delete_overlap_callback(callback: *mut PxOverlapCallback);
pub fn create_alloc_callback(
alloc_callback: AllocCallback,
dealloc_callback: DeallocCallback,
userdata: *mut c_void,
) -> *mut PxAllocatorCallback;
pub fn create_profiler_callback(
zone_start_callback: ZoneStartCallback,
zone_end_callback: ZoneEndCallback,
userdata: *mut c_void,
) -> *mut PxProfilerCallback;
pub fn get_alloc_callback_user_data(alloc_callback: *mut PxAllocatorCallback) -> *mut c_void;
pub fn create_error_callback(
error_callback: ErrorCallback,
userdata: *mut c_void,
) -> *mut PxErrorCallback;
pub fn create_assert_handler(
error_callback: AssertHandler,
userdata: *mut c_void,
) -> *mut PxAssertHandler;
pub fn get_default_simulation_filter_shader() -> *mut c_void;
#[deprecated]
pub fn create_contact_callback(
callback: CollisionCallback,
userdata: *mut c_void,
) -> *mut PxSimulationEventCallback;
#[deprecated()]
pub fn destroy_contact_callback(callback: *mut PxSimulationEventCallback);
pub fn create_simulation_event_callbacks(
callbacks: *const SimulationEventCallbackInfo,
) -> *mut PxSimulationEventCallback;
pub fn get_simulation_event_info(
callback: *mut PxSimulationEventCallback,
) -> *mut SimulationEventCallbackInfo;
pub fn destroy_simulation_event_callbacks(callback: *mut PxSimulationEventCallback);
pub fn enable_custom_filter_shader(
scene_desc: *mut PxSceneDesc,
shader: SimulationFilterShader,
call_default_filter_shader_first: u32,
);
#[doc(hidden)]
pub fn PxAssertHandler_opCall_mut(
self_: *mut PxAssertHandler,
expr: *const i8,
file: *const i8,
line: i32,
ignore: *mut bool,
) -> ();
}