PhysicsWorld2D.pkg 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. $#include "Urho2D/PhysicsWorld2D.h"
  2. struct PhysicsRaycastResult2D
  3. {
  4. PhysicsRaycastResult2D();
  5. ~PhysicsRaycastResult2D();
  6. Vector2 position_ @ position;
  7. Vector2 normal_ @ normal;
  8. float distance_ @ distance;
  9. RigidBody2D* body_ @ body;
  10. };
  11. class PhysicsWorld2D : Component
  12. {
  13. void DrawDebugGeometry();
  14. void SetUpdateEnabled(bool enable);
  15. void SetDrawShape(bool drawShape);
  16. void SetDrawJoint(bool drawJoint);
  17. void SetDrawAabb(bool drawAabb);
  18. void SetDrawPair(bool drawPair);
  19. void SetDrawCenterOfMass(bool drawCenterOfMass);
  20. void SetAllowSleeping(bool enable);
  21. void SetWarmStarting(bool enable);
  22. void SetContinuousPhysics(bool enable);
  23. void SetSubStepping(bool enable);
  24. void SetGravity(const Vector2& gravity);
  25. void SetAutoClearForces(bool enable);
  26. void SetVelocityIterations(int velocityIterations);
  27. void SetPositionIterations(int positionIterations);
  28. // void Raycast(PODVector<PhysicsRaycastResult2D>& results, const Vector2& startPoint, const Vector2& endPoint, unsigned collisionMask = M_MAX_UNSIGNED);
  29. tolua_outside const PODVector<PhysicsRaycastResult2D>& PhysicsWorld2DRaycast @ Raycast(const Vector2& startPoint, const Vector2& endPoint, unsigned collisionMask = M_MAX_UNSIGNED);
  30. // void RaycastSingle(PhysicsRaycastResult2D& result, const Vector2& startPoint, const Vector2& endPoint, unsigned collisionMask = M_MAX_UNSIGNED);
  31. tolua_outside PhysicsRaycastResult2D PhysicsWorld2DRaycastSingle @ RaycastSingle(const Vector2& startPoint, const Vector2& endPoint, unsigned collisionMask = M_MAX_UNSIGNED);
  32. RigidBody2D* GetRigidBody(const Vector2& point, unsigned collisionMask = M_MAX_UNSIGNED);
  33. RigidBody2D* GetRigidBody(int screenX, int screenY, unsigned collisionMask = M_MAX_UNSIGNED);
  34. // void GetRigidBodies(PODVector<RigidBody2D*>& result, const Rect& aabb, unsigned collisionMask = M_MAX_UNSIGNED);
  35. tolua_outside const PODVector<RigidBody2D*>& PhysicsWorld2DGetRigidBodies @ GetRigidBodies(const Rect& aabb, unsigned collisionMask = M_MAX_UNSIGNED);
  36. bool IsUpdateEnabled() const;
  37. bool GetDrawShape() const;
  38. bool GetDrawJoint() const;
  39. bool GetDrawAabb() const;
  40. bool GetDrawPair() const;
  41. bool GetDrawCenterOfMass() const;
  42. bool GetAllowSleeping() const;
  43. bool GetWarmStarting() const;
  44. bool GetContinuousPhysics() const;
  45. bool GetSubStepping() const;
  46. bool GetAutoClearForces() const;
  47. const Vector2& GetGravity() const;
  48. int GetVelocityIterations() const;
  49. int GetPositionIterations() const;
  50. tolua_property__is_set bool updateEnabled;
  51. tolua_property__get_set bool drawShape;
  52. tolua_property__get_set bool drawJoint;
  53. tolua_property__get_set bool drawAabb;
  54. tolua_property__get_set bool drawPair;
  55. tolua_property__get_set bool drawCenterOfMass;
  56. tolua_property__get_set bool allowSleeping;
  57. tolua_property__get_set bool warmStarting;
  58. tolua_property__get_set bool continuousPhysics;
  59. tolua_property__get_set bool subStepping;
  60. tolua_property__get_set bool autoClearForces;
  61. tolua_property__get_set Vector2& gravity;
  62. tolua_property__get_set int velocityIterations;
  63. tolua_property__get_set int positionIterations;
  64. };
  65. ${
  66. const PODVector<PhysicsRaycastResult2D>& PhysicsWorld2DRaycast(PhysicsWorld2D* physicsWorld, const Vector2& startPoint, const Vector2& endPoint, unsigned collisionMask = M_MAX_UNSIGNED)
  67. {
  68. static PODVector<PhysicsRaycastResult2D> results;
  69. results.Clear();
  70. physicsWorld->Raycast(results, startPoint, endPoint, collisionMask);
  71. return results;
  72. }
  73. PhysicsRaycastResult2D PhysicsWorld2DRaycastSingle(PhysicsWorld2D* physicsWorld, const Vector2& startPoint, const Vector2& endPoint, unsigned collisionMask = M_MAX_UNSIGNED)
  74. {
  75. PhysicsRaycastResult2D result;
  76. physicsWorld->RaycastSingle(result, startPoint, endPoint, collisionMask);
  77. return result;
  78. }
  79. const PODVector<RigidBody2D*>& PhysicsWorld2DGetRigidBodies(PhysicsWorld2D* physicsWorld, const Rect& aabb, unsigned collisionMask = M_MAX_UNSIGNED)
  80. {
  81. static PODVector<RigidBody2D*> results;
  82. results.Clear();
  83. physicsWorld->GetRigidBodies(results, aabb, collisionMask);
  84. return results;
  85. }
  86. $}