ConstraintGear2D.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Copyright (c) 2008-2023 the Urho3D project
  2. // License: MIT
  3. #pragma once
  4. #include "../Physics2D/Constraint2D.h"
  5. namespace Urho3D
  6. {
  7. /// 2D gear constraint component.
  8. class URHO3D_API ConstraintGear2D : public Constraint2D
  9. {
  10. URHO3D_OBJECT(ConstraintGear2D, Constraint2D);
  11. public:
  12. /// Construct.
  13. explicit ConstraintGear2D(Context* context);
  14. /// Destruct.
  15. ~ConstraintGear2D() override;
  16. /// Register object factory.
  17. /// @nobind
  18. static void RegisterObject(Context* context);
  19. /// Set owner constraint.
  20. /// @property
  21. void SetOwnerConstraint(Constraint2D* constraint);
  22. /// Set other constraint.
  23. /// @property
  24. void SetOtherConstraint(Constraint2D* constraint);
  25. /// Set ratio.
  26. /// @property
  27. void SetRatio(float ratio);
  28. /// Return owner constraint.
  29. /// @property
  30. Constraint2D* GetOwnerConstraint() const { return ownerConstraint_; }
  31. /// Return other constraint.
  32. /// @property
  33. Constraint2D* GetOtherConstraint() const { return otherConstraint_; }
  34. /// Return ratio.
  35. /// @property
  36. float GetRatio() const { return jointDef_.ratio; }
  37. private:
  38. /// Return joint def.
  39. b2JointDef* GetJointDef() override;
  40. /// Box2D joint def.
  41. b2GearJointDef jointDef_;
  42. /// Owner body constraint.
  43. WeakPtr<Constraint2D> ownerConstraint_;
  44. /// Other body constraint.
  45. WeakPtr<Constraint2D> otherConstraint_;
  46. };
  47. }