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