123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- #pragma once
- #include <Mathematics/Logger.h>
- #include <Mathematics/Vector2.h>
- namespace WwiseGTE
- {
- template <typename Real, typename TriangleMesh>
- class IntpLinearNonuniform2
- {
- public:
-
- IntpLinearNonuniform2(TriangleMesh const& mesh, Real const* F)
- :
- mMesh(&mesh),
- mF(F)
- {
- LogAssert(mF != nullptr, "Invalid input.");
- }
-
-
-
- bool operator()(Vector2<Real> const& P, Real& F) const
- {
- int t = mMesh->GetContainingTriangle(P);
- if (t == -1)
- {
-
- return false;
- }
-
-
- std::array<Real, 3> bary;
- if (!mMesh->GetBarycentrics(t, P, bary))
- {
-
-
- return false;
- }
-
- std::array<int, 3> indices;
- mMesh->GetIndices(t, indices);
- F = bary[0] * mF[indices[0]] + bary[1] * mF[indices[1]] + bary[2] * mF[indices[2]];
- return true;
- }
- private:
- TriangleMesh const* mMesh;
- Real const* mF;
- };
- }
|