Fix crash when rubber band hits its owner

This commit is contained in:
Benau 2022-05-20 08:17:15 +08:00
parent f61dcb2ec3
commit 3b0df18167

View File

@ -200,8 +200,9 @@ void RubberBand::update(int ticks)
m_plunger->setKeepAlive(0); m_plunger->setKeepAlive(0);
return; return;
} }
// diff can be zero if the rubber band hits its owner
diff.normalize(); // diff can't be zero here if (diff.x() != 0.0f && diff.y() != 0.0f && diff.z() != 0.0f)
diff.normalize();
m_owner->getBody()->applyCentralForce(diff*force); m_owner->getBody()->applyCentralForce(diff*force);
m_owner->increaseMaxSpeed(MaxSpeed::MS_INCREASE_RUBBER, m_owner->increaseMaxSpeed(MaxSpeed::MS_INCREASE_RUBBER,
kp->getPlungerBandSpeedIncrease(), kp->getPlungerBandSpeedIncrease(),