Upgrade Bullet to version 2.83.
[blender.git] / extern / bullet2 / src / BulletDynamics / ConstraintSolver / btHingeConstraint.h
index 7c33ac24e05752f15d599a6a3d8d5cf53eaeb4b3..f26e72105ba72e77e99f8c4bb0096b55606e158c 100644 (file)
@@ -41,7 +41,8 @@ enum btHingeFlags
 {
        BT_HINGE_FLAGS_CFM_STOP = 1,
        BT_HINGE_FLAGS_ERP_STOP = 2,
-       BT_HINGE_FLAGS_CFM_NORM = 4
+       BT_HINGE_FLAGS_CFM_NORM = 4,
+       BT_HINGE_FLAGS_ERP_NORM = 8
 };
 
 
@@ -94,6 +95,7 @@ public:
 
        int                     m_flags;
        btScalar        m_normalCFM;
+       btScalar        m_normalERP;
        btScalar        m_stopCFM;
        btScalar        m_stopERP;
 
@@ -175,6 +177,7 @@ public:
        //       maintain a given angular target.
        void enableMotor(bool enableMotor)      { m_enableAngularMotor = enableMotor; }
        void setMaxMotorImpulse(btScalar maxMotorImpulse) { m_maxMotorImpulse = maxMotorImpulse; }
+       void setMotorTargetVelocity(btScalar motorTargetVelocity) { m_motorTargetVelocity = motorTargetVelocity; }
        void setMotorTarget(const btQuaternion& qAinB, btScalar dt); // qAinB is rotation of body A wrt body B.
        void setMotorTarget(btScalar targetAngle, btScalar dt);
 
@@ -191,6 +194,33 @@ public:
                m_relaxationFactor = _relaxationFactor;
 #endif
        }
+       
+       btScalar getLimitSoftness() const
+       {
+#ifdef _BT_USE_CENTER_LIMIT_
+               return m_limit.getSoftness();
+#else
+               return m_limitSoftness;
+#endif
+       }
+
+       btScalar getLimitBiasFactor() const
+       {
+#ifdef _BT_USE_CENTER_LIMIT_
+               return m_limit.getBiasFactor();
+#else
+               return m_biasFactor;
+#endif
+       }
+
+       btScalar getLimitRelaxationFactor() const
+       {
+#ifdef _BT_USE_CENTER_LIMIT_
+               return m_limit.getRelaxationFactor();
+#else
+               return m_relaxationFactor;
+#endif
+       }
 
        void    setAxis(btVector3& axisInA)
        {
@@ -217,6 +247,14 @@ public:
 
        }
 
+    bool hasLimit() const {
+#ifdef  _BT_USE_CENTER_LIMIT_
+        return m_limit.getHalfRange() > 0;
+#else
+        return m_lowerLimit <= m_upperLimit;
+#endif
+    }
+
        btScalar        getLowerLimit() const
        {
 #ifdef _BT_USE_CENTER_LIMIT_
@@ -236,6 +274,7 @@ public:
        }
 
 
+       ///The getHingeAngle gives the hinge angle in range [-PI,PI]
        btScalar getHingeAngle();
 
        btScalar getHingeAngle(const btTransform& transA,const btTransform& transB);
@@ -286,13 +325,20 @@ public:
        // access for UseFrameOffset
        bool getUseFrameOffset() { return m_useOffsetForConstraintFrame; }
        void setUseFrameOffset(bool frameOffsetOnOff) { m_useOffsetForConstraintFrame = frameOffsetOnOff; }
-
+       // access for UseReferenceFrameA
+       bool getUseReferenceFrameA() const { return m_useReferenceFrameA; }
+       void setUseReferenceFrameA(bool useReferenceFrameA) { m_useReferenceFrameA = useReferenceFrameA; }
 
        ///override the default global value of a parameter (such as ERP or CFM), optionally provide the axis (0..5). 
        ///If no axis is provided, it uses the default axis for this constraint.
        virtual void    setParam(int num, btScalar value, int axis = -1);
        ///return the local value of parameter
        virtual btScalar getParam(int num, int axis = -1) const;
+       
+       virtual int getFlags() const
+       {
+           return m_flags;
+       }
 
        virtual int     calculateSerializeBufferSize() const;
 
@@ -326,6 +372,43 @@ struct     btHingeConstraintDoubleData
 };
 #endif //BT_BACKWARDS_COMPATIBLE_SERIALIZATION
 
+///The getAccumulatedHingeAngle returns the accumulated hinge angle, taking rotation across the -PI/PI boundary into account
+ATTRIBUTE_ALIGNED16(class) btHingeAccumulatedAngleConstraint : public btHingeConstraint
+{
+protected:
+       btScalar        m_accumulatedAngle;
+public:
+
+       BT_DECLARE_ALIGNED_ALLOCATOR();
+       
+       btHingeAccumulatedAngleConstraint(btRigidBody& rbA,btRigidBody& rbB, const btVector3& pivotInA,const btVector3& pivotInB, const btVector3& axisInA,const btVector3& axisInB, bool useReferenceFrameA = false)
+       :btHingeConstraint(rbA,rbB,pivotInA,pivotInB, axisInA,axisInB, useReferenceFrameA )
+       {
+               m_accumulatedAngle=getHingeAngle();
+       }
+
+       btHingeAccumulatedAngleConstraint(btRigidBody& rbA,const btVector3& pivotInA,const btVector3& axisInA, bool useReferenceFrameA = false)
+       :btHingeConstraint(rbA,pivotInA,axisInA, useReferenceFrameA)
+       {
+               m_accumulatedAngle=getHingeAngle();
+       }
+       
+       btHingeAccumulatedAngleConstraint(btRigidBody& rbA,btRigidBody& rbB, const btTransform& rbAFrame, const btTransform& rbBFrame, bool useReferenceFrameA = false)
+       :btHingeConstraint(rbA,rbB, rbAFrame, rbBFrame, useReferenceFrameA )
+       {
+               m_accumulatedAngle=getHingeAngle();
+       }
+
+       btHingeAccumulatedAngleConstraint(btRigidBody& rbA,const btTransform& rbAFrame, bool useReferenceFrameA = false)
+       :btHingeConstraint(rbA,rbAFrame, useReferenceFrameA )
+       {
+               m_accumulatedAngle=getHingeAngle();
+       }
+       btScalar getAccumulatedHingeAngle();
+       void    setAccumulatedHingeAngle(btScalar accAngle);
+       virtual void getInfo1 (btConstraintInfo1* info);
+
+};
 
 struct btHingeConstraintFloatData
 {