1 /** 2 3 4 Copyright: 5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. 6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) 7 Copyright (c) 2017-2018 Godot-D contributors 8 9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License) 10 11 12 */ 13 module godot.physicsdirectbodystate; 14 import std.meta : AliasSeq, staticIndexOf; 15 import std.traits : Unqual; 16 import godot.d.meta; 17 import godot.core; 18 import godot.c; 19 import godot.d.bind; 20 import godot.d.reference; 21 import godot.object; 22 import godot.physicsdirectspacestate; 23 /** 24 25 */ 26 @GodotBaseClass struct PhysicsDirectBodyState 27 { 28 enum string _GODOT_internal_name = "PhysicsDirectBodyState"; 29 public: 30 @nogc nothrow: 31 union { godot_object _godot_object; GodotObject _GODOT_base; } 32 alias _GODOT_base this; 33 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 34 package(godot) __gshared bool _classBindingInitialized = false; 35 package(godot) static struct _classBinding 36 { 37 __gshared: 38 @GodotName("get_total_gravity") GodotMethod!(Vector3) getTotalGravity; 39 @GodotName("get_total_linear_damp") GodotMethod!(double) getTotalLinearDamp; 40 @GodotName("get_total_angular_damp") GodotMethod!(double) getTotalAngularDamp; 41 @GodotName("get_center_of_mass") GodotMethod!(Vector3) getCenterOfMass; 42 @GodotName("get_principal_inertia_axes") GodotMethod!(Basis) getPrincipalInertiaAxes; 43 @GodotName("get_inverse_mass") GodotMethod!(double) getInverseMass; 44 @GodotName("get_inverse_inertia") GodotMethod!(Vector3) getInverseInertia; 45 @GodotName("set_linear_velocity") GodotMethod!(void, Vector3) setLinearVelocity; 46 @GodotName("get_linear_velocity") GodotMethod!(Vector3) getLinearVelocity; 47 @GodotName("set_angular_velocity") GodotMethod!(void, Vector3) setAngularVelocity; 48 @GodotName("get_angular_velocity") GodotMethod!(Vector3) getAngularVelocity; 49 @GodotName("set_transform") GodotMethod!(void, Transform) setTransform; 50 @GodotName("get_transform") GodotMethod!(Transform) getTransform; 51 @GodotName("add_central_force") GodotMethod!(void, Vector3) addCentralForce; 52 @GodotName("add_force") GodotMethod!(void, Vector3, Vector3) addForce; 53 @GodotName("add_torque") GodotMethod!(void, Vector3) addTorque; 54 @GodotName("apply_central_impulse") GodotMethod!(void, Vector3) applyCentralImpulse; 55 @GodotName("apply_impulse") GodotMethod!(void, Vector3, Vector3) applyImpulse; 56 @GodotName("apply_torque_impulse") GodotMethod!(void, Vector3) applyTorqueImpulse; 57 @GodotName("set_sleep_state") GodotMethod!(void, bool) setSleepState; 58 @GodotName("is_sleeping") GodotMethod!(bool) isSleeping; 59 @GodotName("get_contact_count") GodotMethod!(long) getContactCount; 60 @GodotName("get_contact_local_position") GodotMethod!(Vector3, long) getContactLocalPosition; 61 @GodotName("get_contact_local_normal") GodotMethod!(Vector3, long) getContactLocalNormal; 62 @GodotName("get_contact_impulse") GodotMethod!(double, long) getContactImpulse; 63 @GodotName("get_contact_local_shape") GodotMethod!(long, long) getContactLocalShape; 64 @GodotName("get_contact_collider") GodotMethod!(RID, long) getContactCollider; 65 @GodotName("get_contact_collider_position") GodotMethod!(Vector3, long) getContactColliderPosition; 66 @GodotName("get_contact_collider_id") GodotMethod!(long, long) getContactColliderId; 67 @GodotName("get_contact_collider_object") GodotMethod!(GodotObject, long) getContactColliderObject; 68 @GodotName("get_contact_collider_shape") GodotMethod!(long, long) getContactColliderShape; 69 @GodotName("get_contact_collider_velocity_at_position") GodotMethod!(Vector3, long) getContactColliderVelocityAtPosition; 70 @GodotName("get_step") GodotMethod!(double) getStep; 71 @GodotName("integrate_forces") GodotMethod!(void) integrateForces; 72 @GodotName("get_space_state") GodotMethod!(PhysicsDirectSpaceState) getSpaceState; 73 } 74 bool opEquals(in PhysicsDirectBodyState other) const { return _godot_object.ptr is other._godot_object.ptr; } 75 PhysicsDirectBodyState opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 76 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 77 mixin baseCasts; 78 static PhysicsDirectBodyState _new() 79 { 80 static godot_class_constructor constructor; 81 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("PhysicsDirectBodyState"); 82 if(constructor is null) return typeof(this).init; 83 return cast(PhysicsDirectBodyState)(constructor()); 84 } 85 @disable new(size_t s); 86 /** 87 88 */ 89 Vector3 getTotalGravity() const 90 { 91 checkClassBinding!(typeof(this))(); 92 return ptrcall!(Vector3)(_classBinding.getTotalGravity, _godot_object); 93 } 94 /** 95 96 */ 97 double getTotalLinearDamp() const 98 { 99 checkClassBinding!(typeof(this))(); 100 return ptrcall!(double)(_classBinding.getTotalLinearDamp, _godot_object); 101 } 102 /** 103 104 */ 105 double getTotalAngularDamp() const 106 { 107 checkClassBinding!(typeof(this))(); 108 return ptrcall!(double)(_classBinding.getTotalAngularDamp, _godot_object); 109 } 110 /** 111 112 */ 113 Vector3 getCenterOfMass() const 114 { 115 checkClassBinding!(typeof(this))(); 116 return ptrcall!(Vector3)(_classBinding.getCenterOfMass, _godot_object); 117 } 118 /** 119 120 */ 121 Basis getPrincipalInertiaAxes() const 122 { 123 checkClassBinding!(typeof(this))(); 124 return ptrcall!(Basis)(_classBinding.getPrincipalInertiaAxes, _godot_object); 125 } 126 /** 127 128 */ 129 double getInverseMass() const 130 { 131 checkClassBinding!(typeof(this))(); 132 return ptrcall!(double)(_classBinding.getInverseMass, _godot_object); 133 } 134 /** 135 136 */ 137 Vector3 getInverseInertia() const 138 { 139 checkClassBinding!(typeof(this))(); 140 return ptrcall!(Vector3)(_classBinding.getInverseInertia, _godot_object); 141 } 142 /** 143 144 */ 145 void setLinearVelocity(in Vector3 velocity) 146 { 147 checkClassBinding!(typeof(this))(); 148 ptrcall!(void)(_classBinding.setLinearVelocity, _godot_object, velocity); 149 } 150 /** 151 152 */ 153 Vector3 getLinearVelocity() const 154 { 155 checkClassBinding!(typeof(this))(); 156 return ptrcall!(Vector3)(_classBinding.getLinearVelocity, _godot_object); 157 } 158 /** 159 160 */ 161 void setAngularVelocity(in Vector3 velocity) 162 { 163 checkClassBinding!(typeof(this))(); 164 ptrcall!(void)(_classBinding.setAngularVelocity, _godot_object, velocity); 165 } 166 /** 167 168 */ 169 Vector3 getAngularVelocity() const 170 { 171 checkClassBinding!(typeof(this))(); 172 return ptrcall!(Vector3)(_classBinding.getAngularVelocity, _godot_object); 173 } 174 /** 175 176 */ 177 void setTransform(in Transform transform) 178 { 179 checkClassBinding!(typeof(this))(); 180 ptrcall!(void)(_classBinding.setTransform, _godot_object, transform); 181 } 182 /** 183 184 */ 185 Transform getTransform() const 186 { 187 checkClassBinding!(typeof(this))(); 188 return ptrcall!(Transform)(_classBinding.getTransform, _godot_object); 189 } 190 /** 191 Adds a constant directional force without affecting rotation. 192 This is equivalent to `add_force(force, Vector3(0,0,0))`. 193 */ 194 void addCentralForce(in Vector3 force) 195 { 196 checkClassBinding!(typeof(this))(); 197 ptrcall!(void)(_classBinding.addCentralForce, _godot_object, force); 198 } 199 /** 200 Adds a constant force (i.e. acceleration). 201 */ 202 void addForce(in Vector3 force, in Vector3 position) 203 { 204 checkClassBinding!(typeof(this))(); 205 ptrcall!(void)(_classBinding.addForce, _godot_object, force, position); 206 } 207 /** 208 Adds a constant rotational force (i.e. a motor) without affecting position. 209 */ 210 void addTorque(in Vector3 torque) 211 { 212 checkClassBinding!(typeof(this))(); 213 ptrcall!(void)(_classBinding.addTorque, _godot_object, torque); 214 } 215 /** 216 Applies a single directional impulse without affecting rotation. 217 This is equivalent to ``apply_impulse(Vector3(0,0,0), impulse)``. 218 */ 219 void applyCentralImpulse(in Vector3 j) 220 { 221 checkClassBinding!(typeof(this))(); 222 ptrcall!(void)(_classBinding.applyCentralImpulse, _godot_object, j); 223 } 224 /** 225 Apply a positioned impulse (which will be affected by the body mass and shape). This is the equivalent of hitting a billiard ball with a cue: a force that is applied once, and only once. Both the impulse and the position are in global coordinates, and the position is relative to the object's origin. 226 */ 227 void applyImpulse(in Vector3 position, in Vector3 j) 228 { 229 checkClassBinding!(typeof(this))(); 230 ptrcall!(void)(_classBinding.applyImpulse, _godot_object, position, j); 231 } 232 /** 233 Apply a torque impulse (which will be affected by the body mass and shape). This will rotate the body around the passed in vector. 234 */ 235 void applyTorqueImpulse(in Vector3 j) 236 { 237 checkClassBinding!(typeof(this))(); 238 ptrcall!(void)(_classBinding.applyTorqueImpulse, _godot_object, j); 239 } 240 /** 241 242 */ 243 void setSleepState(in bool enabled) 244 { 245 checkClassBinding!(typeof(this))(); 246 ptrcall!(void)(_classBinding.setSleepState, _godot_object, enabled); 247 } 248 /** 249 250 */ 251 bool isSleeping() const 252 { 253 checkClassBinding!(typeof(this))(); 254 return ptrcall!(bool)(_classBinding.isSleeping, _godot_object); 255 } 256 /** 257 258 */ 259 long getContactCount() const 260 { 261 checkClassBinding!(typeof(this))(); 262 return ptrcall!(long)(_classBinding.getContactCount, _godot_object); 263 } 264 /** 265 266 */ 267 Vector3 getContactLocalPosition(in long contact_idx) const 268 { 269 checkClassBinding!(typeof(this))(); 270 return ptrcall!(Vector3)(_classBinding.getContactLocalPosition, _godot_object, contact_idx); 271 } 272 /** 273 274 */ 275 Vector3 getContactLocalNormal(in long contact_idx) const 276 { 277 checkClassBinding!(typeof(this))(); 278 return ptrcall!(Vector3)(_classBinding.getContactLocalNormal, _godot_object, contact_idx); 279 } 280 /** 281 Impulse created by the contact. Only implemented for Bullet physics. 282 */ 283 double getContactImpulse(in long contact_idx) const 284 { 285 checkClassBinding!(typeof(this))(); 286 return ptrcall!(double)(_classBinding.getContactImpulse, _godot_object, contact_idx); 287 } 288 /** 289 290 */ 291 long getContactLocalShape(in long contact_idx) const 292 { 293 checkClassBinding!(typeof(this))(); 294 return ptrcall!(long)(_classBinding.getContactLocalShape, _godot_object, contact_idx); 295 } 296 /** 297 298 */ 299 RID getContactCollider(in long contact_idx) const 300 { 301 checkClassBinding!(typeof(this))(); 302 return ptrcall!(RID)(_classBinding.getContactCollider, _godot_object, contact_idx); 303 } 304 /** 305 306 */ 307 Vector3 getContactColliderPosition(in long contact_idx) const 308 { 309 checkClassBinding!(typeof(this))(); 310 return ptrcall!(Vector3)(_classBinding.getContactColliderPosition, _godot_object, contact_idx); 311 } 312 /** 313 314 */ 315 long getContactColliderId(in long contact_idx) const 316 { 317 checkClassBinding!(typeof(this))(); 318 return ptrcall!(long)(_classBinding.getContactColliderId, _godot_object, contact_idx); 319 } 320 /** 321 322 */ 323 GodotObject getContactColliderObject(in long contact_idx) const 324 { 325 checkClassBinding!(typeof(this))(); 326 return ptrcall!(GodotObject)(_classBinding.getContactColliderObject, _godot_object, contact_idx); 327 } 328 /** 329 330 */ 331 long getContactColliderShape(in long contact_idx) const 332 { 333 checkClassBinding!(typeof(this))(); 334 return ptrcall!(long)(_classBinding.getContactColliderShape, _godot_object, contact_idx); 335 } 336 /** 337 338 */ 339 Vector3 getContactColliderVelocityAtPosition(in long contact_idx) const 340 { 341 checkClassBinding!(typeof(this))(); 342 return ptrcall!(Vector3)(_classBinding.getContactColliderVelocityAtPosition, _godot_object, contact_idx); 343 } 344 /** 345 346 */ 347 double getStep() const 348 { 349 checkClassBinding!(typeof(this))(); 350 return ptrcall!(double)(_classBinding.getStep, _godot_object); 351 } 352 /** 353 354 */ 355 void integrateForces() 356 { 357 checkClassBinding!(typeof(this))(); 358 ptrcall!(void)(_classBinding.integrateForces, _godot_object); 359 } 360 /** 361 362 */ 363 PhysicsDirectSpaceState getSpaceState() 364 { 365 checkClassBinding!(typeof(this))(); 366 return ptrcall!(PhysicsDirectSpaceState)(_classBinding.getSpaceState, _godot_object); 367 } 368 /** 369 The timestep (delta) used for the simulation. 370 */ 371 @property double step() 372 { 373 return getStep(); 374 } 375 /** 376 The inverse of the mass of the body. 377 */ 378 @property double inverseMass() 379 { 380 return getInverseMass(); 381 } 382 /** 383 The rate at which the body stops rotating, if there are not any other forces moving it. 384 */ 385 @property double totalAngularDamp() 386 { 387 return getTotalAngularDamp(); 388 } 389 /** 390 The rate at which the body stops moving, if there are not any other forces moving it. 391 */ 392 @property double totalLinearDamp() 393 { 394 return getTotalLinearDamp(); 395 } 396 /** 397 The inverse of the inertia of the body. 398 */ 399 @property Vector3 inverseInertia() 400 { 401 return getInverseInertia(); 402 } 403 /** 404 The total gravity vector being currently applied to this body. 405 */ 406 @property Vector3 totalGravity() 407 { 408 return getTotalGravity(); 409 } 410 /** 411 412 */ 413 @property Vector3 centerOfMass() 414 { 415 return getCenterOfMass(); 416 } 417 /** 418 419 */ 420 @property Basis principalInertiaAxes() 421 { 422 return getPrincipalInertiaAxes(); 423 } 424 /** 425 The angular velocity of the body. 426 */ 427 @property Vector3 angularVelocity() 428 { 429 return getAngularVelocity(); 430 } 431 /// ditto 432 @property void angularVelocity(Vector3 v) 433 { 434 setAngularVelocity(v); 435 } 436 /** 437 The linear velocity of the body. 438 */ 439 @property Vector3 linearVelocity() 440 { 441 return getLinearVelocity(); 442 } 443 /// ditto 444 @property void linearVelocity(Vector3 v) 445 { 446 setLinearVelocity(v); 447 } 448 /** 449 `true` if this body is currently sleeping (not active). 450 */ 451 @property bool sleeping() 452 { 453 return isSleeping(); 454 } 455 /// ditto 456 @property void sleeping(bool v) 457 { 458 setSleepState(v); 459 } 460 /** 461 The transformation matrix of the body. 462 */ 463 @property Transform transform() 464 { 465 return getTransform(); 466 } 467 /// ditto 468 @property void transform(Transform v) 469 { 470 setTransform(v); 471 } 472 }