/** * Copyright (c) Facebook, Inc. and its affiliates. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. */ #pragma once #include #include #include #include #include #include /** * All the mathfu:: implementations of our core data types. */ template struct Bounds { mathfu::Vector min; mathfu::Vector max; bool initialized = false; void Clear() { min = mathfu::Vector(); max = mathfu::Vector(); initialized = false; } void AddPoint(const mathfu::Vector& p) { if (initialized) { for (int ii = 0; ii < d; ii++) { min(ii) = std::min(min(ii), p(ii)); max(ii) = std::max(max(ii), p(ii)); } } else { min = p; max = p; initialized = true; } } }; typedef mathfu::Vector Vec4i; typedef mathfu::Matrix Mat4i; typedef mathfu::Vector Vec2f; typedef mathfu::Vector Vec3f; typedef mathfu::Vector Vec4f; typedef mathfu::Matrix Mat2f; typedef mathfu::Matrix Mat3f; typedef mathfu::Matrix Mat4f; typedef mathfu::Quaternion Quatf; typedef Bounds Boundsf; #define VEC3F_ONE (Vec3f{1.0f}) #define VEC3F_ZERO (Vec3f{0.0f}) #define VEC4F_ONE (Vec4f{1.0f}) #define VEC4F_ZERO (Vec4f{0.0f}) template inline std::vector toStdVec(const mathfu::Vector& vec) { std::vector result(d); for (int ii = 0; ii < d; ii++) { result[ii] = vec[ii]; } return result; } template std::vector toStdVec(const mathfu::Quaternion& quat) { return std::vector{quat.vector()[0], quat.vector()[1], quat.vector()[2], quat.scalar()}; } inline Vec3f toVec3f(const FbxDouble3& v) { return Vec3f((float)v[0], (float)v[1], (float)v[2]); } inline Vec3f toVec3f(const FbxVector4& v) { return Vec3f((float)v[0], (float)v[1], (float)v[2]); } inline Vec4f toVec4f(const FbxVector4& v) { return Vec4f((float)v[0], (float)v[1], (float)v[2], (float)v[3]); } inline Mat4f toMat4f(const FbxAMatrix& m) { auto result = Mat4f(); for (int row = 0; row < 4; row++) { for (int col = 0; col < 4; col++) { result(row, col) = (float)m[row][col]; } } return result; } inline Quatf toQuatf(const FbxQuaternion& q) { return Quatf((float)q[3], (float)q[0], (float)q[1], (float)q[2]); }