Fix #101877, rigidbodies & constraints causing frequent crashes. #108399
|
@ -26,6 +26,7 @@ btTypedConstraint::btTypedConstraint(btTypedConstraintType type, btRigidBody& rb
|
|||
m_breakingImpulseThreshold(SIMD_INFINITY),
|
||||
m_isEnabled(true),
|
||||
m_needsFeedback(false),
|
||||
m_isValid(true),
|
||||
m_overrideNumSolverIterations(-1),
|
||||
m_rbA(rbA),
|
||||
m_rbB(getFixedBody()),
|
||||
|
@ -42,6 +43,7 @@ btTypedConstraint::btTypedConstraint(btTypedConstraintType type, btRigidBody& rb
|
|||
m_breakingImpulseThreshold(SIMD_INFINITY),
|
||||
m_isEnabled(true),
|
||||
m_needsFeedback(false),
|
||||
m_isValid(true),
|
||||
m_overrideNumSolverIterations(-1),
|
||||
m_rbA(rbA),
|
||||
m_rbB(rbB),
|
||||
|
|
|
@ -84,7 +84,8 @@ btTypedConstraint : public btTypedObject
|
|||
btScalar m_breakingImpulseThreshold;
|
||||
bool m_isEnabled;
|
||||
bool m_needsFeedback;
|
||||
int m_overrideNumSolverIterations;
|
||||
bool m_isValid;
|
||||
int m_overrideNumSolverIterations;
|
||||
|
||||
btTypedConstraint& operator=(btTypedConstraint& other)
|
||||
{
|
||||
|
@ -199,18 +200,14 @@ public:
|
|||
}
|
||||
|
||||
bool isValid() const{
|
||||
return (&m_rbA)&&(&m_rbB);
|
||||
return m_isValid;
|
||||
}
|
||||
|
||||
void invalidate(){
|
||||
if(isValid()){
|
||||
m_rbA.removeConstraintRef(this);
|
||||
m_rbB.removeConstraintRef(this);
|
||||
//force set m_rbA & m_rbB to NULL.
|
||||
// why are they references?
|
||||
void **p=(void**)&m_appliedImpulse;
|
||||
p[-2]=nullptr;
|
||||
p[-1]=nullptr;
|
||||
m_isValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue