light: make GLM_InterpolateNormal return failure on degenerate input
This commit is contained in:
parent
95e9fdcd21
commit
6b14e166b8
|
|
@ -704,6 +704,9 @@ std::pair<bool, qvec3f> GLM_InterpolateNormal(const std::vector<qvec3f> &points,
|
|||
{
|
||||
Q_assert(points.size() == normals.size());
|
||||
|
||||
if (points.size() < 3)
|
||||
return make_pair(false, qvec3f(0));
|
||||
|
||||
// Step through the triangles, being careful to handle zero-size ones
|
||||
|
||||
const qvec3f &p0 = points.at(0);
|
||||
|
|
|
|||
|
|
@ -319,6 +319,12 @@ TEST(mathlib, ProjectPointOntoPlane) {
|
|||
EXPECT_FLOAT_EQ(10, projected[2]);
|
||||
}
|
||||
|
||||
TEST(mathlib, InterpolateNormalsDegenerate) {
|
||||
EXPECT_FALSE(GLM_InterpolateNormal({}, {}, qvec3f(0,0,0)).first);
|
||||
EXPECT_FALSE(GLM_InterpolateNormal({qvec3f(0,0,0)}, {qvec3f(0,0,1)}, qvec3f(0,0,0)).first);
|
||||
EXPECT_FALSE(GLM_InterpolateNormal({qvec3f(0,0,0), qvec3f(10,0,0)}, {qvec3f(0,0,1), qvec3f(0,0,1)}, qvec3f(0,0,0)).first);
|
||||
}
|
||||
|
||||
TEST(mathlib, InterpolateNormals) {
|
||||
// This test relies on the way GLM_InterpolateNormal is implemented
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue