1 /** 2 Physics Body whose position is determined through physics simulation in 3D space. 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.rigidbody; 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.classdb; 23 import godot.physicsbody; 24 import godot.physicsdirectbodystate; 25 import godot.physicsmaterial; 26 import godot.collisionobject; 27 import godot.spatial; 28 import godot.node; 29 /** 30 Physics Body whose position is determined through physics simulation in 3D space. 31 32 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. 33 A RigidBody has 4 behavior $(D mode)s: Rigid, Static, Character, and Kinematic. 34 $(B 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 will yield strange behavior. If you need to directly affect the body's state, use $(D _integrateForces), which allows you to directly access the physics state. 35 If you need to override the default physics behavior, you can write a custom force integration. See $(D customIntegrator). 36 */ 37 @GodotBaseClass struct RigidBody 38 { 39 enum string _GODOT_internal_name = "RigidBody"; 40 public: 41 @nogc nothrow: 42 union { godot_object _godot_object; PhysicsBody _GODOT_base; } 43 alias _GODOT_base this; 44 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 45 package(godot) __gshared bool _classBindingInitialized = false; 46 package(godot) static struct _classBinding 47 { 48 __gshared: 49 @GodotName("_integrate_forces") GodotMethod!(void, PhysicsDirectBodyState) _integrateForces; 50 @GodotName("set_mode") GodotMethod!(void, long) setMode; 51 @GodotName("get_mode") GodotMethod!(RigidBody.Mode) getMode; 52 @GodotName("set_mass") GodotMethod!(void, double) setMass; 53 @GodotName("get_mass") GodotMethod!(double) getMass; 54 @GodotName("set_weight") GodotMethod!(void, double) setWeight; 55 @GodotName("get_weight") GodotMethod!(double) getWeight; 56 @GodotName("set_friction") GodotMethod!(void, double) setFriction; 57 @GodotName("get_friction") GodotMethod!(double) getFriction; 58 @GodotName("set_bounce") GodotMethod!(void, double) setBounce; 59 @GodotName("get_bounce") GodotMethod!(double) getBounce; 60 @GodotName("set_physics_material_override") GodotMethod!(void, PhysicsMaterial) setPhysicsMaterialOverride; 61 @GodotName("get_physics_material_override") GodotMethod!(PhysicsMaterial) getPhysicsMaterialOverride; 62 @GodotName("_reload_physics_characteristics") GodotMethod!(void) _reloadPhysicsCharacteristics; 63 @GodotName("set_linear_velocity") GodotMethod!(void, Vector3) setLinearVelocity; 64 @GodotName("get_linear_velocity") GodotMethod!(Vector3) getLinearVelocity; 65 @GodotName("set_angular_velocity") GodotMethod!(void, Vector3) setAngularVelocity; 66 @GodotName("get_angular_velocity") GodotMethod!(Vector3) getAngularVelocity; 67 @GodotName("set_gravity_scale") GodotMethod!(void, double) setGravityScale; 68 @GodotName("get_gravity_scale") GodotMethod!(double) getGravityScale; 69 @GodotName("set_linear_damp") GodotMethod!(void, double) setLinearDamp; 70 @GodotName("get_linear_damp") GodotMethod!(double) getLinearDamp; 71 @GodotName("set_angular_damp") GodotMethod!(void, double) setAngularDamp; 72 @GodotName("get_angular_damp") GodotMethod!(double) getAngularDamp; 73 @GodotName("set_max_contacts_reported") GodotMethod!(void, long) setMaxContactsReported; 74 @GodotName("get_max_contacts_reported") GodotMethod!(long) getMaxContactsReported; 75 @GodotName("set_use_custom_integrator") GodotMethod!(void, bool) setUseCustomIntegrator; 76 @GodotName("is_using_custom_integrator") GodotMethod!(bool) isUsingCustomIntegrator; 77 @GodotName("set_contact_monitor") GodotMethod!(void, bool) setContactMonitor; 78 @GodotName("is_contact_monitor_enabled") GodotMethod!(bool) isContactMonitorEnabled; 79 @GodotName("set_use_continuous_collision_detection") GodotMethod!(void, bool) setUseContinuousCollisionDetection; 80 @GodotName("is_using_continuous_collision_detection") GodotMethod!(bool) isUsingContinuousCollisionDetection; 81 @GodotName("set_axis_velocity") GodotMethod!(void, Vector3) setAxisVelocity; 82 @GodotName("add_central_force") GodotMethod!(void, Vector3) addCentralForce; 83 @GodotName("add_force") GodotMethod!(void, Vector3, Vector3) addForce; 84 @GodotName("add_torque") GodotMethod!(void, Vector3) addTorque; 85 @GodotName("apply_central_impulse") GodotMethod!(void, Vector3) applyCentralImpulse; 86 @GodotName("apply_impulse") GodotMethod!(void, Vector3, Vector3) applyImpulse; 87 @GodotName("apply_torque_impulse") GodotMethod!(void, Vector3) applyTorqueImpulse; 88 @GodotName("set_sleeping") GodotMethod!(void, bool) setSleeping; 89 @GodotName("is_sleeping") GodotMethod!(bool) isSleeping; 90 @GodotName("set_can_sleep") GodotMethod!(void, bool) setCanSleep; 91 @GodotName("is_able_to_sleep") GodotMethod!(bool) isAbleToSleep; 92 @GodotName("_direct_state_changed") GodotMethod!(void, GodotObject) _directStateChanged; 93 @GodotName("_body_enter_tree") GodotMethod!(void, long) _bodyEnterTree; 94 @GodotName("_body_exit_tree") GodotMethod!(void, long) _bodyExitTree; 95 @GodotName("set_axis_lock") GodotMethod!(void, long, bool) setAxisLock; 96 @GodotName("get_axis_lock") GodotMethod!(bool, long) getAxisLock; 97 @GodotName("get_colliding_bodies") GodotMethod!(Array) getCollidingBodies; 98 } 99 bool opEquals(in RigidBody other) const { return _godot_object.ptr is other._godot_object.ptr; } 100 RigidBody opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 101 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 102 mixin baseCasts; 103 static RigidBody _new() 104 { 105 static godot_class_constructor constructor; 106 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("RigidBody"); 107 if(constructor is null) return typeof(this).init; 108 return cast(RigidBody)(constructor()); 109 } 110 @disable new(size_t s); 111 /// 112 enum Mode : int 113 { 114 /** 115 Rigid body mode. This is the "natural" state of a rigid body. It is affected by forces, and can move, rotate, and be affected by user code. 116 */ 117 modeRigid = 0, 118 /** 119 Static mode. The body behaves like a $(D StaticBody), and can only move by user code. 120 */ 121 modeStatic = 1, 122 /** 123 Character body mode. This behaves like a rigid body, but can not rotate. 124 */ 125 modeCharacter = 2, 126 /** 127 Kinematic body mode. The body behaves like a $(D KinematicBody), and can only move by user code. 128 */ 129 modeKinematic = 3, 130 } 131 /// 132 enum Constants : int 133 { 134 modeRigid = 0, 135 modeStatic = 1, 136 modeCharacter = 2, 137 modeKinematic = 3, 138 } 139 /** 140 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 $(D setUseCustomIntegrator) allows you to disable the default behavior and do fully custom force integration for a body. 141 */ 142 void _integrateForces(PhysicsDirectBodyState state) 143 { 144 Array _GODOT_args = Array.empty_array; 145 _GODOT_args.append(state); 146 String _GODOT_method_name = String("_integrate_forces"); 147 this.callv(_GODOT_method_name, _GODOT_args); 148 } 149 /** 150 151 */ 152 void setMode(in long mode) 153 { 154 checkClassBinding!(typeof(this))(); 155 ptrcall!(void)(_classBinding.setMode, _godot_object, mode); 156 } 157 /** 158 159 */ 160 RigidBody.Mode getMode() const 161 { 162 checkClassBinding!(typeof(this))(); 163 return ptrcall!(RigidBody.Mode)(_classBinding.getMode, _godot_object); 164 } 165 /** 166 167 */ 168 void setMass(in double mass) 169 { 170 checkClassBinding!(typeof(this))(); 171 ptrcall!(void)(_classBinding.setMass, _godot_object, mass); 172 } 173 /** 174 175 */ 176 double getMass() const 177 { 178 checkClassBinding!(typeof(this))(); 179 return ptrcall!(double)(_classBinding.getMass, _godot_object); 180 } 181 /** 182 183 */ 184 void setWeight(in double weight) 185 { 186 checkClassBinding!(typeof(this))(); 187 ptrcall!(void)(_classBinding.setWeight, _godot_object, weight); 188 } 189 /** 190 191 */ 192 double getWeight() const 193 { 194 checkClassBinding!(typeof(this))(); 195 return ptrcall!(double)(_classBinding.getWeight, _godot_object); 196 } 197 /** 198 199 */ 200 void setFriction(in double friction) 201 { 202 checkClassBinding!(typeof(this))(); 203 ptrcall!(void)(_classBinding.setFriction, _godot_object, friction); 204 } 205 /** 206 207 */ 208 double getFriction() const 209 { 210 checkClassBinding!(typeof(this))(); 211 return ptrcall!(double)(_classBinding.getFriction, _godot_object); 212 } 213 /** 214 215 */ 216 void setBounce(in double bounce) 217 { 218 checkClassBinding!(typeof(this))(); 219 ptrcall!(void)(_classBinding.setBounce, _godot_object, bounce); 220 } 221 /** 222 223 */ 224 double getBounce() const 225 { 226 checkClassBinding!(typeof(this))(); 227 return ptrcall!(double)(_classBinding.getBounce, _godot_object); 228 } 229 /** 230 231 */ 232 void setPhysicsMaterialOverride(PhysicsMaterial physics_material_override) 233 { 234 checkClassBinding!(typeof(this))(); 235 ptrcall!(void)(_classBinding.setPhysicsMaterialOverride, _godot_object, physics_material_override); 236 } 237 /** 238 239 */ 240 Ref!PhysicsMaterial getPhysicsMaterialOverride() const 241 { 242 checkClassBinding!(typeof(this))(); 243 return ptrcall!(PhysicsMaterial)(_classBinding.getPhysicsMaterialOverride, _godot_object); 244 } 245 /** 246 247 */ 248 void _reloadPhysicsCharacteristics() 249 { 250 Array _GODOT_args = Array.empty_array; 251 String _GODOT_method_name = String("_reload_physics_characteristics"); 252 this.callv(_GODOT_method_name, _GODOT_args); 253 } 254 /** 255 256 */ 257 void setLinearVelocity(in Vector3 linear_velocity) 258 { 259 checkClassBinding!(typeof(this))(); 260 ptrcall!(void)(_classBinding.setLinearVelocity, _godot_object, linear_velocity); 261 } 262 /** 263 264 */ 265 Vector3 getLinearVelocity() const 266 { 267 checkClassBinding!(typeof(this))(); 268 return ptrcall!(Vector3)(_classBinding.getLinearVelocity, _godot_object); 269 } 270 /** 271 272 */ 273 void setAngularVelocity(in Vector3 angular_velocity) 274 { 275 checkClassBinding!(typeof(this))(); 276 ptrcall!(void)(_classBinding.setAngularVelocity, _godot_object, angular_velocity); 277 } 278 /** 279 280 */ 281 Vector3 getAngularVelocity() const 282 { 283 checkClassBinding!(typeof(this))(); 284 return ptrcall!(Vector3)(_classBinding.getAngularVelocity, _godot_object); 285 } 286 /** 287 288 */ 289 void setGravityScale(in double gravity_scale) 290 { 291 checkClassBinding!(typeof(this))(); 292 ptrcall!(void)(_classBinding.setGravityScale, _godot_object, gravity_scale); 293 } 294 /** 295 296 */ 297 double getGravityScale() const 298 { 299 checkClassBinding!(typeof(this))(); 300 return ptrcall!(double)(_classBinding.getGravityScale, _godot_object); 301 } 302 /** 303 304 */ 305 void setLinearDamp(in double linear_damp) 306 { 307 checkClassBinding!(typeof(this))(); 308 ptrcall!(void)(_classBinding.setLinearDamp, _godot_object, linear_damp); 309 } 310 /** 311 312 */ 313 double getLinearDamp() const 314 { 315 checkClassBinding!(typeof(this))(); 316 return ptrcall!(double)(_classBinding.getLinearDamp, _godot_object); 317 } 318 /** 319 320 */ 321 void setAngularDamp(in double angular_damp) 322 { 323 checkClassBinding!(typeof(this))(); 324 ptrcall!(void)(_classBinding.setAngularDamp, _godot_object, angular_damp); 325 } 326 /** 327 328 */ 329 double getAngularDamp() const 330 { 331 checkClassBinding!(typeof(this))(); 332 return ptrcall!(double)(_classBinding.getAngularDamp, _godot_object); 333 } 334 /** 335 336 */ 337 void setMaxContactsReported(in long amount) 338 { 339 checkClassBinding!(typeof(this))(); 340 ptrcall!(void)(_classBinding.setMaxContactsReported, _godot_object, amount); 341 } 342 /** 343 344 */ 345 long getMaxContactsReported() const 346 { 347 checkClassBinding!(typeof(this))(); 348 return ptrcall!(long)(_classBinding.getMaxContactsReported, _godot_object); 349 } 350 /** 351 352 */ 353 void setUseCustomIntegrator(in bool enable) 354 { 355 checkClassBinding!(typeof(this))(); 356 ptrcall!(void)(_classBinding.setUseCustomIntegrator, _godot_object, enable); 357 } 358 /** 359 360 */ 361 bool isUsingCustomIntegrator() 362 { 363 checkClassBinding!(typeof(this))(); 364 return ptrcall!(bool)(_classBinding.isUsingCustomIntegrator, _godot_object); 365 } 366 /** 367 368 */ 369 void setContactMonitor(in bool enabled) 370 { 371 checkClassBinding!(typeof(this))(); 372 ptrcall!(void)(_classBinding.setContactMonitor, _godot_object, enabled); 373 } 374 /** 375 376 */ 377 bool isContactMonitorEnabled() const 378 { 379 checkClassBinding!(typeof(this))(); 380 return ptrcall!(bool)(_classBinding.isContactMonitorEnabled, _godot_object); 381 } 382 /** 383 384 */ 385 void setUseContinuousCollisionDetection(in bool enable) 386 { 387 checkClassBinding!(typeof(this))(); 388 ptrcall!(void)(_classBinding.setUseContinuousCollisionDetection, _godot_object, enable); 389 } 390 /** 391 392 */ 393 bool isUsingContinuousCollisionDetection() const 394 { 395 checkClassBinding!(typeof(this))(); 396 return ptrcall!(bool)(_classBinding.isUsingContinuousCollisionDetection, _godot_object); 397 } 398 /** 399 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. 400 */ 401 void setAxisVelocity(in Vector3 axis_velocity) 402 { 403 checkClassBinding!(typeof(this))(); 404 ptrcall!(void)(_classBinding.setAxisVelocity, _godot_object, axis_velocity); 405 } 406 /** 407 Adds a constant directional force without affecting rotation. 408 This is equivalent to `add_force(force, Vector3(0,0,0))`. 409 */ 410 void addCentralForce(in Vector3 force) 411 { 412 checkClassBinding!(typeof(this))(); 413 ptrcall!(void)(_classBinding.addCentralForce, _godot_object, force); 414 } 415 /** 416 Adds a constant force (i.e. acceleration). 417 */ 418 void addForce(in Vector3 force, in Vector3 position) 419 { 420 checkClassBinding!(typeof(this))(); 421 ptrcall!(void)(_classBinding.addForce, _godot_object, force, position); 422 } 423 /** 424 Adds a constant rotational force (i.e. a motor) without affecting position. 425 */ 426 void addTorque(in Vector3 torque) 427 { 428 checkClassBinding!(typeof(this))(); 429 ptrcall!(void)(_classBinding.addTorque, _godot_object, torque); 430 } 431 /** 432 Applies a directional impulse without affecting rotation. 433 This is equivalent to `apply_impulse(Vector3(0,0,0), impulse)`. 434 */ 435 void applyCentralImpulse(in Vector3 impulse) 436 { 437 checkClassBinding!(typeof(this))(); 438 ptrcall!(void)(_classBinding.applyCentralImpulse, _godot_object, impulse); 439 } 440 /** 441 Applies 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. 442 */ 443 void applyImpulse(in Vector3 position, in Vector3 impulse) 444 { 445 checkClassBinding!(typeof(this))(); 446 ptrcall!(void)(_classBinding.applyImpulse, _godot_object, position, impulse); 447 } 448 /** 449 Applies a torque impulse which will be affected by the body mass and shape. This will rotate the body around the passed in vector. 450 */ 451 void applyTorqueImpulse(in Vector3 impulse) 452 { 453 checkClassBinding!(typeof(this))(); 454 ptrcall!(void)(_classBinding.applyTorqueImpulse, _godot_object, impulse); 455 } 456 /** 457 458 */ 459 void setSleeping(in bool sleeping) 460 { 461 checkClassBinding!(typeof(this))(); 462 ptrcall!(void)(_classBinding.setSleeping, _godot_object, sleeping); 463 } 464 /** 465 466 */ 467 bool isSleeping() const 468 { 469 checkClassBinding!(typeof(this))(); 470 return ptrcall!(bool)(_classBinding.isSleeping, _godot_object); 471 } 472 /** 473 474 */ 475 void setCanSleep(in bool able_to_sleep) 476 { 477 checkClassBinding!(typeof(this))(); 478 ptrcall!(void)(_classBinding.setCanSleep, _godot_object, able_to_sleep); 479 } 480 /** 481 482 */ 483 bool isAbleToSleep() const 484 { 485 checkClassBinding!(typeof(this))(); 486 return ptrcall!(bool)(_classBinding.isAbleToSleep, _godot_object); 487 } 488 /** 489 490 */ 491 void _directStateChanged(GodotObject arg0) 492 { 493 Array _GODOT_args = Array.empty_array; 494 _GODOT_args.append(arg0); 495 String _GODOT_method_name = String("_direct_state_changed"); 496 this.callv(_GODOT_method_name, _GODOT_args); 497 } 498 /** 499 500 */ 501 void _bodyEnterTree(in long arg0) 502 { 503 Array _GODOT_args = Array.empty_array; 504 _GODOT_args.append(arg0); 505 String _GODOT_method_name = String("_body_enter_tree"); 506 this.callv(_GODOT_method_name, _GODOT_args); 507 } 508 /** 509 510 */ 511 void _bodyExitTree(in long arg0) 512 { 513 Array _GODOT_args = Array.empty_array; 514 _GODOT_args.append(arg0); 515 String _GODOT_method_name = String("_body_exit_tree"); 516 this.callv(_GODOT_method_name, _GODOT_args); 517 } 518 /** 519 520 */ 521 void setAxisLock(in long axis, in bool lock) 522 { 523 checkClassBinding!(typeof(this))(); 524 ptrcall!(void)(_classBinding.setAxisLock, _godot_object, axis, lock); 525 } 526 /** 527 528 */ 529 bool getAxisLock(in long axis) const 530 { 531 checkClassBinding!(typeof(this))(); 532 return ptrcall!(bool)(_classBinding.getAxisLock, _godot_object, axis); 533 } 534 /** 535 Return a list of the bodies colliding with this one. By default, number of max contacts reported is at 0 , see $(D setMaxContactsReported) to increase it. Note that 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. 536 */ 537 Array getCollidingBodies() const 538 { 539 checkClassBinding!(typeof(this))(); 540 return ptrcall!(Array)(_classBinding.getCollidingBodies, _godot_object); 541 } 542 /** 543 The body mode from the MODE_* enum. Modes include: MODE_STATIC, MODE_KINEMATIC, MODE_RIGID, and MODE_CHARACTER. 544 */ 545 @property RigidBody.Mode mode() 546 { 547 return getMode(); 548 } 549 /// ditto 550 @property void mode(long v) 551 { 552 setMode(v); 553 } 554 /** 555 The body's mass. 556 */ 557 @property double mass() 558 { 559 return getMass(); 560 } 561 /// ditto 562 @property void mass(double v) 563 { 564 setMass(v); 565 } 566 /** 567 The body's weight based on its mass and the global 3D gravity. Global values are set in "Project > Project Settings > Physics > 3d". 568 */ 569 @property double weight() 570 { 571 return getWeight(); 572 } 573 /// ditto 574 @property void weight(double v) 575 { 576 setWeight(v); 577 } 578 /** 579 The body's friction, from 0 (frictionless) to 1 (max friction). 580 */ 581 @property double friction() 582 { 583 return getFriction(); 584 } 585 /// ditto 586 @property void friction(double v) 587 { 588 setFriction(v); 589 } 590 /** 591 RigidBody's bounciness. 592 */ 593 @property double bounce() 594 { 595 return getBounce(); 596 } 597 /// ditto 598 @property void bounce(double v) 599 { 600 setBounce(v); 601 } 602 /** 603 604 */ 605 @property PhysicsMaterial physicsMaterialOverride() 606 { 607 return getPhysicsMaterialOverride(); 608 } 609 /// ditto 610 @property void physicsMaterialOverride(PhysicsMaterial v) 611 { 612 setPhysicsMaterialOverride(v); 613 } 614 /** 615 This is multiplied by the global 3D gravity setting found in "Project > Project Settings > Physics > 3d" to produce RigidBody's gravity. E.g. a value of 1 will be normal gravity, 2 will apply double gravity, and 0.5 will apply half gravity to this object. 616 */ 617 @property double gravityScale() 618 { 619 return getGravityScale(); 620 } 621 /// ditto 622 @property void gravityScale(double v) 623 { 624 setGravityScale(v); 625 } 626 /** 627 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 $(D _integrateForces) function, if defined. 628 */ 629 @property bool customIntegrator() 630 { 631 return isUsingCustomIntegrator(); 632 } 633 /// ditto 634 @property void customIntegrator(bool v) 635 { 636 setUseCustomIntegrator(v); 637 } 638 /** 639 If `true` continuous collision detection is used. 640 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 less impacts by small, fast-moving objects. Not using continuous collision detection is faster to compute, but can miss small, fast-moving objects. 641 */ 642 @property bool continuousCd() 643 { 644 return isUsingContinuousCollisionDetection(); 645 } 646 /// ditto 647 @property void continuousCd(bool v) 648 { 649 setUseContinuousCollisionDetection(v); 650 } 651 /** 652 The maximum contacts to report. Bodies can keep a log of the contacts with other bodies, this is enabled by setting the maximum amount of contacts reported to a number greater than 0. 653 */ 654 @property long contactsReported() 655 { 656 return getMaxContactsReported(); 657 } 658 /// ditto 659 @property void contactsReported(long v) 660 { 661 setMaxContactsReported(v); 662 } 663 /** 664 If `true` the RigidBody will emit signals when it collides with another RigidBody. 665 */ 666 @property bool contactMonitor() 667 { 668 return isContactMonitorEnabled(); 669 } 670 /// ditto 671 @property void contactMonitor(bool v) 672 { 673 setContactMonitor(v); 674 } 675 /** 676 If `true` the body is sleeping and will not calculate forces until woken up by a collision or the `apply_impulse` method. 677 */ 678 @property bool sleeping() 679 { 680 return isSleeping(); 681 } 682 /// ditto 683 @property void sleeping(bool v) 684 { 685 setSleeping(v); 686 } 687 /** 688 If `true` the RigidBody will not calculate forces and will act as a static body while there is no movement. It will wake up when forces are applied through other collisions or when the `apply_impulse` method is used. 689 */ 690 @property bool canSleep() 691 { 692 return isAbleToSleep(); 693 } 694 /// ditto 695 @property void canSleep(bool v) 696 { 697 setCanSleep(v); 698 } 699 /** 700 Lock the body's movement in the x-axis. 701 */ 702 @property bool axisLockLinearX() 703 { 704 return getAxisLock(1); 705 } 706 /// ditto 707 @property void axisLockLinearX(bool v) 708 { 709 setAxisLock(1, v); 710 } 711 /** 712 Lock the body's movement in the x-axis. 713 */ 714 @property bool axisLockLinearY() 715 { 716 return getAxisLock(2); 717 } 718 /// ditto 719 @property void axisLockLinearY(bool v) 720 { 721 setAxisLock(2, v); 722 } 723 /** 724 Lock the body's movement in the x-axis. 725 */ 726 @property bool axisLockLinearZ() 727 { 728 return getAxisLock(4); 729 } 730 /// ditto 731 @property void axisLockLinearZ(bool v) 732 { 733 setAxisLock(4, v); 734 } 735 /** 736 Lock the body's rotation in the x-axis. 737 */ 738 @property bool axisLockAngularX() 739 { 740 return getAxisLock(8); 741 } 742 /// ditto 743 @property void axisLockAngularX(bool v) 744 { 745 setAxisLock(8, v); 746 } 747 /** 748 Lock the body's rotation in the y-axis. 749 */ 750 @property bool axisLockAngularY() 751 { 752 return getAxisLock(16); 753 } 754 /// ditto 755 @property void axisLockAngularY(bool v) 756 { 757 setAxisLock(16, v); 758 } 759 /** 760 Lock the body's rotation in the z-axis. 761 */ 762 @property bool axisLockAngularZ() 763 { 764 return getAxisLock(32); 765 } 766 /// ditto 767 @property void axisLockAngularZ(bool v) 768 { 769 setAxisLock(32, v); 770 } 771 /** 772 The body's linear velocity. Can be used sporadically, but $(B DON'T SET THIS IN EVERY FRAME), because physics may run in another thread and runs at a different granularity. Use $(D _integrateForces) as your process loop for precise control of the body state. 773 */ 774 @property Vector3 linearVelocity() 775 { 776 return getLinearVelocity(); 777 } 778 /// ditto 779 @property void linearVelocity(Vector3 v) 780 { 781 setLinearVelocity(v); 782 } 783 /** 784 The body's linear damp. Default value: -1, cannot be less than -1. If this value is different from -1, any linear damp derived from the world or areas will be overridden. 785 */ 786 @property double linearDamp() 787 { 788 return getLinearDamp(); 789 } 790 /// ditto 791 @property void linearDamp(double v) 792 { 793 setLinearDamp(v); 794 } 795 /** 796 RigidBody's rotational velocity. 797 */ 798 @property Vector3 angularVelocity() 799 { 800 return getAngularVelocity(); 801 } 802 /// ditto 803 @property void angularVelocity(Vector3 v) 804 { 805 setAngularVelocity(v); 806 } 807 /** 808 Damps RigidBody's rotational forces. 809 */ 810 @property double angularDamp() 811 { 812 return getAngularDamp(); 813 } 814 /// ditto 815 @property void angularDamp(double v) 816 { 817 setAngularDamp(v); 818 } 819 }