From 15740faf9fe9fe4be08965098bbf2947e096aeeb Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 14 Aug 2019 22:50:43 +0800 Subject: +Unity Runtime code --- Runtime/Physics2D/HingeJoint2D.h | 61 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 Runtime/Physics2D/HingeJoint2D.h (limited to 'Runtime/Physics2D/HingeJoint2D.h') diff --git a/Runtime/Physics2D/HingeJoint2D.h b/Runtime/Physics2D/HingeJoint2D.h new file mode 100644 index 0000000..6da16b7 --- /dev/null +++ b/Runtime/Physics2D/HingeJoint2D.h @@ -0,0 +1,61 @@ +#pragma once + +#if ENABLE_2D_PHYSICS || DOXYGEN + +#include "Runtime/Math/Vector2.h" +#include "Joint2D.h" + +class Vector2f; + + +// -------------------------------------------------------------------------- + + +class HingeJoint2D : public Joint2D +{ +public: + + REGISTER_DERIVED_CLASS (HingeJoint2D, Joint2D) + DECLARE_OBJECT_SERIALIZE (HingeJoint2D) + + HingeJoint2D (MemLabelId label, ObjectCreationMode mode); + // virtual ~HingeJoint2D (); declared-by-macro + + virtual void CheckConsistency(); + virtual void Reset (); + + Vector2f GetAnchor () const { return m_Anchor; } + virtual void SetAnchor (const Vector2f& anchor); + + Vector2f GetConnectedAnchor () const { return m_ConnectedAnchor; } + virtual void SetConnectedAnchor (const Vector2f& anchor); + + bool GetUseMotor () const { return m_UseMotor; } + void SetUseMotor (bool enable); + + bool GetUseLimits () const { return m_UseLimits; } + void SetUseLimits (bool enable); + + JointMotor2D GetMotor () const { return m_Motor; } + void SetMotor (const JointMotor2D& motor); + + JointAngleLimits2D GetLimits () const { return m_AngleLimits; } + void SetLimits (const JointAngleLimits2D& limits); + +protected: + virtual void Create (); + virtual void ReCreate(); + +protected: + Vector2f m_Anchor; ///< The local-space anchor from the base rigid-body. + Vector2f m_ConnectedAnchor; ///< The local-space anchor from the connected rigid-body. + JointMotor2D m_Motor; ///< The joint motor. + JointAngleLimits2D m_AngleLimits; ///< The joint angle limits. + bool m_UseMotor; ///< Whether to use the joint motor or not. + bool m_UseLimits; ///< Whether to use the angle limits or not. + +private: + float m_OldReferenceAngle; +}; + +#endif -- cgit v1.1-26-g67d0