objc2_scene_kit/generated/
SCNPhysicsField.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12/// Specifies the domain of influence of a physics field.
13///
14/// See also [Apple's documentation](https://developer.apple.com/documentation/scenekit/scnphysicsfieldscope?language=objc)
15// NS_ENUM
16#[repr(transparent)]
17#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
18pub struct SCNPhysicsFieldScope(pub NSInteger);
19impl SCNPhysicsFieldScope {
20    #[doc(alias = "SCNPhysicsFieldScopeInsideExtent")]
21    pub const InsideExtent: Self = Self(0);
22    #[doc(alias = "SCNPhysicsFieldScopeOutsideExtent")]
23    pub const OutsideExtent: Self = Self(1);
24}
25
26unsafe impl Encode for SCNPhysicsFieldScope {
27    const ENCODING: Encoding = NSInteger::ENCODING;
28}
29
30unsafe impl RefEncode for SCNPhysicsFieldScope {
31    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
32}
33
34/// [Apple's documentation](https://developer.apple.com/documentation/scenekit/scnfieldforceevaluator?language=objc)
35#[cfg(all(
36    feature = "SceneKitTypes",
37    feature = "block2",
38    feature = "objc2-core-foundation"
39))]
40pub type SCNFieldForceEvaluator = *mut block2::DynBlock<
41    dyn Fn(SCNVector3, SCNVector3, c_float, c_float, NSTimeInterval) -> SCNVector3,
42>;
43
44extern_class!(
45    /// SCNPhysicsField is an abstract class that describes a force field that applies in the physics world.
46    ///
47    /// See also [Apple's documentation](https://developer.apple.com/documentation/scenekit/scnphysicsfield?language=objc)
48    #[unsafe(super(NSObject))]
49    #[derive(Debug, PartialEq, Eq, Hash)]
50    pub struct SCNPhysicsField;
51);
52
53extern_conformance!(
54    unsafe impl NSCoding for SCNPhysicsField {}
55);
56
57extern_conformance!(
58    unsafe impl NSCopying for SCNPhysicsField {}
59);
60
61unsafe impl CopyingHelper for SCNPhysicsField {
62    type Result = Self;
63}
64
65extern_conformance!(
66    unsafe impl NSObjectProtocol for SCNPhysicsField {}
67);
68
69extern_conformance!(
70    unsafe impl NSSecureCoding for SCNPhysicsField {}
71);
72
73impl SCNPhysicsField {
74    extern_methods!(
75        #[cfg(feature = "objc2-core-foundation")]
76        #[unsafe(method(strength))]
77        #[unsafe(method_family = none)]
78        pub unsafe fn strength(&self) -> CGFloat;
79
80        #[cfg(feature = "objc2-core-foundation")]
81        /// Setter for [`strength`][Self::strength].
82        #[unsafe(method(setStrength:))]
83        #[unsafe(method_family = none)]
84        pub unsafe fn setStrength(&self, strength: CGFloat);
85
86        #[cfg(feature = "objc2-core-foundation")]
87        #[unsafe(method(falloffExponent))]
88        #[unsafe(method_family = none)]
89        pub unsafe fn falloffExponent(&self) -> CGFloat;
90
91        #[cfg(feature = "objc2-core-foundation")]
92        /// Setter for [`falloffExponent`][Self::falloffExponent].
93        #[unsafe(method(setFalloffExponent:))]
94        #[unsafe(method_family = none)]
95        pub unsafe fn setFalloffExponent(&self, falloff_exponent: CGFloat);
96
97        #[cfg(feature = "objc2-core-foundation")]
98        #[unsafe(method(minimumDistance))]
99        #[unsafe(method_family = none)]
100        pub unsafe fn minimumDistance(&self) -> CGFloat;
101
102        #[cfg(feature = "objc2-core-foundation")]
103        /// Setter for [`minimumDistance`][Self::minimumDistance].
104        #[unsafe(method(setMinimumDistance:))]
105        #[unsafe(method_family = none)]
106        pub unsafe fn setMinimumDistance(&self, minimum_distance: CGFloat);
107
108        #[unsafe(method(isActive))]
109        #[unsafe(method_family = none)]
110        pub unsafe fn isActive(&self) -> bool;
111
112        /// Setter for [`isActive`][Self::isActive].
113        #[unsafe(method(setActive:))]
114        #[unsafe(method_family = none)]
115        pub unsafe fn setActive(&self, active: bool);
116
117        #[unsafe(method(isExclusive))]
118        #[unsafe(method_family = none)]
119        pub unsafe fn isExclusive(&self) -> bool;
120
121        /// Setter for [`isExclusive`][Self::isExclusive].
122        #[unsafe(method(setExclusive:))]
123        #[unsafe(method_family = none)]
124        pub unsafe fn setExclusive(&self, exclusive: bool);
125
126        #[cfg(all(feature = "SceneKitTypes", feature = "objc2-core-foundation"))]
127        #[unsafe(method(halfExtent))]
128        #[unsafe(method_family = none)]
129        pub unsafe fn halfExtent(&self) -> SCNVector3;
130
131        #[cfg(all(feature = "SceneKitTypes", feature = "objc2-core-foundation"))]
132        /// Setter for [`halfExtent`][Self::halfExtent].
133        #[unsafe(method(setHalfExtent:))]
134        #[unsafe(method_family = none)]
135        pub unsafe fn setHalfExtent(&self, half_extent: SCNVector3);
136
137        #[unsafe(method(usesEllipsoidalExtent))]
138        #[unsafe(method_family = none)]
139        pub unsafe fn usesEllipsoidalExtent(&self) -> bool;
140
141        /// Setter for [`usesEllipsoidalExtent`][Self::usesEllipsoidalExtent].
142        #[unsafe(method(setUsesEllipsoidalExtent:))]
143        #[unsafe(method_family = none)]
144        pub unsafe fn setUsesEllipsoidalExtent(&self, uses_ellipsoidal_extent: bool);
145
146        #[unsafe(method(scope))]
147        #[unsafe(method_family = none)]
148        pub unsafe fn scope(&self) -> SCNPhysicsFieldScope;
149
150        /// Setter for [`scope`][Self::scope].
151        #[unsafe(method(setScope:))]
152        #[unsafe(method_family = none)]
153        pub unsafe fn setScope(&self, scope: SCNPhysicsFieldScope);
154
155        #[cfg(all(feature = "SceneKitTypes", feature = "objc2-core-foundation"))]
156        #[unsafe(method(offset))]
157        #[unsafe(method_family = none)]
158        pub unsafe fn offset(&self) -> SCNVector3;
159
160        #[cfg(all(feature = "SceneKitTypes", feature = "objc2-core-foundation"))]
161        /// Setter for [`offset`][Self::offset].
162        #[unsafe(method(setOffset:))]
163        #[unsafe(method_family = none)]
164        pub unsafe fn setOffset(&self, offset: SCNVector3);
165
166        #[cfg(all(feature = "SceneKitTypes", feature = "objc2-core-foundation"))]
167        #[unsafe(method(direction))]
168        #[unsafe(method_family = none)]
169        pub unsafe fn direction(&self) -> SCNVector3;
170
171        #[cfg(all(feature = "SceneKitTypes", feature = "objc2-core-foundation"))]
172        /// Setter for [`direction`][Self::direction].
173        #[unsafe(method(setDirection:))]
174        #[unsafe(method_family = none)]
175        pub unsafe fn setDirection(&self, direction: SCNVector3);
176
177        /// Determines the node physicsBody's categories that will be influenced by the receiver. Defaults to all bit set.
178        #[unsafe(method(categoryBitMask))]
179        #[unsafe(method_family = none)]
180        pub unsafe fn categoryBitMask(&self) -> NSUInteger;
181
182        /// Setter for [`categoryBitMask`][Self::categoryBitMask].
183        #[unsafe(method(setCategoryBitMask:))]
184        #[unsafe(method_family = none)]
185        pub unsafe fn setCategoryBitMask(&self, category_bit_mask: NSUInteger);
186
187        /// Slows an object proportionally to the object’s velocity.
188        /// Use this to simulate effects such as friction from motion through the air.
189        #[unsafe(method(dragField))]
190        #[unsafe(method_family = none)]
191        pub unsafe fn dragField() -> Retained<SCNPhysicsField>;
192
193        /// Applies a force tangential to the direction from the sample point to the field's position.
194        /// The force will be CCW to the direction. Make the strength negative to apply force in the CW direction.
195        /// Amount is proportional to distance from center and the object's mass.
196        /// Use this to create effects such as tornadoes.
197        #[unsafe(method(vortexField))]
198        #[unsafe(method_family = none)]
199        pub unsafe fn vortexField() -> Retained<SCNPhysicsField>;
200
201        /// Applies a force in the direction of the origin of the field in local space. To repel objects, use a negative strength.
202        /// The force is proportional to the distance from the field origin. Varies with the mass of the object according to F = ma
203        /// The field node's rotation property can be used to orient the gravity in a particular direction.
204        #[unsafe(method(radialGravityField))]
205        #[unsafe(method_family = none)]
206        pub unsafe fn radialGravityField() -> Retained<SCNPhysicsField>;
207
208        /// Applies a force in the direction of the "direction" vector in the local space. To repel objects, use a negative strength.
209        /// The force is the same everywhere in the field. Varies with the mass of the object according to F = ma
210        /// The field node's rotation property can be used to orient the gravity in a particular direction.
211        #[unsafe(method(linearGravityField))]
212        #[unsafe(method_family = none)]
213        pub unsafe fn linearGravityField() -> Retained<SCNPhysicsField>;
214
215        #[cfg(feature = "objc2-core-foundation")]
216        /// A time varying differentiable Perlin simplex noise field. A smoothness of 0 means as noisy as possible.
217        /// Use this to simulate such effects as fireflies, or snow.
218        /// To freeze the noise in place, set animationSpeed to 0.0. Mass is ignored.
219        /// You can change the "smoothness" and "animationSpeed" using KVC.
220        #[unsafe(method(noiseFieldWithSmoothness:animationSpeed:))]
221        #[unsafe(method_family = none)]
222        pub unsafe fn noiseFieldWithSmoothness_animationSpeed(
223            smoothness: CGFloat,
224            speed: CGFloat,
225        ) -> Retained<SCNPhysicsField>;
226
227        #[cfg(feature = "objc2-core-foundation")]
228        /// Just like Noise, except the strength of the noise is proportional to the velocity of the object in the field.
229        #[unsafe(method(turbulenceFieldWithSmoothness:animationSpeed:))]
230        #[unsafe(method_family = none)]
231        pub unsafe fn turbulenceFieldWithSmoothness_animationSpeed(
232            smoothness: CGFloat,
233            speed: CGFloat,
234        ) -> Retained<SCNPhysicsField>;
235
236        /// A Hooke’s law force - a force linearly proportional to distance from the center of the field. An object in this
237        /// field will oscillate with a period proportional to the inverse of the mass.
238        /// An example use is to keep objects confined to a particular region.
239        #[unsafe(method(springField))]
240        #[unsafe(method_family = none)]
241        pub unsafe fn springField() -> Retained<SCNPhysicsField>;
242
243        /// A force proportional to the charge on the object. An example use of this field is to make objects behavior differently
244        /// from one another when they enter a region, or to make an object's behavior different than its mass based behavior
245        /// This field models the first part of the Lorentz equation, F = qE
246        #[unsafe(method(electricField))]
247        #[unsafe(method_family = none)]
248        pub unsafe fn electricField() -> Retained<SCNPhysicsField>;
249
250        /// A force proportional to the charge on the object and the object’s velocity.
251        /// An example use of this field is to make objects behavior differently from one another when they enter a region, or to make an object's behavior different than its mass based behavior
252        /// This field models the second part of the Lorentz equation, F = qvB
253        #[unsafe(method(magneticField))]
254        #[unsafe(method_family = none)]
255        pub unsafe fn magneticField() -> Retained<SCNPhysicsField>;
256
257        #[cfg(all(
258            feature = "SceneKitTypes",
259            feature = "block2",
260            feature = "objc2-core-foundation"
261        ))]
262        /// A field force with a custom force evaluator.
263        ///
264        /// # Safety
265        ///
266        /// `block` must be a valid pointer.
267        #[unsafe(method(customFieldWithEvaluationBlock:))]
268        #[unsafe(method_family = none)]
269        pub unsafe fn customFieldWithEvaluationBlock(
270            block: SCNFieldForceEvaluator,
271        ) -> Retained<SCNPhysicsField>;
272    );
273}
274
275/// Methods declared on superclass `NSObject`.
276impl SCNPhysicsField {
277    extern_methods!(
278        #[unsafe(method(init))]
279        #[unsafe(method_family = init)]
280        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
281
282        #[unsafe(method(new))]
283        #[unsafe(method_family = new)]
284        pub unsafe fn new() -> Retained<Self>;
285    );
286}