Struct physx::physics::PhysicsFoundationBuilder
source · pub struct PhysicsFoundationBuilder<Allocator: AllocatorCallback> { /* private fields */ }
Implementations§
source§impl<Allocator: AllocatorCallback> PhysicsFoundationBuilder<Allocator>
impl<Allocator: AllocatorCallback> PhysicsFoundationBuilder<Allocator>
pub fn new(allocator: Allocator) -> Self
pub fn enable_visual_debugger(&mut self, enable: bool) -> &mut Self
sourcepub fn set_pvd_port(&mut self, pvd_port: i32) -> &mut Self
pub fn set_pvd_port(&mut self, pvd_port: i32) -> &mut Self
Set the port number for the visual debuggers transport. Default is 5425.
sourcepub fn set_pvd_host(&mut self, pvd_host: impl Into<String>) -> &mut Self
pub fn set_pvd_host(&mut self, pvd_host: impl Into<String>) -> &mut Self
Set the port number for the visual debuggers transport. Default is 5425.
sourcepub fn set_length_tolerance(&mut self, length: f32) -> &mut Self
pub fn set_length_tolerance(&mut self, length: f32) -> &mut Self
Set the tolerance scale for lengths in the simulation. This should be approximately the ratio between the scale of simulation and one meter. For example, if a regular simulation object is 1 centimeter 100 is a good scale here.
Default: 1.0
sourcepub fn set_speed_tolerance(&mut self, speed: f32) -> &mut Self
pub fn set_speed_tolerance(&mut self, speed: f32) -> &mut Self
Set the tolerance scale for speeds in the simulation. This should be approximately the magnitude of speeds of simulation objects.
Default: 1.0
sourcepub fn with_extensions(&mut self, load: bool) -> &mut Self
pub fn with_extensions(&mut self, load: bool) -> &mut Self
Enable or disable extensions. Default is false
.
sourcepub fn with_error_callback<EC: ErrorCallback>(
&mut self,
error_callback: EC
) -> &mut Self
pub fn with_error_callback<EC: ErrorCallback>( &mut self, error_callback: EC ) -> &mut Self
Examples found in repository?
examples/error_callback.rs (line 20)
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
fn main() {
// Holds a PxFoundation and a PxPhysics.
// Also has an optional Pvd and transport, not enabled by default.
// The default allocator is the one provided by PhysX.
let mut builder = PhysicsFoundationBuilder::default();
builder.with_error_callback(ErrorCallback);
let mut physics: PhysicsFoundation<physx::foundation::DefaultAllocator, PxShape> =
builder.build().expect("a foundation being built");
#[allow(unsafe_code)]
// SAFETY: Invoking the underlying error reporting functions to demonstrate
// the error callback, this code is not part of the safe API since it is
// normally only invoked by the underlying SDK
unsafe {
let error_callback =
physx_sys::PxFoundation_getErrorCallback_mut(physics.foundation_mut().as_mut_ptr());
let msg = CString::new("this is just a warning").unwrap();
let file = CString::new(file!()).unwrap();
physx_sys::PxErrorCallback_reportError_mut(
error_callback,
PxErrorCode::DebugWarning,
msg.as_ptr(),
file.as_ptr(),
line!() as _,
);
let msg = CString::new("this is an invalid operation").unwrap();
physx_sys::PxErrorCallback_reportError_mut(
error_callback,
PxErrorCode::InvalidOperation,
msg.as_ptr(),
file.as_ptr(),
line!() as _,
);
}
}
sourcepub fn build<Geom: Shape>(self) -> Option<PhysicsFoundation<Allocator, Geom>>
pub fn build<Geom: Shape>(self) -> Option<PhysicsFoundation<Allocator, Geom>>
Build the PhysicsFoundation.
Examples found in repository?
examples/assert_handler.rs (line 22)
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
fn main() {
// Holds a PxFoundation and a PxPhysics.
// Also has an optional Pvd and transport, not enabled by default.
// The default allocator is the one provided by PhysX.
let builder = PhysicsFoundationBuilder::default();
let mut physics: PhysicsFoundation<physx::foundation::DefaultAllocator, PxShape> =
builder.build().expect("a foundation being built");
physics.set_assert_handler(AssertHandler);
#[allow(unsafe_code)]
// SAFETY: Calling assertion handlers explicitly since they are not part of
// of the safe API of physx since they are only normally called from within
// the SDK itself
unsafe {
let assert_handler = physx_sys::phys_PxGetAssertHandler();
let expr = CString::new("1 != 2").unwrap();
let file = CString::new(file!()).unwrap();
let mut should_ignore = false;
physx_sys::PxAssertHandler_opCall_mut(
assert_handler,
expr.as_ptr(),
file.as_ptr(),
line!() as _,
&mut should_ignore as *mut _,
);
let expr = CString::new("false").unwrap();
physx_sys::PxAssertHandler_opCall_mut(
assert_handler,
expr.as_ptr(),
file.as_ptr(),
line!() as _,
&mut should_ignore as *mut _,
);
}
}
More examples
examples/error_callback.rs (line 22)
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
fn main() {
// Holds a PxFoundation and a PxPhysics.
// Also has an optional Pvd and transport, not enabled by default.
// The default allocator is the one provided by PhysX.
let mut builder = PhysicsFoundationBuilder::default();
builder.with_error_callback(ErrorCallback);
let mut physics: PhysicsFoundation<physx::foundation::DefaultAllocator, PxShape> =
builder.build().expect("a foundation being built");
#[allow(unsafe_code)]
// SAFETY: Invoking the underlying error reporting functions to demonstrate
// the error callback, this code is not part of the safe API since it is
// normally only invoked by the underlying SDK
unsafe {
let error_callback =
physx_sys::PxFoundation_getErrorCallback_mut(physics.foundation_mut().as_mut_ptr());
let msg = CString::new("this is just a warning").unwrap();
let file = CString::new(file!()).unwrap();
physx_sys::PxErrorCallback_reportError_mut(
error_callback,
PxErrorCode::DebugWarning,
msg.as_ptr(),
file.as_ptr(),
line!() as _,
);
let msg = CString::new("this is an invalid operation").unwrap();
physx_sys::PxErrorCallback_reportError_mut(
error_callback,
PxErrorCode::InvalidOperation,
msg.as_ptr(),
file.as_ptr(),
line!() as _,
);
}
}