pub struct SceneDescriptor<U, L: ArticulationLink, S: RigidStatic, D: RigidDynamic, C: ArticulationReducedCoordinate, OC: CollisionCallback, OT: TriggerCallback, OCB: ConstraintBreakCallback, OWS: WakeSleepCallback<L, S, D>, OA: AdvanceCallback<L, D>> {
Show 40 fields pub phantom_marker: PhantomData<(L, S, D, C)>, pub user_data: U, pub on_collide: Option<OC>, pub on_trigger: Option<OT>, pub on_constraint_break: Option<OCB>, pub on_wake_sleep: Option<OWS>, pub on_advance: Option<OA>, pub gravity: PxVec3, pub kine_kine_filtering_mode: PairFilteringMode, pub static_kine_filtering_mode: PairFilteringMode, pub broad_phase_type: BroadPhaseType, pub limits: SceneLimits, pub friction_type: FrictionType, pub solver_type: SolverType, pub bounce_threshold_velocity: f32, pub friction_offset_threshold: f32, pub ccd_max_separation: f32, pub flags: SceneFlags, pub static_structure: PruningStructureType, pub dynamic_structure: PruningStructureType, pub dynamic_tree_rebuild_rate_hint: u32, pub scene_query_update_mode: SceneQueryUpdateMode, pub solver_batch_size: u32, pub solver_articulation_batch_size: u32, pub nb_contact_data_blocks: u32, pub max_nb_contact_data_blocks: u32, pub max_bias_coefficient: f32, pub contact_report_stream_buffer_size: u32, pub ccd_max_passes: u32, pub ccd_threshold: f32, pub wake_counter_reset_value: f32, pub sanity_bounds: PxBounds3, pub simulation_filter_shader: FilterShaderDescriptor, pub thread_count: u32, pub broad_phase_callback: *mut PxBroadPhaseCallback, pub contact_modify_callback: *mut PxContactModifyCallback, pub ccd_contact_modify_callback: *mut PxCCDContactModifyCallback, pub gpu_dynamics_config: PxgDynamicsMemoryConfig, pub gpu_max_num_partitions: u32, pub gpu_compute_version: u32,
}

Fields§

§phantom_marker: PhantomData<(L, S, D, C)>§user_data: U§on_collide: Option<OC>§on_trigger: Option<OT>§on_constraint_break: Option<OCB>§on_wake_sleep: Option<OWS>§on_advance: Option<OA>§gravity: PxVec3§kine_kine_filtering_mode: PairFilteringMode§static_kine_filtering_mode: PairFilteringMode§broad_phase_type: BroadPhaseType§limits: SceneLimits§friction_type: FrictionType§solver_type: SolverType§bounce_threshold_velocity: f32§friction_offset_threshold: f32§ccd_max_separation: f32§flags: SceneFlags§static_structure: PruningStructureType§dynamic_structure: PruningStructureType§dynamic_tree_rebuild_rate_hint: u32§scene_query_update_mode: SceneQueryUpdateMode§solver_batch_size: u32§solver_articulation_batch_size: u32§nb_contact_data_blocks: u32§max_nb_contact_data_blocks: u32§max_bias_coefficient: f32§contact_report_stream_buffer_size: u32§ccd_max_passes: u32§ccd_threshold: f32§wake_counter_reset_value: f32§sanity_bounds: PxBounds3§simulation_filter_shader: FilterShaderDescriptor§thread_count: u32§broad_phase_callback: *mut PxBroadPhaseCallback§contact_modify_callback: *mut PxContactModifyCallback§ccd_contact_modify_callback: *mut PxCCDContactModifyCallback§gpu_dynamics_config: PxgDynamicsMemoryConfig§gpu_max_num_partitions: u32§gpu_compute_version: u32

Implementations§

source§

impl<U, L: ArticulationLink, S: RigidStatic, D: RigidDynamic, C: ArticulationReducedCoordinate, OC: CollisionCallback, OT: TriggerCallback, OCB: ConstraintBreakCallback, OWS: WakeSleepCallback<L, S, D>, OA: AdvanceCallback<L, D>> SceneDescriptor<U, L, S, D, C, OC, OT, OCB, OWS, OA>

source

pub fn new(user_data: U) -> Self

Examples found in repository?
examples/profiler.rs (line 114)
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
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 physics = PhysicsFoundation::<_, PxShape>::default();

    physics.set_profiler(PrintProfilerCallback {
        start: std::time::Instant::now(),
    });
    // Setup the scene object.  The PxScene type alias makes this much cleaner.
    // There are lots of unwrap calls due to potential null pointers.
    let mut scene: Owner<PxScene> = physics
        .create(SceneDescriptor {
            gravity: PxVec3::new(0.0, -9.81, 0.0),
            on_advance: Some(OnAdvance),
            ..SceneDescriptor::new(())
        })
        .unwrap();

    let mut material = physics.create_material(0.5, 0.5, 0.6, ()).unwrap();

    let ground_plane = physics
        .create_plane(PxVec3::new(0.0, 1.0, 0.0), 0.0, material.as_mut(), ())
        .unwrap();
    // The scene owns actors that are added to it.  They can be retrieved using the
    // various getters on the scene.
    scene.add_static_actor(ground_plane);

    let sphere_geo = PxSphereGeometry::new(10.0);

    let mut sphere_actor = physics
        .create_rigid_dynamic(
            PxTransform::from_translation(&PxVec3::new(0.0, 40.0, 100.0)),
            &sphere_geo,
            material.as_mut(),
            10.0,
            PxTransform::default(),
            (),
        )
        .unwrap();
    sphere_actor.set_angular_damping(0.5);
    sphere_actor.set_rigid_body_flag(RigidBodyFlag::EnablePoseIntegrationPreview, true);
    scene.add_dynamic_actor(sphere_actor);

    for _ in 0..100 {
        #[allow(unsafe_code)]
        // SAFETY: it's unsafe /shrug
        let mut sb = unsafe { ScratchBuffer::new(4) };

        // Calls both simulate and fetch_results.  More complex simulation update
        // controls are not fully supported.
        scene
            .step(0.1, None::<&mut physx_sys::PxBaseTask>, Some(&mut sb), true)
            .expect("error occured during simulation");
    }
}
More examples
Hide additional examples
examples/ball_physx.rs (line 89)
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
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 physics = PhysicsFoundation::<_, PxShape>::default();

    // Setup the scene object.  The PxScene type alias makes this much cleaner.
    // There are lots of unwrap calls due to potential null pointers.
    let mut scene: Owner<PxScene> = physics
        .create(SceneDescriptor {
            gravity: PxVec3::new(0.0, -9.81, 0.0),
            on_advance: Some(OnAdvance),
            ..SceneDescriptor::new(())
        })
        .unwrap();

    let mut material = physics.create_material(0.5, 0.5, 0.6, ()).unwrap();

    let ground_plane = physics
        .create_plane(PxVec3::new(0.0, 1.0, 0.0), 0.0, material.as_mut(), ())
        .unwrap();
    // The scene owns actors that are added to it.  They can be retrieved using the
    // various getters on the scene.
    scene.add_static_actor(ground_plane);

    let sphere_geo = PxSphereGeometry::new(10.0);

    let mut sphere_actor = physics
        .create_rigid_dynamic(
            PxTransform::from_translation(&PxVec3::new(0.0, 40.0, 100.0)),
            &sphere_geo,
            material.as_mut(),
            10.0,
            PxTransform::default(),
            (),
        )
        .unwrap();
    sphere_actor.set_angular_damping(0.5);
    sphere_actor.set_rigid_body_flag(RigidBodyFlag::EnablePoseIntegrationPreview, true);
    scene.add_dynamic_actor(sphere_actor);

    // SAFETY: scratch buffer creation
    #[allow(unsafe_code)]
    let mut scratch = unsafe { ScratchBuffer::new(4) };

    // Updating
    let heights_over_time = (0..100)
        .map(|_| {
            // Calls both simulate and fetch_results.  More complex simulation update
            // controls are not fully supported.
            scene
                .step(
                    0.1,
                    None::<&mut physx_sys::PxBaseTask>,
                    Some(&mut scratch),
                    true,
                )
                .expect("error occured during simulation");
            // For simplicity, just read out the only dynamic actor in the scene.
            // getActiveActors is also supported, it returns a Vec<&mut ActorMap> which has
            // a map method that takes a function for each actor type, and `as_<T>` methods
            // that return an Option<&mut T>.
            let actors = scene.get_dynamic_actors();
            actors[0].get_global_position().y() as i32 - 10
        })
        .collect::<Vec<_>>();

    // Draw to stdout
    let max_h = 18;
    (0..max_h)
        .map(|h| {
            let h = max_h - 1 - h;
            heights_over_time
                .iter()
                .enumerate()
                .map(|(_t, p)| if h == *p { 'o' } else { ' ' })
                .collect::<String>()
        })
        .for_each(|line| println!("{}", line));
}

Trait Implementations§

source§

impl<P: Physics, U, L: ArticulationLink, S: RigidStatic, D: RigidDynamic, C: ArticulationReducedCoordinate, OC: CollisionCallback, OT: TriggerCallback, OCB: ConstraintBreakCallback, OWS: WakeSleepCallback<L, S, D>, OA: AdvanceCallback<L, D>> Descriptor<P> for SceneDescriptor<U, L, S, D, C, OC, OT, OCB, OWS, OA>

§

type Target = Option<Owner<PxScene<U, L, S, D, C, OC, OT, OCB, OWS, OA>>>

source§

fn create(self, creator: &mut P) -> Self::Target

Auto Trait Implementations§

§

impl<U, L, S, D, C, OC, OT, OCB, OWS, OA> RefUnwindSafe for SceneDescriptor<U, L, S, D, C, OC, OT, OCB, OWS, OA>where C: RefUnwindSafe, D: RefUnwindSafe, L: RefUnwindSafe, OA: RefUnwindSafe, OC: RefUnwindSafe, OCB: RefUnwindSafe, OT: RefUnwindSafe, OWS: RefUnwindSafe, S: RefUnwindSafe, U: RefUnwindSafe,

§

impl<U, L, S, D, C, OC, OT, OCB, OWS, OA> !Send for SceneDescriptor<U, L, S, D, C, OC, OT, OCB, OWS, OA>

§

impl<U, L, S, D, C, OC, OT, OCB, OWS, OA> !Sync for SceneDescriptor<U, L, S, D, C, OC, OT, OCB, OWS, OA>

§

impl<U, L, S, D, C, OC, OT, OCB, OWS, OA> Unpin for SceneDescriptor<U, L, S, D, C, OC, OT, OCB, OWS, OA>where C: Unpin, D: Unpin, L: Unpin, OA: Unpin, OC: Unpin, OCB: Unpin, OT: Unpin, OWS: Unpin, S: Unpin, U: Unpin,

§

impl<U, L, S, D, C, OC, OT, OCB, OWS, OA> UnwindSafe for SceneDescriptor<U, L, S, D, C, OC, OT, OCB, OWS, OA>where C: UnwindSafe, D: UnwindSafe, L: UnwindSafe, OA: UnwindSafe, OC: UnwindSafe, OCB: UnwindSafe, OT: UnwindSafe, OWS: UnwindSafe, S: UnwindSafe, U: 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.