Mesh: [skip ci] when points lie exactly on a plane it can happen that a plane fit creates U,V vectors with NaN while W is valid
This commit is contained in:
@@ -220,12 +220,26 @@ float PlaneFit::Fit()
|
||||
|
||||
// It may happen that the result have nan values
|
||||
for (int i=0; i<3; i++) {
|
||||
if (boost::math::isnan(U[i]) ||
|
||||
boost::math::isnan(V[i]) ||
|
||||
boost::math::isnan(W[i]))
|
||||
if (boost::math::isnan(W[i]))
|
||||
return FLOAT_MAX;
|
||||
}
|
||||
|
||||
// In some cases when the points exactly lie on a plane it can happen that
|
||||
// U or V have nan values but W is valid.
|
||||
// In this case create an orthonormal basis
|
||||
bool validUV = true;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (boost::math::isnan(U[i]) ||
|
||||
boost::math::isnan(V[i])) {
|
||||
validUV = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!validUV) {
|
||||
Wm4::Vector3<double>::GenerateOrthonormalBasis(U, V, W);
|
||||
}
|
||||
|
||||
_vDirU.Set(float(U.X()), float(U.Y()), float(U.Z()));
|
||||
_vDirV.Set(float(V.X()), float(V.Y()), float(V.Z()));
|
||||
_vDirW.Set(float(W.X()), float(W.Y()), float(W.Z()));
|
||||
|
||||
Reference in New Issue
Block a user