pub struct PhysicsFoundationBuilder<Allocator: AllocatorCallback> { /* private fields */ }

Implementations§

source§

impl<Allocator: AllocatorCallback> PhysicsFoundationBuilder<Allocator>

source

pub fn new(allocator: Allocator) -> Self

source

pub fn enable_visual_debugger(&mut self, enable: bool) -> &mut Self

source

pub fn set_pvd_port(&mut self, pvd_port: i32) -> &mut Self

Set the port number for the visual debuggers transport. Default is 5425.

source

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.

source

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

source

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

source

pub fn with_extensions(&mut self, load: bool) -> &mut Self

Enable or disable extensions. Default is false.

source

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 _,
        );
    }
}
source

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
Hide additional 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 _,
        );
    }
}

Trait Implementations§

source§

impl Default for PhysicsFoundationBuilder<DefaultAllocator>

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<Allocator> RefUnwindSafe for PhysicsFoundationBuilder<Allocator>where Allocator: RefUnwindSafe,

§

impl<Allocator> !Send for PhysicsFoundationBuilder<Allocator>

§

impl<Allocator> !Sync for PhysicsFoundationBuilder<Allocator>

§

impl<Allocator> Unpin for PhysicsFoundationBuilder<Allocator>where Allocator: Unpin,

§

impl<Allocator> UnwindSafe for PhysicsFoundationBuilder<Allocator>where Allocator: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.