1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
#[cfg(feature = "objc2-core-graphics")]
use objc2_core_graphics::*;
use objc2_foundation::*;
use crate::*;
extern_class!(
/// A SpriteKit physics body. These are the physical representations of your nodes. These specify the area and mass and any collision masking needed.
///
/// All bodies have zero, one or more shapes that define its area. A body with no shapes is ethereal and does not collide with other bodies.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/spritekit/skphysicsbody?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct SKPhysicsBody;
);
extern_conformance!(
unsafe impl NSCoding for SKPhysicsBody {}
);
extern_conformance!(
unsafe impl NSCopying for SKPhysicsBody {}
);
unsafe impl CopyingHelper for SKPhysicsBody {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for SKPhysicsBody {}
);
extern_conformance!(
unsafe impl NSSecureCoding for SKPhysicsBody {}
);
impl SKPhysicsBody {
extern_methods!(
#[cfg(feature = "objc2-core-foundation")]
/// Creates a circle of radius r centered at the node's origin.
///
/// Parameter `r`: the radius in points
#[unsafe(method(bodyWithCircleOfRadius:))]
#[unsafe(method_family = none)]
pub unsafe fn bodyWithCircleOfRadius(r: CGFloat) -> Retained<SKPhysicsBody>;
#[cfg(feature = "objc2-core-foundation")]
/// Creates a circle of radius r centered at a point in the node's coordinate space.
///
/// Parameter `r`: the radius in points
#[unsafe(method(bodyWithCircleOfRadius:center:))]
#[unsafe(method_family = none)]
pub unsafe fn bodyWithCircleOfRadius_center(
r: CGFloat,
center: CGPoint,
) -> Retained<SKPhysicsBody>;
#[cfg(feature = "objc2-core-foundation")]
/// Creates a rectangle of the specified size centered at the node's origin.
///
/// Parameter `s`: the size in points
#[unsafe(method(bodyWithRectangleOfSize:))]
#[unsafe(method_family = none)]
pub unsafe fn bodyWithRectangleOfSize(s: CGSize) -> Retained<SKPhysicsBody>;
#[cfg(feature = "objc2-core-foundation")]
/// Creates a rectangle of the specified size centered at a point in the node's coordinate space.
///
/// Parameter `s`: the size in points
#[unsafe(method(bodyWithRectangleOfSize:center:))]
#[unsafe(method_family = none)]
pub unsafe fn bodyWithRectangleOfSize_center(
s: CGSize,
center: CGPoint,
) -> Retained<SKPhysicsBody>;
#[cfg(feature = "objc2-core-graphics")]
/// The path must represent a convex or concave polygon with counter clockwise winding and no self intersection. Positions are relative to the node's origin.
///
/// Parameter `path`: the path to use
#[unsafe(method(bodyWithPolygonFromPath:))]
#[unsafe(method_family = none)]
pub unsafe fn bodyWithPolygonFromPath(path: &CGPath) -> Retained<SKPhysicsBody>;
#[cfg(feature = "objc2-core-foundation")]
/// Creates an edge from p1 to p2. Edges have no volume and are intended to be used to create static environments. Edges can collide with bodies of volume, but not with each other.
///
/// Parameter `p1`: start point
///
/// Parameter `p2`: end point
#[unsafe(method(bodyWithEdgeFromPoint:toPoint:))]
#[unsafe(method_family = none)]
pub unsafe fn bodyWithEdgeFromPoint_toPoint(
p1: CGPoint,
p2: CGPoint,
) -> Retained<SKPhysicsBody>;
#[cfg(feature = "objc2-core-graphics")]
/// Creates an edge chain from a path. The path must have no self intersection. Edges have no volume and are intended to be used to create static environments. Edges can collide with bodies of volume, but not with each other.
///
/// Parameter `path`: the path to use
#[unsafe(method(bodyWithEdgeChainFromPath:))]
#[unsafe(method_family = none)]
pub unsafe fn bodyWithEdgeChainFromPath(path: &CGPath) -> Retained<SKPhysicsBody>;
#[cfg(feature = "objc2-core-graphics")]
/// Creates an edge loop from a path. A loop is automatically created by joining the last point to the first. The path must have no self intersection. Edges have no volume and are intended to be used to create static environments. Edges can collide with body's of volume, but not with each other.
///
/// Parameter `path`: the path to use
#[unsafe(method(bodyWithEdgeLoopFromPath:))]
#[unsafe(method_family = none)]
pub unsafe fn bodyWithEdgeLoopFromPath(path: &CGPath) -> Retained<SKPhysicsBody>;
#[cfg(feature = "objc2-core-foundation")]
/// Creates an edge loop from a CGRect. Edges have no volume and are intended to be used to create static environments. Edges can collide with body's of volume, but not with each other.
///
/// Parameter `rect`: the CGRect to use
#[unsafe(method(bodyWithEdgeLoopFromRect:))]
#[unsafe(method_family = none)]
pub unsafe fn bodyWithEdgeLoopFromRect(rect: CGRect) -> Retained<SKPhysicsBody>;
#[cfg(all(feature = "SKTexture", feature = "objc2-core-foundation"))]
/// Creates a body from the alpha values in the supplied texture.
///
/// Parameter `texture`: the texture to be interpreted
///
/// Parameter `size`: of the generated physics body
#[unsafe(method(bodyWithTexture:size:))]
#[unsafe(method_family = none)]
pub unsafe fn bodyWithTexture_size(
texture: &SKTexture,
size: CGSize,
) -> Retained<SKPhysicsBody>;
#[cfg(all(feature = "SKTexture", feature = "objc2-core-foundation"))]
/// Creates a body from the alpha values in the supplied texture.
///
/// Parameter `texture`: the texture to be interpreted
///
/// Parameter `alphaThreshold`: the alpha value above which a pixel is interpreted as opaque
///
/// Parameter `size`: of the generated physics body
#[unsafe(method(bodyWithTexture:alphaThreshold:size:))]
#[unsafe(method_family = none)]
pub unsafe fn bodyWithTexture_alphaThreshold_size(
texture: &SKTexture,
alpha_threshold: c_float,
size: CGSize,
) -> Retained<SKPhysicsBody>;
/// Creates an compound body that is the union of the bodies used to create it.
#[unsafe(method(bodyWithBodies:))]
#[unsafe(method_family = none)]
pub unsafe fn bodyWithBodies(bodies: &NSArray<SKPhysicsBody>) -> Retained<SKPhysicsBody>;
#[unsafe(method(isDynamic))]
#[unsafe(method_family = none)]
pub unsafe fn isDynamic(&self) -> bool;
/// Setter for [`isDynamic`][Self::isDynamic].
#[unsafe(method(setDynamic:))]
#[unsafe(method_family = none)]
pub unsafe fn setDynamic(&self, dynamic: bool);
#[unsafe(method(usesPreciseCollisionDetection))]
#[unsafe(method_family = none)]
pub unsafe fn usesPreciseCollisionDetection(&self) -> bool;
/// Setter for [`usesPreciseCollisionDetection`][Self::usesPreciseCollisionDetection].
#[unsafe(method(setUsesPreciseCollisionDetection:))]
#[unsafe(method_family = none)]
pub unsafe fn setUsesPreciseCollisionDetection(
&self,
uses_precise_collision_detection: bool,
);
#[unsafe(method(allowsRotation))]
#[unsafe(method_family = none)]
pub unsafe fn allowsRotation(&self) -> bool;
/// Setter for [`allowsRotation`][Self::allowsRotation].
#[unsafe(method(setAllowsRotation:))]
#[unsafe(method_family = none)]
pub unsafe fn setAllowsRotation(&self, allows_rotation: bool);
#[unsafe(method(pinned))]
#[unsafe(method_family = none)]
pub unsafe fn pinned(&self) -> bool;
/// Setter for [`pinned`][Self::pinned].
#[unsafe(method(setPinned:))]
#[unsafe(method_family = none)]
pub unsafe fn setPinned(&self, pinned: bool);
/// If the physics simulation has determined that this body is at rest it may set the resting property to YES. Resting bodies do not participate
/// in the simulation until some collision with a non-resting object, or an impulse is applied, that unrests it. If all bodies in the world are resting
/// then the simulation as a whole is "at rest".
#[unsafe(method(isResting))]
#[unsafe(method_family = none)]
pub unsafe fn isResting(&self) -> bool;
/// Setter for [`isResting`][Self::isResting].
#[unsafe(method(setResting:))]
#[unsafe(method_family = none)]
pub unsafe fn setResting(&self, resting: bool);
#[cfg(feature = "objc2-core-foundation")]
/// Determines the 'roughness' for the surface of the physics body (0.0 - 1.0). Defaults to 0.2
#[unsafe(method(friction))]
#[unsafe(method_family = none)]
pub unsafe fn friction(&self) -> CGFloat;
#[cfg(feature = "objc2-core-foundation")]
/// Setter for [`friction`][Self::friction].
#[unsafe(method(setFriction:))]
#[unsafe(method_family = none)]
pub unsafe fn setFriction(&self, friction: CGFloat);
#[cfg(feature = "objc2-core-foundation")]
/// Specifies the charge on the body. Charge determines the degree to which a body is affected by
/// electric and magnetic fields. Note that this is a unitless quantity, it is up to the developer to
/// set charge and field strength appropriately. Defaults to 0.0
#[unsafe(method(charge))]
#[unsafe(method_family = none)]
pub unsafe fn charge(&self) -> CGFloat;
#[cfg(feature = "objc2-core-foundation")]
/// Setter for [`charge`][Self::charge].
#[unsafe(method(setCharge:))]
#[unsafe(method_family = none)]
pub unsafe fn setCharge(&self, charge: CGFloat);
#[cfg(feature = "objc2-core-foundation")]
/// Determines the 'bounciness' of the physics body (0.0 - 1.0). Defaults to 0.2
#[unsafe(method(restitution))]
#[unsafe(method_family = none)]
pub unsafe fn restitution(&self) -> CGFloat;
#[cfg(feature = "objc2-core-foundation")]
/// Setter for [`restitution`][Self::restitution].
#[unsafe(method(setRestitution:))]
#[unsafe(method_family = none)]
pub unsafe fn setRestitution(&self, restitution: CGFloat);
#[cfg(feature = "objc2-core-foundation")]
/// Optionally reduce the body's linear velocity each frame to simulate fluid/air friction. Value should be zero or greater. Defaults to 0.1.
/// Used in conjunction with per frame impulses, an object can be made to move at a constant speed. For example, if an object 64 points in size
/// and default density and a linearDamping of 25 will slide across the screen in a few seconds if an impulse of magnitude 10 is applied every update.
#[unsafe(method(linearDamping))]
#[unsafe(method_family = none)]
pub unsafe fn linearDamping(&self) -> CGFloat;
#[cfg(feature = "objc2-core-foundation")]
/// Setter for [`linearDamping`][Self::linearDamping].
#[unsafe(method(setLinearDamping:))]
#[unsafe(method_family = none)]
pub unsafe fn setLinearDamping(&self, linear_damping: CGFloat);
#[cfg(feature = "objc2-core-foundation")]
/// Optionally reduce the body's angular velocity each frame to simulate rotational friction. (0.0 - 1.0). Defaults to 0.1
#[unsafe(method(angularDamping))]
#[unsafe(method_family = none)]
pub unsafe fn angularDamping(&self) -> CGFloat;
#[cfg(feature = "objc2-core-foundation")]
/// Setter for [`angularDamping`][Self::angularDamping].
#[unsafe(method(setAngularDamping:))]
#[unsafe(method_family = none)]
pub unsafe fn setAngularDamping(&self, angular_damping: CGFloat);
#[cfg(feature = "objc2-core-foundation")]
/// The density of the body.
///
/// The unit is arbitrary, as long as the relative densities are consistent throughout the application. Note that density and mass are inherently related (they are directly proportional), so changing one also changes the other. Both are provided so either can be used depending on what is more relevant to your usage.
#[unsafe(method(density))]
#[unsafe(method_family = none)]
pub unsafe fn density(&self) -> CGFloat;
#[cfg(feature = "objc2-core-foundation")]
/// Setter for [`density`][Self::density].
#[unsafe(method(setDensity:))]
#[unsafe(method_family = none)]
pub unsafe fn setDensity(&self, density: CGFloat);
#[cfg(feature = "objc2-core-foundation")]
/// The mass of the body.
///
/// The unit is arbitrary, as long as the relative masses are consistent throughout the application. Note that density and mass are inherently related (they are directly proportional), so changing one also changes the other. Both are provided so either can be used depending on what is more relevant to your usage.
#[unsafe(method(mass))]
#[unsafe(method_family = none)]
pub unsafe fn mass(&self) -> CGFloat;
#[cfg(feature = "objc2-core-foundation")]
/// Setter for [`mass`][Self::mass].
#[unsafe(method(setMass:))]
#[unsafe(method_family = none)]
pub unsafe fn setMass(&self, mass: CGFloat);
#[cfg(feature = "objc2-core-foundation")]
/// The area of the body.
///
/// The unit is arbitrary, as long as the relative areas are consistent throughout the application.
#[unsafe(method(area))]
#[unsafe(method_family = none)]
pub unsafe fn area(&self) -> CGFloat;
/// Bodies are affected by field forces such as gravity if this property is set and the field's category mask is set appropriately. The default value is YES.
///
/// If this is set a force is applied to the object based on the mass. Set the field force vector in the scene to modify the strength of the force.
#[unsafe(method(affectedByGravity))]
#[unsafe(method_family = none)]
pub unsafe fn affectedByGravity(&self) -> bool;
/// Setter for [`affectedByGravity`][Self::affectedByGravity].
#[unsafe(method(setAffectedByGravity:))]
#[unsafe(method_family = none)]
pub unsafe fn setAffectedByGravity(&self, affected_by_gravity: bool);
/// Defines what logical 'categories' of fields this body responds to. Defaults to all bits set (all categories).
/// Can be forced off via affectedByGravity.
#[unsafe(method(fieldBitMask))]
#[unsafe(method_family = none)]
pub unsafe fn fieldBitMask(&self) -> u32;
/// Setter for [`fieldBitMask`][Self::fieldBitMask].
#[unsafe(method(setFieldBitMask:))]
#[unsafe(method_family = none)]
pub unsafe fn setFieldBitMask(&self, field_bit_mask: u32);
/// Defines what logical 'categories' this body belongs to. Defaults to all bits set (all categories).
#[unsafe(method(categoryBitMask))]
#[unsafe(method_family = none)]
pub unsafe fn categoryBitMask(&self) -> u32;
/// Setter for [`categoryBitMask`][Self::categoryBitMask].
#[unsafe(method(setCategoryBitMask:))]
#[unsafe(method_family = none)]
pub unsafe fn setCategoryBitMask(&self, category_bit_mask: u32);
/// Defines what logical 'categories' of bodies this body responds to collisions with. Defaults to all bits set (all categories).
#[unsafe(method(collisionBitMask))]
#[unsafe(method_family = none)]
pub unsafe fn collisionBitMask(&self) -> u32;
/// Setter for [`collisionBitMask`][Self::collisionBitMask].
#[unsafe(method(setCollisionBitMask:))]
#[unsafe(method_family = none)]
pub unsafe fn setCollisionBitMask(&self, collision_bit_mask: u32);
/// Defines what logical 'categories' of bodies this body generates intersection notifications with. Defaults to all bits cleared (no categories).
#[unsafe(method(contactTestBitMask))]
#[unsafe(method_family = none)]
pub unsafe fn contactTestBitMask(&self) -> u32;
/// Setter for [`contactTestBitMask`][Self::contactTestBitMask].
#[unsafe(method(setContactTestBitMask:))]
#[unsafe(method_family = none)]
pub unsafe fn setContactTestBitMask(&self, contact_test_bit_mask: u32);
#[cfg(feature = "SKPhysicsJoint")]
#[unsafe(method(joints))]
#[unsafe(method_family = none)]
pub unsafe fn joints(&self) -> Retained<NSArray<SKPhysicsJoint>>;
#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
#[cfg(target_os = "macos")]
/// The representedObject this physicsBody is currently bound to, or nil if it is not.
#[unsafe(method(node))]
#[unsafe(method_family = none)]
pub unsafe fn node(&self, mtm: MainThreadMarker) -> Option<Retained<SKNode>>;
#[cfg(feature = "objc2-core-foundation")]
#[unsafe(method(velocity))]
#[unsafe(method_family = none)]
pub unsafe fn velocity(&self) -> CGVector;
#[cfg(feature = "objc2-core-foundation")]
/// Setter for [`velocity`][Self::velocity].
#[unsafe(method(setVelocity:))]
#[unsafe(method_family = none)]
pub unsafe fn setVelocity(&self, velocity: CGVector);
#[cfg(feature = "objc2-core-foundation")]
#[unsafe(method(angularVelocity))]
#[unsafe(method_family = none)]
pub unsafe fn angularVelocity(&self) -> CGFloat;
#[cfg(feature = "objc2-core-foundation")]
/// Setter for [`angularVelocity`][Self::angularVelocity].
#[unsafe(method(setAngularVelocity:))]
#[unsafe(method_family = none)]
pub unsafe fn setAngularVelocity(&self, angular_velocity: CGFloat);
#[cfg(feature = "objc2-core-foundation")]
#[unsafe(method(applyForce:))]
#[unsafe(method_family = none)]
pub unsafe fn applyForce(&self, force: CGVector);
#[cfg(feature = "objc2-core-foundation")]
#[unsafe(method(applyForce:atPoint:))]
#[unsafe(method_family = none)]
pub unsafe fn applyForce_atPoint(&self, force: CGVector, point: CGPoint);
#[cfg(feature = "objc2-core-foundation")]
#[unsafe(method(applyTorque:))]
#[unsafe(method_family = none)]
pub unsafe fn applyTorque(&self, torque: CGFloat);
#[cfg(feature = "objc2-core-foundation")]
#[unsafe(method(applyImpulse:))]
#[unsafe(method_family = none)]
pub unsafe fn applyImpulse(&self, impulse: CGVector);
#[cfg(feature = "objc2-core-foundation")]
#[unsafe(method(applyImpulse:atPoint:))]
#[unsafe(method_family = none)]
pub unsafe fn applyImpulse_atPoint(&self, impulse: CGVector, point: CGPoint);
#[cfg(feature = "objc2-core-foundation")]
#[unsafe(method(applyAngularImpulse:))]
#[unsafe(method_family = none)]
pub unsafe fn applyAngularImpulse(&self, impulse: CGFloat);
#[unsafe(method(allContactedBodies))]
#[unsafe(method_family = none)]
pub unsafe fn allContactedBodies(&self) -> Retained<NSArray<SKPhysicsBody>>;
);
}
/// Methods declared on superclass `NSObject`.
impl SKPhysicsBody {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}