react to very small vectors instead of just zero-length ones

This commit is contained in:
Seth Alves 2017-05-03 20:23:10 -07:00
parent f867a8e718
commit c693687927

View file

@ -104,12 +104,12 @@ btTypedConstraint* ObjectConstraintHinge::getConstraint() {
return nullptr;
}
if (glm::length(axisInA) == 0.0f) {
if (glm::length(axisInA) < FLT_EPSILON) {
qCWarning(physics) << "hinge axis cannot be a zero vector";
axisInA = DEFAULT_HINGE_AXIS;
}
} else {
axisInA = glm::normalize(axisInA);
}
if (!otherEntityID.isNull()) {
// This hinge is between two entities... find the other rigid body.
@ -118,12 +118,12 @@ btTypedConstraint* ObjectConstraintHinge::getConstraint() {
return nullptr;
}
if (glm::length(axisInB)) {
if (glm::length(axisInB) < FLT_EPSILON) {
qCWarning(physics) << "hinge axis cannot be a zero vector";
axisInB = DEFAULT_HINGE_AXIS;
}
} else {
axisInB = glm::normalize(axisInB);
}
constraint = new btHingeConstraint(*rigidBodyA, *rigidBodyB,
glmToBullet(pivotInA), glmToBullet(pivotInB),