/
RigidBody.hx
401 lines (309 loc) · 15.1 KB
/
RigidBody.hx
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
// Automatically generated Godot externs: DO NOT EDIT
// MIT licensed, see LICENSE.md
package godot;
import cs.system.*;
/**
This is the node that implements full 3D physics. This means that you do not control a RigidBody directly. Instead, you can apply forces to it (gravity, impulses, etc.), and the physics simulation will calculate the resulting movement, collision, bouncing, rotating, etc.
A RigidBody has 4 behavior `godot.RigidBody.mode`s: Rigid, Static, Character, and Kinematic.
Note: Don't change a RigidBody's position every frame or very often. Sporadic changes work fine, but physics runs at a different granularity (fixed Hz) than usual rendering (process callback) and maybe even in a separate thread, so changing this from a process loop may result in strange behavior. If you need to directly affect the body's state, use `godot.RigidBody._IntegrateForces`, which allows you to directly access the physics state.
If you need to override the default physics behavior, you can write a custom force integration function. See `godot.RigidBody.customIntegrator`.
With Bullet physics (the default), the center of mass is the RigidBody3D center. With GodotPhysics, the center of mass is the average of the `godot.CollisionShape` centers.
**/
@:libType
@:csNative
@:native("Godot.RigidBody")
@:autoBuild(godot.Godot.buildUserClass())
extern class RigidBody extends godot.PhysicsBody {
/**
`body_entered` signal.
**/
public var onBodyEntered(get, never):Signal<(body:Node)->Void>;
@:dox(hide) @:noCompletion inline function get_onBodyEntered():Signal<(body:Node)->Void> {
return new Signal(this, "body_entered", Signal.SignalHandlerNodeVoid.connectSignal, Signal.SignalHandlerNodeVoid.disconnectSignal, Signal.SignalHandlerNodeVoid.isSignalConnected);
}
/**
`body_exited` signal.
**/
public var onBodyExited(get, never):Signal<(body:Node)->Void>;
@:dox(hide) @:noCompletion inline function get_onBodyExited():Signal<(body:Node)->Void> {
return new Signal(this, "body_exited", Signal.SignalHandlerNodeVoid.connectSignal, Signal.SignalHandlerNodeVoid.disconnectSignal, Signal.SignalHandlerNodeVoid.isSignalConnected);
}
/**
`body_shape_entered` signal.
**/
public var onBodyShapeEntered(get, never):Signal<(bodyRid:RID, body:Node, bodyShapeIndex:Int, localShapeIndex:Int)->Void>;
@:dox(hide) @:noCompletion inline function get_onBodyShapeEntered():Signal<(bodyRid:RID, body:Node, bodyShapeIndex:Int, localShapeIndex:Int)->Void> {
return new Signal(this, "body_shape_entered", Signal.SignalHandlerRIDNodeIntIntVoid.connectSignal, Signal.SignalHandlerRIDNodeIntIntVoid.disconnectSignal, Signal.SignalHandlerRIDNodeIntIntVoid.isSignalConnected);
}
/**
`body_shape_exited` signal.
**/
public var onBodyShapeExited(get, never):Signal<(bodyRid:RID, body:Node, bodyShapeIndex:Int, localShapeIndex:Int)->Void>;
@:dox(hide) @:noCompletion inline function get_onBodyShapeExited():Signal<(bodyRid:RID, body:Node, bodyShapeIndex:Int, localShapeIndex:Int)->Void> {
return new Signal(this, "body_shape_exited", Signal.SignalHandlerRIDNodeIntIntVoid.connectSignal, Signal.SignalHandlerRIDNodeIntIntVoid.disconnectSignal, Signal.SignalHandlerRIDNodeIntIntVoid.isSignalConnected);
}
/**
`sleeping_state_changed` signal.
**/
public var onSleepingStateChanged(get, never):Signal<Void->Void>;
@:dox(hide) @:noCompletion inline function get_onSleepingStateChanged():Signal<Void->Void> {
return new Signal(this, "sleeping_state_changed", Signal.SignalHandlerVoidVoid.connectSignal, Signal.SignalHandlerVoidVoid.disconnectSignal, Signal.SignalHandlerVoidVoid.isSignalConnected);
}
/**
Damps RigidBody's rotational forces. If this value is different from -1.0 it will be added to any linear damp derived from the world or areas.
See for more details about damping.
**/
@:native("AngularDamp")
public var angularDamp:Single;
/**
The body's rotational velocity in axis-angle format. The magnitude of the vector is the rotation rate in radians per second.
**/
@:native("AngularVelocity")
public var angularVelocity:godot.Vector3;
/**
The body's linear damp. Cannot be less than -1.0. If this value is different from -1.0 it will be added to any linear damp derived from the world or areas.
See for more details about damping.
**/
@:native("LinearDamp")
public var linearDamp:Single;
/**
The body's linear velocity in units per second. Can be used sporadically, but don't set this every frame, because physics may run in another thread and runs at a different granularity. Use `godot.RigidBody._IntegrateForces` as your process loop for precise control of the body state.
**/
@:native("LinearVelocity")
public var linearVelocity:godot.Vector3;
/**
Lock the body's rotation in the Z axis.
**/
@:native("AxisLockAngularZ")
public var axisLockAngularZ:Bool;
/**
Lock the body's rotation in the Y axis.
**/
@:native("AxisLockAngularY")
public var axisLockAngularY:Bool;
/**
Lock the body's rotation in the X axis.
**/
@:native("AxisLockAngularX")
public var axisLockAngularX:Bool;
/**
Lock the body's movement in the Z axis.
**/
@:native("AxisLockLinearZ")
public var axisLockLinearZ:Bool;
/**
Lock the body's movement in the Y axis.
**/
@:native("AxisLockLinearY")
public var axisLockLinearY:Bool;
/**
Lock the body's movement in the X axis.
**/
@:native("AxisLockLinearX")
public var axisLockLinearX:Bool;
/**
If `true`, the body can enter sleep mode when there is no movement. See `godot.RigidBody.sleeping`.
Note: A RigidBody3D will never enter sleep mode automatically if its `godot.RigidBody.mode` is `godot.RigidBody_ModeEnum.character`. It can still be put to sleep manually by setting its `godot.RigidBody.sleeping` property to `true`.
**/
@:native("CanSleep")
public var canSleep:Bool;
/**
If `true`, the body will not move and will not calculate forces until woken up by another body through, for example, a collision, or by using the `godot.RigidBody.applyImpulse` or `godot.RigidBody.addForce` methods.
**/
@:native("Sleeping")
public var sleeping:Bool;
/**
If `true`, the RigidBody will emit signals when it collides with another RigidBody. See also `godot.RigidBody.contactsReported`.
**/
@:native("ContactMonitor")
public var contactMonitor:Bool;
/**
The maximum number of contacts that will be recorded. Requires `godot.RigidBody.contactMonitor` to be set to `true`.
Note: The number of contacts is different from the number of collisions. Collisions between parallel edges will result in two contacts (one at each end), and collisions between parallel faces will result in four contacts (one at each corner).
**/
@:native("ContactsReported")
public var contactsReported:Int;
/**
If `true`, continuous collision detection is used.
Continuous collision detection tries to predict where a moving body will collide, instead of moving it and correcting its movement if it collided. Continuous collision detection is more precise, and misses fewer impacts by small, fast-moving objects. Not using continuous collision detection is faster to compute, but can miss small, fast-moving objects.
**/
@:native("ContinuousCd")
public var continuousCd:Bool;
/**
If `true`, internal force integration will be disabled (like gravity or air friction) for this body. Other than collision response, the body will only move as determined by the `godot.RigidBody._IntegrateForces` function, if defined.
**/
@:native("CustomIntegrator")
public var customIntegrator:Bool;
/**
This is multiplied by the global 3D gravity setting found in Project > Project Settings > Physics > 3d to produce RigidBody's gravity. For example, a value of 1 will be normal gravity, 2 will apply double gravity, and 0.5 will apply half gravity to this object.
**/
@:native("GravityScale")
public var gravityScale:Single;
/**
The physics material override for the body.
If a material is assigned to this property, it will be used instead of any other physics material, such as an inherited one.
**/
@:native("PhysicsMaterialOverride")
public var physicsMaterialOverride:godot.PhysicsMaterial;
/**
The body's bounciness. Values range from `0` (no bounce) to `1` (full bounciness).
Deprecated, use `godot.PhysicsMaterial.bounce` instead via `godot.RigidBody.physicsMaterialOverride`.
**/
@:native("Bounce")
public var bounce:Single;
/**
The body's friction, from 0 (frictionless) to 1 (max friction).
Deprecated, use `godot.PhysicsMaterial.friction` instead via `godot.RigidBody.physicsMaterialOverride`.
**/
@:native("Friction")
public var friction:Single;
/**
The body's weight based on its mass and the global 3D gravity. Global values are set in Project > Project Settings > Physics > 3d.
**/
@:native("Weight")
public var weight:Single;
/**
The body's mass.
**/
@:native("Mass")
public var mass:Single;
/**
The body mode. See `godot.RigidBody_ModeEnum` for possible values.
**/
@:native("Mode")
public var mode:godot.RigidBody_ModeEnum;
@:native("new")
public function new():Void;
/**
Called during physics processing, allowing you to read and safely modify the simulation state for the object. By default, it works in addition to the usual physics behavior, but the `godot.RigidBody.customIntegrator` property allows you to disable the default behavior and do fully custom force integration for a body.
**/
@:native("_IntegrateForces")
public function _IntegrateForces(state:godot.PhysicsDirectBodyState):Void;
@:native("SetMode")
public function setMode(mode:godot.RigidBody_ModeEnum):Void;
@:native("GetMode")
public function getMode():godot.RigidBody_ModeEnum;
@:native("SetMass")
public function setMass(mass:Single):Void;
@:native("GetMass")
public function getMass():Single;
@:native("SetWeight")
public function setWeight(weight:Single):Void;
@:native("GetWeight")
public function getWeight():Single;
@:native("SetFriction")
public function setFriction(friction:Single):Void;
@:native("GetFriction")
public function getFriction():Single;
@:native("SetBounce")
public function setBounce(bounce:Single):Void;
@:native("GetBounce")
public function getBounce():Single;
@:native("SetPhysicsMaterialOverride")
public function setPhysicsMaterialOverride(physicsMaterialOverride:godot.PhysicsMaterial):Void;
@:native("GetPhysicsMaterialOverride")
public function getPhysicsMaterialOverride():godot.PhysicsMaterial;
@:native("SetLinearVelocity")
public function setLinearVelocity(linearVelocity:godot.Vector3):Void;
@:native("GetLinearVelocity")
public function getLinearVelocity():godot.Vector3;
@:native("SetAngularVelocity")
public function setAngularVelocity(angularVelocity:godot.Vector3):Void;
@:native("GetAngularVelocity")
public function getAngularVelocity():godot.Vector3;
/**
Returns the inverse inertia tensor basis. This is used to calculate the angular acceleration resulting from a torque applied to the RigidBody.
**/
@:native("GetInverseInertiaTensor")
public function getInverseInertiaTensor():godot.Basis;
@:native("SetGravityScale")
public function setGravityScale(gravityScale:Single):Void;
@:native("GetGravityScale")
public function getGravityScale():Single;
@:native("SetLinearDamp")
public function setLinearDamp(linearDamp:Single):Void;
@:native("GetLinearDamp")
public function getLinearDamp():Single;
@:native("SetAngularDamp")
public function setAngularDamp(angularDamp:Single):Void;
@:native("GetAngularDamp")
public function getAngularDamp():Single;
@:native("SetMaxContactsReported")
public function setMaxContactsReported(amount:Int):Void;
@:native("GetMaxContactsReported")
public function getMaxContactsReported():Int;
@:native("SetUseCustomIntegrator")
public function setUseCustomIntegrator(enable:Bool):Void;
@:native("IsUsingCustomIntegrator")
public function isUsingCustomIntegrator():Bool;
@:native("SetContactMonitor")
public function setContactMonitor(enabled:Bool):Void;
@:native("IsContactMonitorEnabled")
public function isContactMonitorEnabled():Bool;
@:native("SetUseContinuousCollisionDetection")
public function setUseContinuousCollisionDetection(enable:Bool):Void;
@:native("IsUsingContinuousCollisionDetection")
public function isUsingContinuousCollisionDetection():Bool;
/**
Sets an axis velocity. The velocity in the given vector axis will be set as the given vector length. This is useful for jumping behavior.
**/
@:native("SetAxisVelocity")
public function setAxisVelocity(axisVelocity:godot.Vector3):Void;
/**
Adds a constant directional force (i.e. acceleration) without affecting rotation.
This is equivalent to `add_force(force, Vector3(0,0,0))`.
**/
@:native("AddCentralForce")
public function addCentralForce(force:godot.Vector3):Void;
/**
Adds a constant directional force (i.e. acceleration).
The position uses the rotation of the global coordinate system, but is centered at the object's origin.
**/
@:native("AddForce")
public function addForce(force:godot.Vector3, position:godot.Vector3):Void;
/**
Adds a constant rotational force (i.e. a motor) without affecting position.
**/
@:native("AddTorque")
public function addTorque(torque:godot.Vector3):Void;
/**
Applies a directional impulse without affecting rotation.
This is equivalent to `apply_impulse(Vector3(0,0,0), impulse)`.
**/
@:native("ApplyCentralImpulse")
public function applyCentralImpulse(impulse:godot.Vector3):Void;
/**
Applies a positioned impulse to the body. An impulse is time independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason it should only be used when simulating one-time impacts. The position uses the rotation of the global coordinate system, but is centered at the object's origin.
**/
@:native("ApplyImpulse")
public function applyImpulse(position:godot.Vector3, impulse:godot.Vector3):Void;
/**
Applies a torque impulse which will be affected by the body mass and shape. This will rotate the body around the `impulse` vector passed.
**/
@:native("ApplyTorqueImpulse")
public function applyTorqueImpulse(impulse:godot.Vector3):Void;
@:native("SetSleeping")
public function setSleeping(sleeping:Bool):Void;
@:native("IsSleeping")
public function isSleeping():Bool;
@:native("SetCanSleep")
public function setCanSleep(ableToSleep:Bool):Void;
@:native("IsAbleToSleep")
public function isAbleToSleep():Bool;
/**
Locks the specified linear or rotational axis.
**/
@:native("SetAxisLock")
public function setAxisLock(axis:godot.PhysicsServer_BodyAxis, lock:Bool):Void;
/**
Returns `true` if the specified linear or rotational axis is locked.
**/
@:native("GetAxisLock")
public function getAxisLock(axis:godot.PhysicsServer_BodyAxis):Bool;
/**
Returns a list of the bodies colliding with this one. Requires `godot.RigidBody.contactMonitor` to be set to `true` and `godot.RigidBody.contactsReported` to be set high enough to detect all the collisions.
Note: The result of this test is not immediate after moving objects. For performance, list of collisions is updated once per frame and before the physics step. Consider using signals instead.
**/
@:native("GetCollidingBodies")
public function getCollidingBodies():godot.collections.Array;
}