123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- #pragma once
- #include <Mathematics/FeatureKey.h>
- namespace WwiseGTE
- {
- template <bool Ordered>
- class TetrahedronKey : public FeatureKey<4, Ordered>
- {
- public:
- TetrahedronKey()
- {
- this->V = { -1, -1, -1, -1 };
- }
- explicit TetrahedronKey(int v0, int v1, int v2, int v3)
- {
- Initialize(v0, v1, v2, v3);
- }
-
-
-
-
-
- static inline std::array<std::array<int, 3>, 4> const& GetOppositeFace()
- {
- static std::array<std::array<int, 3>, 4> const sOppositeFace =
- {{
- { 1, 2, 3 },
- { 0, 3, 2 },
- { 0, 1, 3 },
- { 0, 2, 1 }
- }};
- return sOppositeFace;
- }
- private:
- template <bool Dummy = Ordered>
- typename std::enable_if<Dummy, void>::type
- Initialize(int v0, int v1, int v2, int v3)
- {
- int imin = 0;
- this->V[0] = v0;
- if (v1 < this->V[0])
- {
- this->V[0] = v1;
- imin = 1;
- }
- if (v2 < this->V[0])
- {
- this->V[0] = v2;
- imin = 2;
- }
- if (v3 < this->V[0])
- {
- this->V[0] = v3;
- imin = 3;
- }
- if (imin == 0)
- {
- Permute(v1, v2, v3);
- }
- else if (imin == 1)
- {
- Permute(v0, v3, v2);
- }
- else if (imin == 2)
- {
- Permute(v0, v1, v3);
- }
- else
- {
- Permute(v0, v2, v1);
- }
- }
- template <bool Dummy = Ordered>
- typename std::enable_if<!Dummy, void>::type
- Initialize(int v0, int v1, int v2, int v3)
- {
- this->V[0] = v0;
- this->V[1] = v1;
- this->V[2] = v2;
- this->V[3] = v3;
- std::sort(this->V.begin(), this->V.end());
- }
- template <bool Dummy = Ordered>
- typename std::enable_if<Dummy, void>::type
- Permute(int u0, int u1, int u2)
- {
-
-
-
-
-
- if (u0 < u1)
- {
- if (u0 < u2)
- {
-
- this->V[1] = u0;
- this->V[2] = u1;
- this->V[3] = u2;
- }
- else
- {
-
- this->V[1] = u2;
- this->V[2] = u0;
- this->V[3] = u1;
- }
- }
- else
- {
- if (u1 < u2)
- {
-
- this->V[1] = u1;
- this->V[2] = u2;
- this->V[3] = u0;
- }
- else
- {
-
- this->V[1] = u2;
- this->V[2] = u0;
- this->V[3] = u1;
- }
- }
- }
- };
- }
|