Fix #101877, rigidbodies & constraints causing frequent crashes. #108399

Open
himisa wants to merge 5 commits from himisa/blender:fix_rigid_crash into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
2 changed files with 6 additions and 7 deletions
Showing only changes of commit 9708f1688d - Show all commits

View File

@ -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),

View File

@ -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;
}
}