update macos/ios to Filament v1.51.2

This commit is contained in:
Nick Fisher
2024-04-20 13:46:58 +08:00
parent 15882891e2
commit ea04e94c1f
156 changed files with 5394 additions and 5884 deletions

View File

@@ -17,15 +17,21 @@
#ifndef TNT_MATH_MAT3_H
#define TNT_MATH_MAT3_H
#include <math/TMatHelpers.h>
#include <math/compiler.h>
#include <math/quat.h>
#include <math/vec3.h>
#include <math/TMatHelpers.h>
#include <math/TVecHelpers.h>
#include <limits.h>
#include <stdint.h>
#include <sys/types.h>
#include <cmath>
#include <assert.h>
#include <stddef.h>
namespace filament {
namespace math {
// -------------------------------------------------------------------------------------
@@ -289,6 +295,14 @@ public:
return matrix::cof(m);
}
/*
* Returns a matrix representing the pose of a virtual camera looking towards -Z in its
* local Y-up coordinate system. "up" defines where the Y axis of the camera's local coordinate
* system is.
*/
template<typename A, typename B>
static TMat33 lookTo(const TVec3<A>& direction, const TVec3<B>& up) noexcept;
/**
* Packs the tangent frame represented by the specified matrix into a quaternion.
* Reflection is preserved by encoding it as the sign of the w component in the
@@ -406,6 +420,29 @@ constexpr TMat33<T>::TMat33(const TQuaternion<U>& q) noexcept : m_value{} {
m_value[2] = col_type(xz + yw, yz - xw, 1 - xx - yy); // NOLINT
}
template<typename T>
constexpr T dot_tolerance() noexcept;
template<>
constexpr float dot_tolerance<float>() noexcept { return 0.999f; }
template<>
constexpr double dot_tolerance<double>() noexcept { return 0.9999; }
template<typename T>
template<typename A, typename B>
TMat33<T> TMat33<T>::lookTo(const TVec3<A>& direction, const TVec3<B>& up) noexcept {
auto const z_axis = direction;
auto norm_up = up;
if (std::abs(dot(z_axis, norm_up)) > dot_tolerance< arithmetic_result_t<A, B> >()) {
// Fix up vector if we're degenerate (looking straight up, basically)
norm_up = { norm_up.z, norm_up.x, norm_up.y };
}
auto const x_axis = normalize(cross(z_axis, norm_up));
auto const y_axis = cross(x_axis, z_axis);
return { x_axis, y_axis, -z_axis };
}
//------------------------------------------------------------------------------
template<typename T>
constexpr TQuaternion<T> TMat33<T>::packTangentFrame(const TMat33<T>& m, size_t storageSize) noexcept {