move Filament headers to own directory under iOS/macOS

This commit is contained in:
Nick Fisher
2023-10-03 00:15:41 +08:00
parent 423f563350
commit 2a3a99c974
412 changed files with 8665 additions and 52334 deletions

View File

@@ -25,10 +25,7 @@
#include <stdint.h>
#include <sys/types.h>
namespace filament {
namespace math {
namespace details {
// -------------------------------------------------------------------------------------
namespace filament::math::details {
/*
* No user serviceable parts here.
@@ -49,7 +46,7 @@ namespace details {
template<template<typename T> class QUATERNION, typename T>
class TQuatProductOperators {
public:
/* compound assignment from a another quaternion of the same size but different
/* compound assignment from another quaternion of the same size but different
* element type.
*/
template<typename OTHER>
@@ -85,7 +82,7 @@ public:
* (the first one, BASE<T> being known).
*/
/* The operators below handle operation between quaternion of the same size
/* The operators below handle operation between quaternions of the same size
* but of a different element type.
*/
template<typename RT>
@@ -127,19 +124,19 @@ public:
*/
friend inline
constexpr QUATERNION<T> MATH_PURE operator*(QUATERNION<T> q, T scalar) {
// don't pass q by reference because we need a copy anyways
// don't pass q by reference because we need a copy anyway
return q *= scalar;
}
friend inline
constexpr QUATERNION<T> MATH_PURE operator*(T scalar, QUATERNION<T> q) {
// don't pass q by reference because we need a copy anyways
// don't pass q by reference because we need a copy anyway
return q *= scalar;
}
friend inline
constexpr QUATERNION<T> MATH_PURE operator/(QUATERNION<T> q, T scalar) {
// don't pass q by reference because we need a copy anyways
// don't pass q by reference because we need a copy anyway
return q /= scalar;
}
};
@@ -283,9 +280,6 @@ public:
}
};
// -------------------------------------------------------------------------------------
} // namespace details
} // namespace math
} // namespace filament
} // namespace filament::math::details
#endif // TNT_MATH_TQUATHELPERS_H

View File

@@ -443,6 +443,37 @@ private:
return v;
}
template<typename U>
friend inline
VECTOR<T> MATH_PURE fmod(VECTOR<T> const& x, VECTOR<U> const& y) {
VECTOR<T> r;
for (size_t i = 0; i < r.size(); i++) {
r[i] = std::fmod(x[i], y[i]);
}
return r;
}
template<typename U>
friend inline
VECTOR<T> MATH_PURE remainder(VECTOR<T> const& x, VECTOR<U> const& y) {
VECTOR<T> r;
for (size_t i = 0; i < r.size(); i++) {
r[i] = std::remainder(x[i], y[i]);
}
return r;
}
template<typename U>
friend inline
VECTOR<T> MATH_PURE remquo(VECTOR<T> const& x, VECTOR<U> const& y,
VECTOR<int>* q) {
VECTOR<T> r;
for (size_t i = 0; i < r.size(); i++) {
r[i] = std::remquo(x[i], y[i], &((*q)[i]));
}
return r;
}
friend inline VECTOR<T> MATH_PURE inversesqrt(VECTOR<T> v) {
for (size_t i = 0; i < v.size(); i++) {
v[i] = T(1) / std::sqrt(v[i]);

View File

@@ -160,7 +160,7 @@ constexpr inline half makeHalf(uint16_t bits) noexcept {
#endif // __ARM_NEON
inline constexpr half operator "" _h(long double v) {
inline constexpr half operator""_h(long double v) {
return half( static_cast<float>(v) );
}

View File

@@ -235,23 +235,6 @@ public:
return r;
}
// returns false if the two matrices are different. May return false if they're the
// same, with some elements only differing by +0 or -0. Behaviour is undefined with NaNs.
static constexpr bool fuzzyEqual(TMat22 l, TMat22 r) noexcept {
uint64_t const* const li = reinterpret_cast<uint64_t const*>(&l);
uint64_t const* const ri = reinterpret_cast<uint64_t const*>(&r);
uint64_t result = 0;
// For some reason clang is not able to vectoize this loop when the number of iteration
// is known and constant (!?!?!). Still this is better than operator==.
#if defined(__clang__)
#pragma clang loop vectorize_width(2)
#endif
for (size_t i = 0; i < sizeof(TMat22) / sizeof(uint64_t); i++) {
result |= li[i] ^ ri[i];
}
return result != 0;
}
template<typename A>
static constexpr TMat22 translation(const TVec2<A>& t) noexcept {
TMat22 r;

View File

@@ -272,24 +272,6 @@ public:
template<typename U, typename V>
constexpr TMat44(const TMat33<U>& matrix, const TVec4<V>& column3) noexcept;
/*
* helpers
*/
// returns false if the two matrices are different. May return false if they're the
// same, with some elements only differing by +0 or -0. Behaviour is undefined with NaNs.
static constexpr bool fuzzyEqual(TMat44 const& l, TMat44 const& r) noexcept {
uint64_t const* const li = reinterpret_cast<uint64_t const*>(&l);
uint64_t const* const ri = reinterpret_cast<uint64_t const*>(&r);
uint64_t result = 0;
// For some reason clang is not able to vectorize this loop when the number of iteration
// is known and constant (!?!?!). Still this is better than operator==.
for (size_t i = 0; i < sizeof(TMat44) / sizeof(uint64_t); i++) {
result |= li[i] ^ ri[i];
}
return result != 0;
}
static constexpr TMat44 ortho(T left, T right, T bottom, T top, T near, T far) noexcept;
static constexpr TMat44 frustum(T left, T right, T bottom, T top, T near, T far) noexcept;

View File

@@ -33,8 +33,7 @@
#include <stdint.h>
namespace filament {
namespace math {
namespace filament::math {
namespace details {
template<typename T> class TVec2;
@@ -45,6 +44,8 @@ template<typename T> class TMat22;
template<typename T> class TMat33;
template<typename T> class TMat44;
template<typename T> class TQuaternion;
} // namespace details
using double2 = details::TVec2<double>;
@@ -86,8 +87,10 @@ using mat3f = details::TMat33<float>;
using mat4 = details::TMat44<double>;
using mat4f = details::TMat44<float>;
} // namespace math
} // namespace filament
using quat = details::TQuaternion<double>;
using quatf = details::TQuaternion<float>;
} // namespace filament::math
#endif // _MSC_VER

View File

@@ -26,10 +26,7 @@
#include <stdint.h>
#include <sys/types.h>
namespace filament {
namespace math {
// -------------------------------------------------------------------------------------
namespace filament::math {
namespace details {
template<typename T>
@@ -89,15 +86,15 @@ public:
// constructors
// leaves object uninitialized. use with caution.
// Leaves object uninitialized. Use with caution.
explicit constexpr TQuaternion(no_init) {}
// default constructor. sets all values to zero.
constexpr TQuaternion() : x(0), y(0), z(0), w(0) {}
// handles implicit conversion to a quat. must not be explicit.
// Handles implicit conversion to a quat. Must not be explicit.
template<typename A, typename = enable_if_arithmetic_t<A>>
constexpr TQuaternion(A w) : x(0), y(0), z(0), w(w) {}
constexpr TQuaternion(A w) : x(0), y(0), z(0), w(w) {} // NOLINT(google-explicit-constructor)
// initialize from 4 values to w + xi + yj + zk
template<typename A, typename B, typename C, typename D,
@@ -175,31 +172,29 @@ typedef details::TQuaternion<float> quatf;
typedef details::TQuaternion<half> quath;
constexpr inline quat operator "" _i(long double v) {
return quat(0.0, double(v), 0.0, 0.0);
return { 0.0, double(v), 0.0, 0.0 };
}
constexpr inline quat operator "" _j(long double v) {
return quat(0.0, 0.0, double(v), 0.0);
return { 0.0, 0.0, double(v), 0.0 };
}
constexpr inline quat operator "" _k(long double v) {
return quat(0.0, 0.0, 0.0, double(v));
return { 0.0, 0.0, 0.0, double(v) };
}
constexpr inline quat operator "" _i(unsigned long long v) {
return quat(0.0, double(v), 0.0, 0.0);
return { 0.0, double(v), 0.0, 0.0 };
}
constexpr inline quat operator "" _j(unsigned long long v) {
return quat(0.0, 0.0, double(v), 0.0);
return { 0.0, 0.0, double(v), 0.0 };
}
constexpr inline quat operator "" _k(unsigned long long v) {
return quat(0.0, 0.0, 0.0, double(v));
return { 0.0, 0.0, 0.0, double(v) };
}
// ----------------------------------------------------------------------------------------
} // namespace math
} // namespace filament
} // namespace filament::math
#endif // TNT_MATH_QUAT_H