PhysicsWorld2D.pkg 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. $#include "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 SetDrawShape(bool drawShape);
  15. void SetDrawJoint(bool drawJoint);
  16. void SetDrawAabb(bool drawAabb);
  17. void SetDrawPair(bool drawPair);
  18. void SetDrawCenterOfMass(bool drawCenterOfMass);
  19. void SetAllowSleeping(bool enable);
  20. void SetWarmStarting(bool enable);
  21. void SetContinuousPhysics(bool enable);
  22. void SetSubStepping(bool enable);
  23. void SetGravity(const Vector2& gravity);
  24. void SetAutoClearForces(bool enable);
  25. void SetVelocityIterations(int velocityIterations);
  26. void SetPositionIterations(int positionIterations);
  27. // void Raycast(PODVector<PhysicsRaycastResult2D>& results, const Vector2& startPoint, const Vector2& endPoint, unsigned collisionMask = M_MAX_UNSIGNED);
  28. tolua_outside const PODVector<PhysicsRaycastResult2D>& PhysicsWorld2DRaycast @ Raycast(const Vector2& startPoint, const Vector2& endPoint, unsigned collisionMask = M_MAX_UNSIGNED);
  29. // void RaycastSingle(PhysicsRaycastResult2D& result, const Vector2& startPoint, const Vector2& endPoint, unsigned collisionMask = M_MAX_UNSIGNED);
  30. tolua_outside PhysicsRaycastResult2D PhysicsWorld2DRaycastSingle @ RaycastSingle(const Vector2& startPoint, const Vector2& endPoint, unsigned collisionMask = M_MAX_UNSIGNED);
  31. RigidBody2D* GetRigidBody(const Vector2& point, unsigned collisionMask = M_MAX_UNSIGNED);
  32. // void GetRigidBodies(PODVector<RigidBody2D*>& result, const Rect& aabb, unsigned collisionMask = M_MAX_UNSIGNED);
  33. tolua_outside const PODVector<RigidBody2D*>& PhysicsWorld2DGetRigidBodies @ GetRigidBodies(const Rect& aabb, unsigned collisionMask = M_MAX_UNSIGNED);
  34. bool GetDrawShape() const;
  35. bool GetDrawJoint() const;
  36. bool GetDrawAabb() const;
  37. bool GetDrawPair() const;
  38. bool GetDrawCenterOfMass() const;
  39. bool GetAllowSleeping() const;
  40. bool GetWarmStarting() const;
  41. bool GetContinuousPhysics() const;
  42. bool GetSubStepping() const;
  43. bool GetAutoClearForces() const;
  44. const Vector2& GetGravity() const;
  45. int GetVelocityIterations() const;
  46. int GetPositionIterations() const;
  47. tolua_property__get_set bool drawShape;
  48. tolua_property__get_set bool drawJoint;
  49. tolua_property__get_set bool drawAabb;
  50. tolua_property__get_set bool drawPair;
  51. tolua_property__get_set bool drawCenterOfMass;
  52. tolua_property__get_set bool allowSleeping;
  53. tolua_property__get_set bool warmStarting;
  54. tolua_property__get_set bool continuousPhysics;
  55. tolua_property__get_set bool subStepping;
  56. tolua_property__get_set bool autoClearForces;
  57. tolua_property__get_set Vector2& gravity;
  58. tolua_property__get_set int velocityIterations;
  59. tolua_property__get_set int positionIterations;
  60. };
  61. ${
  62. const PODVector<PhysicsRaycastResult2D>& PhysicsWorld2DRaycast(PhysicsWorld2D* physicsWorld, const Vector2& startPoint, const Vector2& endPoint, unsigned collisionMask = M_MAX_UNSIGNED)
  63. {
  64. static PODVector<PhysicsRaycastResult2D> results;
  65. results.Clear();
  66. physicsWorld->Raycast(results, startPoint, endPoint, collisionMask);
  67. return results;
  68. }
  69. PhysicsRaycastResult2D PhysicsWorld2DRaycastSingle(PhysicsWorld2D* physicsWorld, const Vector2& startPoint, const Vector2& endPoint, unsigned collisionMask = M_MAX_UNSIGNED)
  70. {
  71. PhysicsRaycastResult2D result;
  72. physicsWorld->RaycastSingle(result, startPoint, endPoint, collisionMask);
  73. return result;
  74. }
  75. const PODVector<RigidBody2D*>& PhysicsWorld2DGetRigidBodies(PhysicsWorld2D* physicsWorld, const Rect& aabb, unsigned collisionMask = M_MAX_UNSIGNED)
  76. {
  77. static PODVector<RigidBody2D*> results;
  78. results.Clear();
  79. physicsWorld->GetRigidBodies(results, aabb, collisionMask);
  80. return results;
  81. }
  82. $}