#[repr(C)]pub struct SCNPhysicsBody { /* private fields */ }SCNPhysicsBody only.Expand description
The SCNPhysicsBody class describes the physics properties (such as mass, friction…) of a node.
See also Apple’s documentation
Implementations§
Source§impl SCNPhysicsBody
impl SCNPhysicsBody
pub unsafe fn staticBody() -> Retained<Self>
pub unsafe fn dynamicBody() -> Retained<Self>
pub unsafe fn kinematicBody() -> Retained<Self>
pub unsafe fn bodyWithType_shape( type: SCNPhysicsBodyType, shape: Option<&SCNPhysicsShape>, ) -> Retained<Self>
SCNPhysicsShape only.pub unsafe fn type(&self) -> SCNPhysicsBodyType
Sourcepub unsafe fn setType(&self, type: SCNPhysicsBodyType)
pub unsafe fn setType(&self, type: SCNPhysicsBodyType)
Setter for type.
pub unsafe fn mass(&self) -> CGFloat
objc2-core-foundation only.Sourcepub unsafe fn setMass(&self, mass: CGFloat)
Available on crate feature objc2-core-foundation only.
pub unsafe fn setMass(&self, mass: CGFloat)
objc2-core-foundation only.Setter for mass.
pub unsafe fn momentOfInertia(&self) -> SCNVector3
SceneKitTypes and objc2-core-foundation only.Sourcepub unsafe fn setMomentOfInertia(&self, moment_of_inertia: SCNVector3)
Available on crate features SceneKitTypes and objc2-core-foundation only.
pub unsafe fn setMomentOfInertia(&self, moment_of_inertia: SCNVector3)
SceneKitTypes and objc2-core-foundation only.Setter for momentOfInertia.
pub unsafe fn usesDefaultMomentOfInertia(&self) -> bool
Sourcepub unsafe fn setUsesDefaultMomentOfInertia(
&self,
uses_default_moment_of_inertia: bool,
)
pub unsafe fn setUsesDefaultMomentOfInertia( &self, uses_default_moment_of_inertia: bool, )
Setter for usesDefaultMomentOfInertia.
pub unsafe fn charge(&self) -> CGFloat
objc2-core-foundation only.Sourcepub unsafe fn setCharge(&self, charge: CGFloat)
Available on crate feature objc2-core-foundation only.
pub unsafe fn setCharge(&self, charge: CGFloat)
objc2-core-foundation only.Setter for charge.
pub unsafe fn friction(&self) -> CGFloat
objc2-core-foundation only.Sourcepub unsafe fn setFriction(&self, friction: CGFloat)
Available on crate feature objc2-core-foundation only.
pub unsafe fn setFriction(&self, friction: CGFloat)
objc2-core-foundation only.Setter for friction.
pub unsafe fn restitution(&self) -> CGFloat
objc2-core-foundation only.Sourcepub unsafe fn setRestitution(&self, restitution: CGFloat)
Available on crate feature objc2-core-foundation only.
pub unsafe fn setRestitution(&self, restitution: CGFloat)
objc2-core-foundation only.Setter for restitution.
pub unsafe fn rollingFriction(&self) -> CGFloat
objc2-core-foundation only.Sourcepub unsafe fn setRollingFriction(&self, rolling_friction: CGFloat)
Available on crate feature objc2-core-foundation only.
pub unsafe fn setRollingFriction(&self, rolling_friction: CGFloat)
objc2-core-foundation only.Setter for rollingFriction.
pub unsafe fn physicsShape(&self) -> Option<Retained<SCNPhysicsShape>>
SCNPhysicsShape only.Sourcepub unsafe fn setPhysicsShape(&self, physics_shape: Option<&SCNPhysicsShape>)
Available on crate feature SCNPhysicsShape only.
pub unsafe fn setPhysicsShape(&self, physics_shape: Option<&SCNPhysicsShape>)
SCNPhysicsShape only.Setter for physicsShape.
pub unsafe fn isResting(&self) -> bool
pub unsafe fn allowsResting(&self) -> bool
Sourcepub unsafe fn setAllowsResting(&self, allows_resting: bool)
pub unsafe fn setAllowsResting(&self, allows_resting: bool)
Setter for allowsResting.
pub unsafe fn velocity(&self) -> SCNVector3
SceneKitTypes and objc2-core-foundation only.Sourcepub unsafe fn setVelocity(&self, velocity: SCNVector3)
Available on crate features SceneKitTypes and objc2-core-foundation only.
pub unsafe fn setVelocity(&self, velocity: SCNVector3)
SceneKitTypes and objc2-core-foundation only.Setter for velocity.
pub unsafe fn angularVelocity(&self) -> SCNVector4
SceneKitTypes and objc2-core-foundation only.Sourcepub unsafe fn setAngularVelocity(&self, angular_velocity: SCNVector4)
Available on crate features SceneKitTypes and objc2-core-foundation only.
pub unsafe fn setAngularVelocity(&self, angular_velocity: SCNVector4)
SceneKitTypes and objc2-core-foundation only.Setter for angularVelocity.
pub unsafe fn damping(&self) -> CGFloat
objc2-core-foundation only.Sourcepub unsafe fn setDamping(&self, damping: CGFloat)
Available on crate feature objc2-core-foundation only.
pub unsafe fn setDamping(&self, damping: CGFloat)
objc2-core-foundation only.Setter for damping.
pub unsafe fn angularDamping(&self) -> CGFloat
objc2-core-foundation only.Sourcepub unsafe fn setAngularDamping(&self, angular_damping: CGFloat)
Available on crate feature objc2-core-foundation only.
pub unsafe fn setAngularDamping(&self, angular_damping: CGFloat)
objc2-core-foundation only.Setter for angularDamping.
pub unsafe fn velocityFactor(&self) -> SCNVector3
SceneKitTypes and objc2-core-foundation only.Sourcepub unsafe fn setVelocityFactor(&self, velocity_factor: SCNVector3)
Available on crate features SceneKitTypes and objc2-core-foundation only.
pub unsafe fn setVelocityFactor(&self, velocity_factor: SCNVector3)
SceneKitTypes and objc2-core-foundation only.Setter for velocityFactor.
pub unsafe fn angularVelocityFactor(&self) -> SCNVector3
SceneKitTypes and objc2-core-foundation only.Sourcepub unsafe fn setAngularVelocityFactor(
&self,
angular_velocity_factor: SCNVector3,
)
Available on crate features SceneKitTypes and objc2-core-foundation only.
pub unsafe fn setAngularVelocityFactor( &self, angular_velocity_factor: SCNVector3, )
SceneKitTypes and objc2-core-foundation only.Setter for angularVelocityFactor.
pub unsafe fn categoryBitMask(&self) -> NSUInteger
Sourcepub unsafe fn setCategoryBitMask(&self, category_bit_mask: NSUInteger)
pub unsafe fn setCategoryBitMask(&self, category_bit_mask: NSUInteger)
Setter for categoryBitMask.
pub unsafe fn collisionBitMask(&self) -> NSUInteger
Sourcepub unsafe fn setCollisionBitMask(&self, collision_bit_mask: NSUInteger)
pub unsafe fn setCollisionBitMask(&self, collision_bit_mask: NSUInteger)
Setter for collisionBitMask.
pub unsafe fn contactTestBitMask(&self) -> NSUInteger
Sourcepub unsafe fn setContactTestBitMask(&self, contact_test_bit_mask: NSUInteger)
pub unsafe fn setContactTestBitMask(&self, contact_test_bit_mask: NSUInteger)
Setter for contactTestBitMask.
pub unsafe fn isAffectedByGravity(&self) -> bool
Sourcepub unsafe fn setAffectedByGravity(&self, affected_by_gravity: bool)
pub unsafe fn setAffectedByGravity(&self, affected_by_gravity: bool)
Setter for isAffectedByGravity.
pub unsafe fn applyForce_impulse(&self, direction: SCNVector3, impulse: bool)
SceneKitTypes and objc2-core-foundation only.pub unsafe fn applyForce_atPosition_impulse( &self, direction: SCNVector3, position: SCNVector3, impulse: bool, )
SceneKitTypes and objc2-core-foundation only.pub unsafe fn applyTorque_impulse(&self, torque: SCNVector4, impulse: bool)
SceneKitTypes and objc2-core-foundation only.pub unsafe fn clearAllForces(&self)
pub unsafe fn resetTransform(&self)
pub unsafe fn setResting(&self, resting: bool)
pub unsafe fn continuousCollisionDetectionThreshold(&self) -> CGFloat
objc2-core-foundation only.Sourcepub unsafe fn setContinuousCollisionDetectionThreshold(
&self,
continuous_collision_detection_threshold: CGFloat,
)
Available on crate feature objc2-core-foundation only.
pub unsafe fn setContinuousCollisionDetectionThreshold( &self, continuous_collision_detection_threshold: CGFloat, )
objc2-core-foundation only.Setter for continuousCollisionDetectionThreshold.
pub unsafe fn centerOfMassOffset(&self) -> SCNVector3
SceneKitTypes and objc2-core-foundation only.Sourcepub unsafe fn setCenterOfMassOffset(&self, center_of_mass_offset: SCNVector3)
Available on crate features SceneKitTypes and objc2-core-foundation only.
pub unsafe fn setCenterOfMassOffset(&self, center_of_mass_offset: SCNVector3)
SceneKitTypes and objc2-core-foundation only.Setter for centerOfMassOffset.
pub unsafe fn linearRestingThreshold(&self) -> CGFloat
objc2-core-foundation only.Sourcepub unsafe fn setLinearRestingThreshold(
&self,
linear_resting_threshold: CGFloat,
)
Available on crate feature objc2-core-foundation only.
pub unsafe fn setLinearRestingThreshold( &self, linear_resting_threshold: CGFloat, )
objc2-core-foundation only.Setter for linearRestingThreshold.
pub unsafe fn angularRestingThreshold(&self) -> CGFloat
objc2-core-foundation only.Sourcepub unsafe fn setAngularRestingThreshold(
&self,
angular_resting_threshold: CGFloat,
)
Available on crate feature objc2-core-foundation only.
pub unsafe fn setAngularRestingThreshold( &self, angular_resting_threshold: CGFloat, )
objc2-core-foundation only.Setter for angularRestingThreshold.
Methods from Deref<Target = NSObject>§
Sourcepub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
Handle messages the object doesn’t recognize.
See Apple’s documentation for details.
Methods from Deref<Target = AnyObject>§
Sourcepub fn class(&self) -> &'static AnyClass
pub fn class(&self) -> &'static AnyClass
Dynamically find the class of this object.
§Panics
May panic if the object is invalid (which may be the case for objects
returned from unavailable init/new methods).
§Example
Check that an instance of NSObject has the precise class NSObject.
use objc2::ClassType;
use objc2::runtime::NSObject;
let obj = NSObject::new();
assert_eq!(obj.class(), NSObject::class());Sourcepub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
👎Deprecated: this is difficult to use correctly, use Ivar::load instead.
pub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
Ivar::load instead.Use Ivar::load instead.
§Safety
The object must have an instance variable with the given name, and it
must be of type T.
See Ivar::load_ptr for details surrounding this.
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
Attempt to downcast the object to a class of type T.
This is the reference-variant. Use Retained::downcast if you want
to convert a retained object to another type.
§Mutable classes
Some classes have immutable and mutable variants, such as NSString
and NSMutableString.
When some Objective-C API signature says it gives you an immutable class, it generally expects you to not mutate that, even though it may technically be mutable “under the hood”.
So using this method to convert a NSString to a NSMutableString,
while not unsound, is generally frowned upon unless you created the
string yourself, or the API explicitly documents the string to be
mutable.
See Apple’s documentation on mutability and on
isKindOfClass: for more details.
§Generic classes
Objective-C generics are called “lightweight generics”, and that’s because they aren’t exposed in the runtime. This makes it impossible to safely downcast to generic collections, so this is disallowed by this method.
You can, however, safely downcast to generic collections where all the
type-parameters are AnyObject.
§Panics
This works internally by calling isKindOfClass:. That means that the
object must have the instance method of that name, and an exception
will be thrown (if CoreFoundation is linked) or the process will abort
if that is not the case. In the vast majority of cases, you don’t need
to worry about this, since both root objects NSObject and
NSProxy implement this method.
§Examples
Cast an NSString back and forth from NSObject.
use objc2::rc::Retained;
use objc2_foundation::{NSObject, NSString};
let obj: Retained<NSObject> = NSString::new().into_super();
let string = obj.downcast_ref::<NSString>().unwrap();
// Or with `downcast`, if we do not need the object afterwards
let string = obj.downcast::<NSString>().unwrap();Try (and fail) to cast an NSObject to an NSString.
use objc2_foundation::{NSObject, NSString};
let obj = NSObject::new();
assert!(obj.downcast_ref::<NSString>().is_none());Try to cast to an array of strings.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
// This is invalid and doesn't type check.
let arr = arr.downcast_ref::<NSArray<NSString>>();This fails to compile, since it would require enumerating over the array to ensure that each element is of the desired type, which is a performance pitfall.
Downcast when processing each element instead.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
for elem in arr {
if let Some(data) = elem.downcast_ref::<NSString>() {
// handle `data`
}
}Trait Implementations§
Source§impl AsRef<AnyObject> for SCNPhysicsBody
impl AsRef<AnyObject> for SCNPhysicsBody
Source§impl AsRef<NSObject> for SCNPhysicsBody
impl AsRef<NSObject> for SCNPhysicsBody
Source§impl AsRef<SCNPhysicsBody> for SCNPhysicsBody
impl AsRef<SCNPhysicsBody> for SCNPhysicsBody
Source§impl Borrow<AnyObject> for SCNPhysicsBody
impl Borrow<AnyObject> for SCNPhysicsBody
Source§impl Borrow<NSObject> for SCNPhysicsBody
impl Borrow<NSObject> for SCNPhysicsBody
Source§impl ClassType for SCNPhysicsBody
impl ClassType for SCNPhysicsBody
Source§const NAME: &'static str = "SCNPhysicsBody"
const NAME: &'static str = "SCNPhysicsBody"
Source§type ThreadKind = <<SCNPhysicsBody as ClassType>::Super as ClassType>::ThreadKind
type ThreadKind = <<SCNPhysicsBody as ClassType>::Super as ClassType>::ThreadKind
Source§impl CopyingHelper for SCNPhysicsBody
impl CopyingHelper for SCNPhysicsBody
Source§type Result = SCNPhysicsBody
type Result = SCNPhysicsBody
Self if the type has no
immutable counterpart. Read moreSource§impl Debug for SCNPhysicsBody
impl Debug for SCNPhysicsBody
Source§impl Deref for SCNPhysicsBody
impl Deref for SCNPhysicsBody
Source§impl Hash for SCNPhysicsBody
impl Hash for SCNPhysicsBody
Source§impl Message for SCNPhysicsBody
impl Message for SCNPhysicsBody
Source§impl NSCoding for SCNPhysicsBody
impl NSCoding for SCNPhysicsBody
Source§impl NSCopying for SCNPhysicsBody
impl NSCopying for SCNPhysicsBody
Source§impl NSObjectProtocol for SCNPhysicsBody
impl NSObjectProtocol for SCNPhysicsBody
Source§fn isEqual(&self, other: Option<&AnyObject>) -> bool
fn isEqual(&self, other: Option<&AnyObject>) -> bool
Source§fn hash(&self) -> usize
fn hash(&self) -> usize
Source§fn isKindOfClass(&self, cls: &AnyClass) -> bool
fn isKindOfClass(&self, cls: &AnyClass) -> bool
Source§fn is_kind_of<T>(&self) -> bool
fn is_kind_of<T>(&self) -> bool
isKindOfClass directly, or cast your objects with AnyObject::downcast_ref