소스 검색

Add a query to check if joints are broken

Panagiotis Christopoulos Charitos 7 년 전
부모
커밋
2a981b263b
2개의 변경된 파일9개의 추가작업 그리고 2개의 파일을 삭제
  1. 8 1
      src/anki/physics/PhysicsJoint.h
  2. 1 1
      src/anki/scene/components/JointComponent.cpp

+ 8 - 1
src/anki/physics/PhysicsJoint.h

@@ -19,11 +19,18 @@ class PhysicsJoint : public PhysicsObject
 public:
 	static const PhysicsObjectType CLASS_TYPE = PhysicsObjectType::JOINT;
 
+	/// Set the breaking impulse.
 	void setBreakingImpulseThreshold(F32 impulse)
 	{
 		m_joint->setBreakingImpulseThreshold(impulse);
 	}
 
+	/// Return true if the joint broke.
+	Bool isBroken() const
+	{
+		return !m_joint->isEnabled();
+	}
+
 protected:
 	btTypedConstraint* m_joint = nullptr;
 	PhysicsBodyPtr m_bodyA;
@@ -36,7 +43,7 @@ protected:
 	void addToWorld();
 };
 
-/// Point 2 point joint.
+/// Point to point joint.
 class PhysicsPoint2PointJoint : public PhysicsJoint
 {
 	ANKI_PHYSICS_OBJECT

+ 1 - 1
src/anki/scene/components/JointComponent.cpp

@@ -125,7 +125,7 @@ Error JointComponent::update(Second prevTime, Second crntTime, Bool& updated)
 		Bool erasedOne = false;
 		for(auto node : m_jointList)
 		{
-			if(node.m_parentNode != m_node->getParent())
+			if(node.m_parentNode != m_node->getParent() || node.m_joint->isBroken())
 			{
 				m_jointList.erase(&node);
 				getAllocator().deleteInstance(&node);