mathlib: GLM_InterpolateNormal: quick hack to fix build of testlight
This commit is contained in:
parent
100d364edf
commit
76d0dae890
|
|
@ -599,6 +599,17 @@ std::pair<int, qvec3f> GLM_ClosestPointOnPolyBoundary(const std::vector<qvec3f>
|
||||||
|
|
||||||
std::pair<bool, qvec3f> GLM_InterpolateNormal(
|
std::pair<bool, qvec3f> GLM_InterpolateNormal(
|
||||||
const std::vector<qvec3f> &points, const std::vector<face_normal_t> &normals, const qvec3f &point)
|
const std::vector<qvec3f> &points, const std::vector<face_normal_t> &normals, const qvec3f &point)
|
||||||
|
{
|
||||||
|
std::vector<qvec3f> normalvecs;
|
||||||
|
for (auto& normal : normals) {
|
||||||
|
normalvecs.push_back(normal.normal);
|
||||||
|
}
|
||||||
|
|
||||||
|
return GLM_InterpolateNormal(points, normalvecs, point);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::pair<bool, qvec3f> GLM_InterpolateNormal(
|
||||||
|
const std::vector<qvec3f> &points, const std::vector<qvec3f> &normals, const qvec3f &point)
|
||||||
{
|
{
|
||||||
Q_assert(points.size() == normals.size());
|
Q_assert(points.size() == normals.size());
|
||||||
|
|
||||||
|
|
@ -608,14 +619,14 @@ std::pair<bool, qvec3f> GLM_InterpolateNormal(
|
||||||
// Step through the triangles, being careful to handle zero-size ones
|
// Step through the triangles, being careful to handle zero-size ones
|
||||||
|
|
||||||
const qvec3f &p0 = points.at(0);
|
const qvec3f &p0 = points.at(0);
|
||||||
const qvec3f &n0 = normals.at(0).normal;
|
const qvec3f &n0 = normals.at(0);
|
||||||
|
|
||||||
const int N = points.size();
|
const int N = points.size();
|
||||||
for (int i = 2; i < N; i++) {
|
for (int i = 2; i < N; i++) {
|
||||||
const qvec3f &p1 = points.at(i - 1);
|
const qvec3f &p1 = points.at(i - 1);
|
||||||
const qvec3f &n1 = normals.at(i - 1).normal;
|
const qvec3f &n1 = normals.at(i - 1);
|
||||||
const qvec3f &p2 = points.at(i);
|
const qvec3f &p2 = points.at(i);
|
||||||
const qvec3f &n2 = normals.at(i).normal;
|
const qvec3f &n2 = normals.at(i);
|
||||||
|
|
||||||
const auto edgeplanes = GLM_MakeInwardFacingEdgePlanes({p0, p1, p2});
|
const auto edgeplanes = GLM_MakeInwardFacingEdgePlanes({p0, p1, p2});
|
||||||
if (edgeplanes.size() != 3)
|
if (edgeplanes.size() != 3)
|
||||||
|
|
|
||||||
|
|
@ -304,6 +304,8 @@ std::pair<int, qvec3f> GLM_ClosestPointOnPolyBoundary(const std::vector<qvec3f>
|
||||||
/// Returns `true` and the interpolated normal if `point` is in the polygon, otherwise returns false.
|
/// Returns `true` and the interpolated normal if `point` is in the polygon, otherwise returns false.
|
||||||
std::pair<bool, qvec3f> GLM_InterpolateNormal(
|
std::pair<bool, qvec3f> GLM_InterpolateNormal(
|
||||||
const std::vector<qvec3f> &points, const std::vector<face_normal_t> &normals, const qvec3f &point);
|
const std::vector<qvec3f> &points, const std::vector<face_normal_t> &normals, const qvec3f &point);
|
||||||
|
std::pair<bool, qvec3f> GLM_InterpolateNormal(
|
||||||
|
const std::vector<qvec3f> &points, const std::vector<qvec3f> &normals, const qvec3f &point);
|
||||||
std::vector<qvec3f> GLM_ShrinkPoly(const std::vector<qvec3f> &poly, const float amount);
|
std::vector<qvec3f> GLM_ShrinkPoly(const std::vector<qvec3f> &poly, const float amount);
|
||||||
/// Returns (front part, back part)
|
/// Returns (front part, back part)
|
||||||
std::pair<std::vector<qvec3f>, std::vector<qvec3f>> GLM_ClipPoly(const std::vector<qvec3f> &poly, const qvec4f &plane);
|
std::pair<std::vector<qvec3f>, std::vector<qvec3f>> GLM_ClipPoly(const std::vector<qvec3f> &poly, const qvec4f &plane);
|
||||||
|
|
|
||||||
|
|
@ -282,7 +282,7 @@ TEST(mathlib, DistAbovePlane)
|
||||||
|
|
||||||
TEST(mathlib, InterpolateNormalsDegenerate)
|
TEST(mathlib, InterpolateNormalsDegenerate)
|
||||||
{
|
{
|
||||||
EXPECT_FALSE(GLM_InterpolateNormal({}, {}, qvec3f(0, 0, 0)).first);
|
EXPECT_FALSE(GLM_InterpolateNormal({}, std::vector<qvec3f>{}, 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(0, 0, 1)}, qvec3f(0, 0, 0)).first);
|
||||||
EXPECT_FALSE(
|
EXPECT_FALSE(
|
||||||
GLM_InterpolateNormal({qvec3f(0, 0, 0), qvec3f(10, 0, 0)}, {qvec3f(0, 0, 1), qvec3f(0, 0, 1)}, qvec3f(0, 0, 0))
|
GLM_InterpolateNormal({qvec3f(0, 0, 0), qvec3f(10, 0, 0)}, {qvec3f(0, 0, 1), qvec3f(0, 0, 1)}, qvec3f(0, 0, 0))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue