Skip to main content

Shape

Struct Shape 

Source
pub struct Shape {
Show 21 fields pub id: i32, pub body_id: i32, pub prev_shape_id: i32, pub next_shape_id: i32, pub sensor_index: i32, pub proxy_key: i32, pub density: f32, pub explosion_scale: f32, pub aabb_margin: f32, pub aabb: Aabb, pub fat_aabb: Aabb, pub local_centroid: Vec3, pub material: SurfaceMaterial, pub materials: Vec<SurfaceMaterial>, pub filter: Filter, pub user_data: u64, pub user_shape: u64, pub name_id: u32, pub generation: u16, pub flags: u8, pub geometry: ShapeGeometry,
}
Expand description

Internal shape. (b3Shape)

A single-material shape keeps its material inline. Multi-material meshes and compounds own a heap array in Self::materials. Reach materials the same way for both via Shape::shape_materials.

Fields§

§id: i32§body_id: i32§prev_shape_id: i32§next_shape_id: i32§sensor_index: i32§proxy_key: i32§density: f32§explosion_scale: f32§aabb_margin: f32§aabb: Aabb§fat_aabb: Aabb§local_centroid: Vec3§material: SurfaceMaterial

Inline material for single-material shapes.

§materials: Vec<SurfaceMaterial>

Heap materials for multi-material meshes/compounds. Empty means use Self::material as a one-element array (C: materials == NULL).

§filter: Filter§user_data: u64§user_shape: u64

Application user shape pointer (C: void* userShape).

§name_id: u32§generation: u16§flags: u8

shape_flags bits

§geometry: ShapeGeometry

The shape geometry (C: type tag + union).

Implementations§

Source§

impl Shape

Source

pub fn shape_type(&self) -> ShapeType

The shape type tag. (C: shape->type)

Source

pub fn material_count(&self) -> i32

Material count. Single-material shapes report 1. (C: materialCount)

Source

pub fn shape_materials(&self) -> &[SurfaceMaterial]

Materials slice. Single-material shapes present the inline material as a one-element view via this helper’s return of a temporary isn’t possible without an enum — callers should use Self::get_material or check materials emptiness. (b3GetShapeMaterials)

Source

pub fn get_material(&self, index: i32) -> &SurfaceMaterial

Material at index. (index into the materials array)

Source

pub fn shape_materials_mut(&mut self) -> &mut [SurfaceMaterial]

Mutable materials slice. (b3GetShapeMaterials writable)

Source

pub fn get_material_mut(&mut self, index: i32) -> &mut SurfaceMaterial

Mutable material at index.

Source

pub fn get_shape_user_material_id( &self, child_index: i32, triangle_index: i32, ) -> u64

User material id for a child/triangle of this shape. (b3GetShapeUserMaterialId)

C early-returns 0 when materialCount == 0; the Rust shape always presents at least the inline material, so that guard has no equivalent here.

Trait Implementations§

Source§

impl Clone for Shape

Source§

fn clone(&self) -> Shape

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Shape

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Shape

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl !Send for Shape

§

impl !Sync for Shape

§

impl Freeze for Shape

§

impl RefUnwindSafe for Shape

§

impl Unpin for Shape

§

impl UnsafeUnpin for Shape

§

impl UnwindSafe for Shape

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.