PhysicsWorld2D.pkg 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. RigidBody2D* GetRigidBody(int screenX, int screenY, unsigned collisionMask = M_MAX_UNSIGNED);
  33. // void GetRigidBodies(PODVector<RigidBody2D*>& result, const Rect& aabb, unsigned collisionMask = M_MAX_UNSIGNED);
  34. tolua_outside const PODVector<RigidBody2D*>& PhysicsWorld2DGetRigidBodies @ GetRigidBodies(const Rect& aabb, unsigned collisionMask = M_MAX_UNSIGNED);
  35. bool GetDrawShape() const;
  36. bool GetDrawJoint() const;
  37. bool GetDrawAabb() const;
  38. bool GetDrawPair() const;
  39. bool GetDrawCenterOfMass() const;
  40. bool GetAllowSleeping() const;
  41. bool GetWarmStarting() const;
  42. bool GetContinuousPhysics() const;
  43. bool GetSubStepping() const;
  44. bool GetAutoClearForces() const;
  45. const Vector2& GetGravity() const;
  46. int GetVelocityIterations() const;
  47. int GetPositionIterations() const;
  48. tolua_property__get_set bool drawShape;
  49. tolua_property__get_set bool drawJoint;
  50. tolua_property__get_set bool drawAabb;
  51. tolua_property__get_set bool drawPair;
  52. tolua_property__get_set bool drawCenterOfMass;
  53. tolua_property__get_set bool allowSleeping;
  54. tolua_property__get_set bool warmStarting;
  55. tolua_property__get_set bool continuousPhysics;
  56. tolua_property__get_set bool subStepping;
  57. tolua_property__get_set bool autoClearForces;
  58. tolua_property__get_set Vector2& gravity;
  59. tolua_property__get_set int velocityIterations;
  60. tolua_property__get_set int positionIterations;
  61. };
  62. ${
  63. const PODVector<PhysicsRaycastResult2D>& PhysicsWorld2DRaycast(PhysicsWorld2D* physicsWorld, const Vector2& startPoint, const Vector2& endPoint, unsigned collisionMask = M_MAX_UNSIGNED)
  64. {
  65. static PODVector<PhysicsRaycastResult2D> results;
  66. results.Clear();
  67. physicsWorld->Raycast(results, startPoint, endPoint, collisionMask);
  68. return results;
  69. }
  70. PhysicsRaycastResult2D PhysicsWorld2DRaycastSingle(PhysicsWorld2D* physicsWorld, const Vector2& startPoint, const Vector2& endPoint, unsigned collisionMask = M_MAX_UNSIGNED)
  71. {
  72. PhysicsRaycastResult2D result;
  73. physicsWorld->RaycastSingle(result, startPoint, endPoint, collisionMask);
  74. return result;
  75. }
  76. const PODVector<RigidBody2D*>& PhysicsWorld2DGetRigidBodies(PhysicsWorld2D* physicsWorld, const Rect& aabb, unsigned collisionMask = M_MAX_UNSIGNED)
  77. {
  78. static PODVector<RigidBody2D*> results;
  79. results.Clear();
  80. physicsWorld->GetRigidBodies(results, aabb, collisionMask);
  81. return results;
  82. }
  83. $}