Move math namespace to fix #746.

This commit is contained in:
prideout
2019-02-07 09:23:07 -08:00
committed by Philip Rideout
parent 6089be6de6
commit 5ee359cf40
155 changed files with 746 additions and 717 deletions
@@ -48,7 +48,7 @@ Java_com_google_android_filament_Camera_nSetCustomProjection(JNIEnv *env, jclass
jlong nativeCamera, jdoubleArray inMatrix_, jdouble near, jdouble far) {
Camera *camera = (Camera *) nativeCamera;
jdouble *inMatrix = env->GetDoubleArrayElements(inMatrix_, NULL);
camera->setCustomProjection(*reinterpret_cast<const math::mat4 *>(inMatrix), near, far);
camera->setCustomProjection(*reinterpret_cast<const filament::math::mat4 *>(inMatrix), near, far);
env->ReleaseDoubleArrayElements(inMatrix_, inMatrix, JNI_ABORT);
}
@@ -78,7 +78,7 @@ Java_com_google_android_filament_Camera_nSetModelMatrix(JNIEnv *env, jclass,
jlong nativeCamera, jfloatArray in_) {
Camera* camera = (Camera *) nativeCamera;
jfloat *in = env->GetFloatArrayElements(in_, NULL);
camera->setModelMatrix(*reinterpret_cast<const math::mat4f*>(in));
camera->setModelMatrix(*reinterpret_cast<const filament::math::mat4f*>(in));
env->ReleaseFloatArrayElements(in_, in, JNI_ABORT);
}
@@ -87,7 +87,7 @@ Java_com_google_android_filament_Camera_nGetProjectionMatrix(JNIEnv *env, jclass
jlong nativeCamera, jdoubleArray out_) {
Camera *camera = (Camera *) nativeCamera;
jdouble *out = env->GetDoubleArrayElements(out_, NULL);
const math::mat4& m = camera->getProjectionMatrix();
const filament::math::mat4& m = camera->getProjectionMatrix();
std::copy_n(&m[0][0], 16, out);
env->ReleaseDoubleArrayElements(out_, out, 0);
}
@@ -97,7 +97,7 @@ Java_com_google_android_filament_Camera_nGetModelMatrix(JNIEnv *env, jclass,
jlong nativeCamera, jfloatArray out_) {
Camera *camera = (Camera *) nativeCamera;
jfloat *out = env->GetFloatArrayElements(out_, NULL);
const math::mat4f& m = camera->getModelMatrix();
const filament::math::mat4f& m = camera->getModelMatrix();
std::copy_n(&m[0][0], 16, out);
env->ReleaseFloatArrayElements(out_, out, 0);
}
@@ -107,7 +107,7 @@ Java_com_google_android_filament_Camera_nGetViewMatrix(JNIEnv *env, jclass, jlon
jfloatArray out_) {
Camera *camera = (Camera *) nativeCamera;
jfloat *out = env->GetFloatArrayElements(out_, NULL);
const math::mat4f& m = camera->getViewMatrix();
const filament::math::mat4f& m = camera->getViewMatrix();
std::copy_n(&m[0][0], 16, out);
env->ReleaseFloatArrayElements(out_, out, 0);
}
@@ -117,7 +117,7 @@ Java_com_google_android_filament_Camera_nGetPosition(JNIEnv *env, jclass, jlong
jfloatArray out_) {
Camera *camera = (Camera *) nativeCamera;
jfloat *out = env->GetFloatArrayElements(out_, NULL);
reinterpret_cast<math::float3&>(*out) = camera->getPosition();
reinterpret_cast<filament::math::float3&>(*out) = camera->getPosition();
env->ReleaseFloatArrayElements(out_, out, 0);
}
@@ -126,7 +126,7 @@ Java_com_google_android_filament_Camera_nGetLeftVector(JNIEnv *env, jclass, jlon
jfloatArray out_) {
Camera *camera = (Camera *) nativeCamera;
jfloat *out = env->GetFloatArrayElements(out_, NULL);
reinterpret_cast<math::float3&>(*out) = camera->getLeftVector();
reinterpret_cast<filament::math::float3&>(*out) = camera->getLeftVector();
env->ReleaseFloatArrayElements(out_, out, 0);
}
@@ -135,7 +135,7 @@ Java_com_google_android_filament_Camera_nGetUpVector(JNIEnv *env, jclass, jlong
jfloatArray out_) {
Camera *camera = (Camera *) nativeCamera;
jfloat *out = env->GetFloatArrayElements(out_, NULL);
reinterpret_cast<math::float3&>(*out) = camera->getUpVector();
reinterpret_cast<filament::math::float3&>(*out) = camera->getUpVector();
env->ReleaseFloatArrayElements(out_, out, 0);
}
@@ -144,7 +144,7 @@ Java_com_google_android_filament_Camera_nGetForwardVector(JNIEnv *env, jclass,
jlong nativeCamera, jfloatArray out_) {
Camera *camera = (Camera *) nativeCamera;
jfloat *out = env->GetFloatArrayElements(out_, NULL);
reinterpret_cast<math::float3&>(*out) = camera->getForwardVector();
reinterpret_cast<filament::math::float3&>(*out) = camera->getForwardVector();
env->ReleaseFloatArrayElements(out_, out, 0);
}
@@ -53,7 +53,7 @@ Java_com_google_android_filament_IndirectLight_nIrradiance(JNIEnv* env, jclass,
jlong nativeBuilder, jint bands, jfloatArray sh_) {
IndirectLight::Builder* builder = (IndirectLight::Builder*) nativeBuilder;
jfloat* sh = env->GetFloatArrayElements(sh_, NULL);
builder->irradiance((uint8_t) bands, (const math::float3*) sh);
builder->irradiance((uint8_t) bands, (const filament::math::float3*) sh);
env->ReleaseFloatArrayElements(sh_, sh, JNI_ABORT);
}
@@ -77,7 +77,7 @@ Java_com_google_android_filament_IndirectLight_nRotation(JNIEnv *, jclass, jlong
jfloat v0, jfloat v1, jfloat v2, jfloat v3, jfloat v4, jfloat v5, jfloat v6, jfloat v7,
jfloat v8) {
IndirectLight::Builder *builder = (IndirectLight::Builder *) nativeBuilder;
builder->rotation(math::mat3f{v0, v1, v2, v3, v4, v5, v6, v7, v8});
builder->rotation(filament::math::mat3f{v0, v1, v2, v3, v4, v5, v6, v7, v8});
}
@@ -101,5 +101,5 @@ Java_com_google_android_filament_IndirectLight_nSetRotation(JNIEnv *env, jclass
jlong nativeIndirectLight, jfloat v0, jfloat v1, jfloat v2, jfloat v3, jfloat v4, jfloat v5,
jfloat v6, jfloat v7, jfloat v8) {
IndirectLight *indirectLight = (IndirectLight *) nativeIndirectLight;
indirectLight->setRotation(math::mat3f{v0, v1, v2, v3, v4, v5, v6, v7, v8});
indirectLight->setRotation(filament::math::mat3f{v0, v1, v2, v3, v4, v5, v6, v7, v8});
}
@@ -174,7 +174,7 @@ Java_com_google_android_filament_LightManager_nGetPosition(JNIEnv *env, jclass t
jlong nativeLightManager, jint i, jfloatArray out_) {
LightManager *lm = (LightManager *) nativeLightManager;
jfloat *out = env->GetFloatArrayElements(out_, NULL);
*reinterpret_cast<math::float3 *>(out) = lm->getPosition((LightManager::Instance) i);
*reinterpret_cast<filament::math::float3 *>(out) = lm->getPosition((LightManager::Instance) i);
env->ReleaseFloatArrayElements(out_, out, 0);
}
@@ -190,7 +190,7 @@ Java_com_google_android_filament_LightManager_nGetDirection(JNIEnv *env, jclass
jlong nativeLightManager, jint i, jfloatArray out_) {
LightManager *lm = (LightManager *) nativeLightManager;
jfloat *out = env->GetFloatArrayElements(out_, NULL);
*reinterpret_cast<math::float3 *>(out) = lm->getDirection((LightManager::Instance) i);
*reinterpret_cast<filament::math::float3 *>(out) = lm->getDirection((LightManager::Instance) i);
env->ReleaseFloatArrayElements(out_, out, 0);
}
@@ -206,7 +206,7 @@ Java_com_google_android_filament_LightManager_nGetColor(JNIEnv *env, jclass type
jlong nativeLightManager, jint i, jfloatArray out_) {
LightManager *lm = (LightManager *) nativeLightManager;
jfloat *out = env->GetFloatArrayElements(out_, NULL);
*reinterpret_cast<math::float3 *>(out) = lm->getColor((LightManager::Instance) i);
*reinterpret_cast<filament::math::float3 *>(out) = lm->getColor((LightManager::Instance) i);
env->ReleaseFloatArrayElements(out_, out, 0);
}
@@ -47,14 +47,14 @@ extern "C"
JNIEXPORT void JNICALL
Java_com_google_android_filament_MaterialInstance_nSetParameterBool2(JNIEnv *env, jclass,
jlong nativeMaterialInstance, jstring name_, jboolean x, jboolean y) {
setParameter(env, nativeMaterialInstance, name_, math::bool2{x, y});
setParameter(env, nativeMaterialInstance, name_, filament::math::bool2{x, y});
}
extern "C"
JNIEXPORT void JNICALL
Java_com_google_android_filament_MaterialInstance_nSetParameterBool3(JNIEnv *env, jclass,
jlong nativeMaterialInstance, jstring name_, jboolean x, jboolean y, jboolean z) {
setParameter(env, nativeMaterialInstance, name_, math::bool3{x, y, z});
setParameter(env, nativeMaterialInstance, name_, filament::math::bool3{x, y, z});
}
extern "C"
@@ -62,7 +62,7 @@ JNIEXPORT void JNICALL
Java_com_google_android_filament_MaterialInstance_nSetParameterBool4(JNIEnv *env, jclass,
jlong nativeMaterialInstance, jstring name_,
jboolean x, jboolean y, jboolean z, jboolean w) {
setParameter(env, nativeMaterialInstance, name_, math::bool4{x, y, z, w});
setParameter(env, nativeMaterialInstance, name_, filament::math::bool4{x, y, z, w});
}
extern "C"
@@ -76,14 +76,14 @@ extern "C"
JNIEXPORT void JNICALL
Java_com_google_android_filament_MaterialInstance_nSetParameterInt2(JNIEnv *env, jclass,
jlong nativeMaterialInstance, jstring name_, jint x, jint y) {
setParameter(env, nativeMaterialInstance, name_, math::int2{x, y});
setParameter(env, nativeMaterialInstance, name_, filament::math::int2{x, y});
}
extern "C"
JNIEXPORT void JNICALL
Java_com_google_android_filament_MaterialInstance_nSetParameterInt3(JNIEnv *env, jclass,
jlong nativeMaterialInstance, jstring name_, jint x, jint y, jint z) {
setParameter(env, nativeMaterialInstance, name_, math::int3{x, y, z});
setParameter(env, nativeMaterialInstance, name_, filament::math::int3{x, y, z});
}
extern "C"
@@ -91,7 +91,7 @@ JNIEXPORT void JNICALL
Java_com_google_android_filament_MaterialInstance_nSetParameterInt4(JNIEnv *env, jclass,
jlong nativeMaterialInstance, jstring name_,
jint x, jint y, jint z, jint w) {
setParameter(env, nativeMaterialInstance, name_, math::int4{x, y, z, w});
setParameter(env, nativeMaterialInstance, name_, filament::math::int4{x, y, z, w});
}
extern "C"
@@ -105,14 +105,14 @@ extern "C"
JNIEXPORT void JNICALL
Java_com_google_android_filament_MaterialInstance_nSetParameterFloat2(JNIEnv *env, jclass,
jlong nativeMaterialInstance, jstring name_, jfloat x, jfloat y) {
setParameter(env, nativeMaterialInstance, name_, math::float2{x, y});
setParameter(env, nativeMaterialInstance, name_, filament::math::float2{x, y});
}
extern "C"
JNIEXPORT void JNICALL
Java_com_google_android_filament_MaterialInstance_nSetParameterFloat3(JNIEnv *env, jclass,
jlong nativeMaterialInstance, jstring name_, jfloat x, jfloat y, jfloat z) {
setParameter(env, nativeMaterialInstance, name_, math::float3{x, y, z});
setParameter(env, nativeMaterialInstance, name_, filament::math::float3{x, y, z});
}
extern "C"
@@ -120,7 +120,7 @@ JNIEXPORT void JNICALL
Java_com_google_android_filament_MaterialInstance_nSetParameterFloat4(JNIEnv *env, jclass,
jlong nativeMaterialInstance, jstring name_,
jfloat x, jfloat y, jfloat z, jfloat w) {
setParameter(env, nativeMaterialInstance, name_, math::float4{x, y, z, w});
setParameter(env, nativeMaterialInstance, name_, filament::math::float4{x, y, z, w});
}
extern "C"
@@ -19,7 +19,7 @@
#include <math/mat3.h>
#include <math/quat.h>
using namespace math;
using namespace filament::math;
extern "C" JNIEXPORT void JNICALL
Java_com_google_android_filament_MathUtils_nPackTangentFrame(JNIEnv *env, jclass,
@@ -197,7 +197,7 @@ Java_com_google_android_filament_RenderableManager_nSetBonesAsMatrices(JNIEnv* e
return -1;
}
rm->setBones((RenderableManager::Instance)i,
static_cast<math::mat4f const *>(data), (size_t)boneCount, (size_t)offset);
static_cast<filament::math::mat4f const *>(data), (size_t)boneCount, (size_t)offset);
return 0;
}
@@ -277,8 +277,8 @@ Java_com_google_android_filament_RenderableManager_nGetAxisAlignedBoundingBox(JN
jfloat *center = env->GetFloatArrayElements(center_, NULL);
jfloat *halfExtent = env->GetFloatArrayElements(halfExtent_, NULL);
Box const &aabb = rm->getAxisAlignedBoundingBox((RenderableManager::Instance) i);
*reinterpret_cast<math::float3 *>(center) = aabb.center;
*reinterpret_cast<math::float3 *>(halfExtent) = aabb.halfExtent;
*reinterpret_cast<filament::math::float3 *>(center) = aabb.center;
*reinterpret_cast<filament::math::float3 *>(halfExtent) = aabb.halfExtent;
env->ReleaseFloatArrayElements(center_, center, 0);
env->ReleaseFloatArrayElements(halfExtent_, halfExtent, 0);
}
@@ -59,7 +59,7 @@ Java_com_google_android_filament_TransformManager_nCreateArray(JNIEnv* env,
if (localTransform_) {
jfloat *localTransform = env->GetFloatArrayElements(localTransform_, NULL);
tm->create(entity, (TransformManager::Instance) parent,
*reinterpret_cast<const math::mat4f *>(localTransform));
*reinterpret_cast<const filament::math::mat4f *>(localTransform));
env->ReleaseFloatArrayElements(localTransform_, localTransform, JNI_ABORT);
} else {
tm->create(entity, (TransformManager::Instance) parent);
@@ -90,7 +90,7 @@ Java_com_google_android_filament_TransformManager_nSetTransform(JNIEnv* env,
TransformManager* tm = (TransformManager*) nativeTransformManager;
jfloat *localTransform = env->GetFloatArrayElements(localTransform_, NULL);
tm->setTransform((TransformManager::Instance) i,
*reinterpret_cast<const math::mat4f *>(localTransform));
*reinterpret_cast<const filament::math::mat4f *>(localTransform));
env->ReleaseFloatArrayElements(localTransform_, localTransform, JNI_ABORT);
}
@@ -100,7 +100,7 @@ Java_com_google_android_filament_TransformManager_nGetTransform(JNIEnv* env,
jfloatArray outLocalTransform_) {
TransformManager* tm = (TransformManager*) nativeTransformManager;
jfloat *outLocalTransform = env->GetFloatArrayElements(outLocalTransform_, NULL);
*reinterpret_cast<math::mat4f *>(outLocalTransform) = tm->getTransform(
*reinterpret_cast<filament::math::mat4f *>(outLocalTransform) = tm->getTransform(
(TransformManager::Instance) i);
env->ReleaseFloatArrayElements(outLocalTransform_, outLocalTransform, 0);
}
@@ -111,7 +111,7 @@ Java_com_google_android_filament_TransformManager_nGetWorldTransform(JNIEnv* env
jfloatArray outWorldTransform_) {
TransformManager* tm = (TransformManager*) nativeTransformManager;
jfloat *outWorldTransform = env->GetFloatArrayElements(outWorldTransform_, NULL);
*reinterpret_cast<math::mat4f *>(outWorldTransform) = tm->getWorldTransform(
*reinterpret_cast<filament::math::mat4f *>(outWorldTransform) = tm->getWorldTransform(
(TransformManager::Instance) i);
env->ReleaseFloatArrayElements(outWorldTransform_, outWorldTransform, 0);
}
@@ -134,8 +134,8 @@ Java_com_google_android_filament_View_nSetDynamicResolutionOptions(JNIEnv*,
options.targetFrameTimeMilli = targetFrameTimeMilli;
options.headRoomRatio = headRoomRatio;
options.scaleRate = scaleRate;
options.minScale = math::float2{minScale};
options.maxScale = math::float2{maxScale};
options.minScale = filament::math::float2{minScale};
options.maxScale = filament::math::float2{maxScale};
options.history = (uint8_t) history;
view->setDynamicResolutionOptions(options);
}
+1 -1
View File
@@ -30,7 +30,7 @@
using namespace filament;
using namespace filament::details;
using namespace math;
using namespace filament::math;
using namespace utils;
+14 -14
View File
@@ -28,24 +28,24 @@ namespace filament {
class UTILS_PUBLIC Box {
public:
math::float3 center = {};
math::float3 halfExtent = {};
filament::math::float3 center = {};
filament::math::float3 halfExtent = {};
constexpr bool isEmpty() const noexcept {
return length2(halfExtent) == 0;
}
constexpr math::float3 getMin() const noexcept {
constexpr filament::math::float3 getMin() const noexcept {
return center - halfExtent;
}
constexpr math::float3 getMax() const noexcept {
constexpr filament::math::float3 getMax() const noexcept {
return center + halfExtent;
}
Box& set(const math::float3& min, const math::float3& max) noexcept {
center = (max + min) * math::float3(0.5f);
halfExtent = (max - min) * math::float3(0.5f);
Box& set(const filament::math::float3& min, const filament::math::float3& max) noexcept {
center = (max + min) * filament::math::float3(0.5f);
halfExtent = (max - min) * filament::math::float3(0.5f);
return *this;
}
@@ -54,22 +54,22 @@ public:
return *this;
}
constexpr Box translateTo(const math::float3& tr) const noexcept {
constexpr Box translateTo(const filament::math::float3& tr) const noexcept {
return Box{ tr, halfExtent };
}
math::float4 getBoundingSphere() const noexcept {
filament::math::float4 getBoundingSphere() const noexcept {
return { center, length(halfExtent) };
}
friend Box rigidTransform(Box const& box, const math::mat4f& m) noexcept;
friend Box rigidTransform(Box const& box, const math::mat3f& m) noexcept;
friend Box rigidTransform(Box const& box, const filament::math::mat4f& m) noexcept;
friend Box rigidTransform(Box const& box, const filament::math::mat3f& m) noexcept;
};
struct Aabb {
math::float3 min = std::numeric_limits<float>::max();
math::float3 max = std::numeric_limits<float>::lowest();
math::float3 center() const noexcept { return (min + max) * math::float3(0.5f); }
filament::math::float3 min = std::numeric_limits<float>::max();
filament::math::float3 max = std::numeric_limits<float>::lowest();
filament::math::float3 center() const noexcept { return (min + max) * filament::math::float3(0.5f); }
bool isEmpty() const noexcept {
return min >= max;
}
+16 -16
View File
@@ -201,7 +201,7 @@ public:
* @param near distance in world units from the camera to the near plane. \p near > 0.
* @param far distance in world units from the camera to the far plane. \p far > \p near.
*/
void setCustomProjection(math::mat4 const& projection, double near, double far) noexcept;
void setCustomProjection(filament::math::mat4 const& projection, double near, double far) noexcept;
/** Returns the projection matrix used for rendering.
*
@@ -212,7 +212,7 @@ public:
*
* @see setProjection, setLensProjection, setCustomProjection, getCullingProjectionMatrix
*/
const math::mat4& getProjectionMatrix() const noexcept;
const filament::math::mat4& getProjectionMatrix() const noexcept;
/** Returns the projection matrix used for culling (far plane is finite).
@@ -221,7 +221,7 @@ public:
*
* @see setProjection, setLensProjection, getProjectionMatrix
*/
const math::mat4& getCullingProjectionMatrix() const noexcept;
const filament::math::mat4& getCullingProjectionMatrix() const noexcept;
//! Returns the frustum's near plane
@@ -246,7 +246,7 @@ public:
*
* @warning \p view must be a rigid transform
*/
void setModelMatrix(const math::mat4f& view) noexcept;
void setModelMatrix(const filament::math::mat4f& view) noexcept;
/** Sets the camera's view matrix
*
@@ -254,9 +254,9 @@ public:
* @param center The position of the camera in world space.
* @param up A unit vector denoting the camera's "up" direction.
*/
void lookAt(const math::float3& eye,
const math::float3& center,
const math::float3& up = { 0, 1, 0 }) noexcept;
void lookAt(const filament::math::float3& eye,
const filament::math::float3& center,
const filament::math::float3& up = { 0, 1, 0 }) noexcept;
/** Returns the camera's model matrix
*
@@ -271,22 +271,22 @@ public:
* @return The camera's pose in world space as a rigid transform. Parent transforms, if any,
* are taken into account.
*/
math::mat4f getModelMatrix() const noexcept;
filament::math::mat4f getModelMatrix() const noexcept;
//! Returns the camera's view matrix (inverse of the model matrix)
math::mat4f getViewMatrix() const noexcept;
filament::math::mat4f getViewMatrix() const noexcept;
//! Returns the camera's position in world space
math::float3 getPosition() const noexcept;
filament::math::float3 getPosition() const noexcept;
//! Returns the camera's normalized left vector
math::float3 getLeftVector() const noexcept;
filament::math::float3 getLeftVector() const noexcept;
//! Returns the camera's normalized up vector
math::float3 getUpVector() const noexcept;
filament::math::float3 getUpVector() const noexcept;
//! Returns the camera's forward vector
math::float3 getForwardVector() const noexcept;
filament::math::float3 getForwardVector() const noexcept;
//! Returns a Frustum object in world space
Frustum getFrustum() const noexcept;
@@ -362,13 +362,13 @@ public:
* \right)
* \f$
*/
static math::mat4 inverseProjection(const math::mat4& p) noexcept;
static filament::math::mat4 inverseProjection(const filament::math::mat4& p) noexcept;
/**
* Returns the inverse of a projection matrix.
* @see inverseProjection(const math::mat4&)
* @see inverseProjection(const filament::math::mat4&)
*/
static math::mat4f inverseProjection(const math::mat4f& p) noexcept;
static filament::math::mat4f inverseProjection(const filament::math::mat4f& p) noexcept;
};
} // namespace filament
+12 -12
View File
@@ -25,14 +25,14 @@
namespace filament {
// RGB color in linear space
using LinearColor = math::float3;
using LinearColor = filament::math::float3;
// RGB color in sRGB space
using sRGBColor = math::float3;
using sRGBColor = filament::math::float3;
// RGBA color in linear space, with alpha
using LinearColorA = math::float4;
using LinearColorA = filament::math::float4;
// RGBA color in sRGB space, with alpha
using sRGBColorA = math::float4;
using sRGBColorA = filament::math::float4;
// types of RGB colors
enum class UTILS_PUBLIC RgbType : uint8_t {
@@ -74,11 +74,11 @@ class UTILS_PUBLIC Color {
public:
// converts an RGB color to linear space
// the conversion depends on the specified type
static LinearColor toLinear(RgbType type, math::float3 color);
static LinearColor toLinear(RgbType type, filament::math::float3 color);
// converts an RGBA color to linear space
// the conversion depends on the specified type
static LinearColorA toLinear(RgbaType type, math::float4 color);
static LinearColorA toLinear(RgbaType type, filament::math::float4 color);
// converts an RGB color in sRGB space to an RGB color in linear space
template<ColorConversion = ACCURATE>
@@ -109,8 +109,8 @@ public:
static LinearColor illuminantD(float K);
private:
static math::float3 sRGBToLinear(math::float3 color) noexcept;
static math::float3 linearToSRGB(math::float3 color) noexcept;
static filament::math::float3 sRGBToLinear(filament::math::float3 color) noexcept;
static filament::math::float3 linearToSRGB(filament::math::float3 color) noexcept;
};
// Use the default implementation from the header
@@ -155,18 +155,18 @@ inline sRGBColorA Color::toSRGB<ACCURATE>(LinearColorA const& color) {
return sRGBColorA{linearToSRGB(color.rgb), color.a};
}
inline LinearColor Color::toLinear(RgbType type, math::float3 color) {
inline LinearColor Color::toLinear(RgbType type, filament::math::float3 color) {
return (type == RgbType::LINEAR) ? color : Color::toLinear<ACCURATE>(color);
}
// converts an RGBA color to linear space
// the conversion depends on the specified type
inline LinearColorA Color::toLinear(RgbaType type, math::float4 color) {
inline LinearColorA Color::toLinear(RgbaType type, filament::math::float4 color) {
switch (type) {
case RgbaType::sRGB:
return Color::toLinear<ACCURATE>(color) * math::float4{color.a, color.a, color.a, 1};
return Color::toLinear<ACCURATE>(color) * filament::math::float4{color.a, color.a, color.a, 1};
case RgbaType::LINEAR:
return color * math::float4{color.a, color.a, color.a, 1};
return color * filament::math::float4{color.a, color.a, color.a, 1};
case RgbaType::PREMULTIPLIED_sRGB:
return Color::toLinear<ACCURATE>(color);
case RgbaType::PREMULTIPLIED_LINEAR:
+6 -6
View File
@@ -53,16 +53,16 @@ public:
bool setProperty(const char* name, bool v) noexcept;
bool setProperty(const char* name, int v) noexcept;
bool setProperty(const char* name, float v) noexcept;
bool setProperty(const char* name, math::float2 v) noexcept;
bool setProperty(const char* name, math::float3 v) noexcept;
bool setProperty(const char* name, math::float4 v) noexcept;
bool setProperty(const char* name, filament::math::float2 v) noexcept;
bool setProperty(const char* name, filament::math::float3 v) noexcept;
bool setProperty(const char* name, filament::math::float4 v) noexcept;
bool getProperty(const char* name, bool* v) const noexcept;
bool getProperty(const char* name, int* v) const noexcept;
bool getProperty(const char* name, float* v) const noexcept;
bool getProperty(const char* name, math::float2* v) const noexcept;
bool getProperty(const char* name, math::float3* v) const noexcept;
bool getProperty(const char* name, math::float4* v) const noexcept;
bool getProperty(const char* name, filament::math::float2* v) const noexcept;
bool getProperty(const char* name, filament::math::float3* v) const noexcept;
bool getProperty(const char* name, filament::math::float4* v) const noexcept;
template<typename T>
inline T* getPropertyAddress(const char* name) noexcept {
+7 -7
View File
@@ -51,28 +51,28 @@ public:
Frustum& operator=(Frustum&& rhs) noexcept = default;
// create a frustum from a projection matrix (usually the projection * view matrix)
explicit Frustum(const math::mat4f& pv);
explicit Frustum(const filament::math::mat4f& pv);
// set the frustum from the given projection matrix
void setProjection(const math::mat4f& pv);
void setProjection(const filament::math::mat4f& pv);
// return the plane equation parameters with normalized normals
math::float4 getNormalizedPlane(Plane plane) const noexcept;
filament::math::float4 getNormalizedPlane(Plane plane) const noexcept;
// return frustum planes in left, right, bottom, top, far, near order
void getNormalizedPlanes(math::float4 planes[6]) const noexcept;
void getNormalizedPlanes(filament::math::float4 planes[6]) const noexcept;
math::float4 const* getNormalizedPlanes() const noexcept { return mPlanes; }
filament::math::float4 const* getNormalizedPlanes() const noexcept { return mPlanes; }
// returns whether a box intersects the frustum (i.e. is visible)
bool intersects(const Box& box) const noexcept;
// returns whether a sphere intersects the frustum (i.e. is visible)
bool intersects(const math::float4& sphere) const noexcept;
bool intersects(const filament::math::float4& sphere) const noexcept;
private:
friend class details::Culler;
math::float4 mPlanes[6];
filament::math::float4 mPlanes[6];
};
+4 -4
View File
@@ -141,7 +141,7 @@ public:
* Because the coefficients are pre-scaled, `sh[0]` is the environment's
* average irradiance.
*/
Builder& irradiance(uint8_t bands, math::float3 const* sh) noexcept;
Builder& irradiance(uint8_t bands, filament::math::float3 const* sh) noexcept;
/**
* Sets the irradiance as a cubemap.
@@ -158,7 +158,7 @@ public:
* @note
* This irradiance cubemap can be generated with the **cmgen** tool.
*
* @see irradiance(uint8_t bands, math::float3 const* sh)
* @see irradiance(uint8_t bands, filament::math::float3 const* sh)
*/
Builder& irradiance(Texture const* cubemap) noexcept;
@@ -182,7 +182,7 @@ public:
*
* @return This Builder, for chaining calls.
*/
Builder& rotation(math::mat3f const& rotation) noexcept;
Builder& rotation(filament::math::mat3f const& rotation) noexcept;
/**
* Creates the IndirectLight object and returns a pointer to it.
@@ -223,7 +223,7 @@ public:
*
* @param rotation 3x3 rotation matrix. Must be a rigid-body transform.
*/
void setRotation(math::mat3f const& rotation) noexcept;
void setRotation(filament::math::mat3f const& rotation) noexcept;
};
} // namespace filament
+7 -7
View File
@@ -265,7 +265,7 @@ public:
* @note
* The Light's position is ignored for directional lights (Type.DIRECTIONAL or Type.SUN)
*/
Builder& position(const math::float3& position) noexcept;
Builder& position(const filament::math::float3& position) noexcept;
/**
* Sets the initial direction of a light in world space.
@@ -278,7 +278,7 @@ public:
* @note
* The Light's direction is ignored for Type.POINT lights.
*/
Builder& direction(const math::float3& direction) noexcept;
Builder& direction(const filament::math::float3& direction) noexcept;
/**
* Sets the initial color of a light.
@@ -477,10 +477,10 @@ public:
*
* @see Builder.position()
*/
void setPosition(Instance i, const math::float3& position) noexcept;
void setPosition(Instance i, const filament::math::float3& position) noexcept;
//! returns the light's position in world space
const math::float3& getPosition(Instance i) const noexcept;
const filament::math::float3& getPosition(Instance i) const noexcept;
/**
* Dynamically updates the light's direction
@@ -491,10 +491,10 @@ public:
*
* @see Builder.direction()
*/
void setDirection(Instance i, const math::float3& direction) noexcept;
void setDirection(Instance i, const filament::math::float3& direction) noexcept;
//! returns the light's direction in world space
const math::float3& getDirection(Instance i) const noexcept;
const filament::math::float3& getDirection(Instance i) const noexcept;
/**
* Dynamically updates the light's hue as linear sRGB
@@ -511,7 +511,7 @@ public:
* @param i Instance of the component obtained from getInstance().
* @return the light's color in linear sRGB
*/
const math::float3& getColor(Instance i) const noexcept;
const filament::math::float3& getColor(Instance i) const noexcept;
/**
* Dynamically updates the light's intensity. The intensity can be negative.
+2 -2
View File
@@ -228,7 +228,7 @@ public:
*
* @see getDefaultInstance()
*/
void setDefaultParameter(const char* name, RgbType type, math::float3 color) noexcept {
void setDefaultParameter(const char* name, RgbType type, filament::math::float3 color) noexcept {
getDefaultInstance()->setParameter(name, type, color);
}
@@ -240,7 +240,7 @@ public:
*
* @see getDefaultInstance()
*/
void setDefaultParameter(const char* name, RgbaType type, math::float4 color) noexcept {
void setDefaultParameter(const char* name, RgbaType type, filament::math::float4 color) noexcept {
getDefaultInstance()->setParameter(name, type, color);
}
+2 -2
View File
@@ -78,7 +78,7 @@ public:
* @param color Array of read, green, blue channels values.
* @throws utils::PreConditionPanic if name doesn't exist or no-op if exceptions are disabled.
*/
void setParameter(const char* name, RgbType type, math::float3 color) noexcept;
void setParameter(const char* name, RgbType type, filament::math::float3 color) noexcept;
/**
* Set an RGBA color as the named parameter.
@@ -89,7 +89,7 @@ public:
* @param color Array of read, green, blue and alpha channels values.
* @throws utils::PreConditionPanic if name doesn't exist or no-op if exceptions are disabled.
*/
void setParameter(const char* name, RgbaType type, math::float4 color) noexcept;
void setParameter(const char* name, RgbaType type, filament::math::float4 color) noexcept;
/**
* Set up a custom scissor rectangle; by default this encompasses the View.
+11 -11
View File
@@ -54,8 +54,8 @@ public:
Instance getInstance(utils::Entity e) const noexcept;
struct Bone {
math::quatf unitQuaternion = { 1, 0, 0, 0 };
math::float3 translation = { 0, 0, 0 };
filament::math::quatf unitQuaternion = { 1, 0, 0, 0 };
filament::math::float3 translation = { 0, 0, 0 };
float reserved = 0;
};
@@ -84,7 +84,7 @@ public:
Builder& receiveShadows(bool enable) noexcept; // true by default
Builder& skinning(size_t boneCount) noexcept; // 0 by default, 255 max
Builder& skinning(size_t boneCount, Bone const* bones) noexcept;
Builder& skinning(size_t boneCount, math::mat4f const* transforms) noexcept;
Builder& skinning(size_t boneCount, filament::math::mat4f const* transforms) noexcept;
// Sets an ordering index for blended primitives that all live at the same Z value.
Builder& blendOrder(size_t index, uint16_t order) noexcept; // 0 by default
@@ -140,7 +140,7 @@ public:
// Updates the bone transforms in the range [offset, offset + boneCount).
// The bones must be pre-allocated using Builder::skinning().
void setBones(Instance instance, Bone const* transforms, size_t boneCount = 1, size_t offset = 0) noexcept;
void setBones(Instance instance, math::mat4f const* transforms, size_t boneCount = 1, size_t offset = 0) noexcept;
void setBones(Instance instance, filament::math::mat4f const* transforms, size_t boneCount = 1, size_t offset = 0) noexcept;
// getters...
@@ -171,10 +171,10 @@ public:
template<typename T>
struct is_supported_vector_type {
using type = typename std::enable_if<
std::is_same<math::float4, T>::value ||
std::is_same<math::half4, T>::value ||
std::is_same<math::float3, T>::value ||
std::is_same<math::half3, T>::value
std::is_same<filament::math::float4, T>::value ||
std::is_same<filament::math::half4, T>::value ||
std::is_same<filament::math::float3, T>::value ||
std::is_same<filament::math::half3, T>::value
>::type;
};
@@ -198,12 +198,12 @@ public:
template<typename VECTOR, typename INDEX, typename, typename>
Box RenderableManager::computeAABB(VECTOR const* vertices, INDEX const* indices, size_t count,
size_t stride) noexcept {
math::float3 bmin(std::numeric_limits<float>::max());
math::float3 bmax(std::numeric_limits<float>::lowest());
filament::math::float3 bmin(std::numeric_limits<float>::max());
filament::math::float3 bmax(std::numeric_limits<float>::lowest());
for (size_t i = 0; i < count; ++i) {
VECTOR const* p = reinterpret_cast<VECTOR const*>(
(char const*)vertices + indices[i] * stride);
const math::float3 v(p->x, p->y, p->z);
const filament::math::float3 v(p->x, p->y, p->z);
bmin = min(bmin, v);
bmax = max(bmax, v);
}
+4 -4
View File
@@ -90,7 +90,7 @@ public:
*
* @see destroy()
*/
void create(utils::Entity entity, Instance parent = {}, const math::mat4f& localTransform = {});
void create(utils::Entity entity, Instance parent = {}, const filament::math::mat4f& localTransform = {});
/**
* Destroys this component from the given entity, children are orphaned.
@@ -122,7 +122,7 @@ public:
* will be particularly bad when updating a lot of transforms. In that case,
* consider using openLocalTransformTransaction() / commitLocalTransformTransaction().
*/
void setTransform(Instance ci, const math::mat4f& localTransform) noexcept;
void setTransform(Instance ci, const filament::math::mat4f& localTransform) noexcept;
/**
* Returns the local transform of a transform component.
@@ -131,7 +131,7 @@ public:
* returns the value set by setTransform().
* @see setTransform()
*/
const math::mat4f& getTransform(Instance ci) const noexcept;
const filament::math::mat4f& getTransform(Instance ci) const noexcept;
/**
* Return the world transform of a transform component.
@@ -141,7 +141,7 @@ public:
* transform.
* @see setTransform()
*/
const math::mat4f& getWorldTransform(Instance ci) const noexcept;
const filament::math::mat4f& getWorldTransform(Instance ci) const noexcept;
/**
* Opens a local transform transaction. During a transaction, getWorldTransform() can
+2 -2
View File
@@ -123,9 +123,9 @@ public:
size_t quatCount; // required
void* outBuffer; // required
size_t outStride; // required stride in bytes
const math::float3* normals; // required source data
const filament::math::float3* normals; // required source data
size_t normalsStride; // optional stride in bytes (assumes packed)
const math::float4* tangents; // optional source data
const filament::math::float4* tangents; // optional source data
size_t tangentsStride; // optional stride in bytes (assumes packed)
};
+3 -3
View File
@@ -97,7 +97,7 @@ public:
DynamicResolutionOptions() = default;
DynamicResolutionOptions(bool enabled, float scaleRate,
math::float2 minScale, math::float2 maxScale)
filament::math::float2 minScale, filament::math::float2 maxScale)
: minScale(minScale), maxScale(maxScale),
scaleRate(scaleRate), enabled(enabled) {
// this one exists for backward compatibility
@@ -105,8 +105,8 @@ public:
explicit DynamicResolutionOptions(bool enabled) : enabled(enabled) { }
math::float2 minScale = math::float2(0.5f); //!< minimum scale factors in x and y
math::float2 maxScale = math::float2(1.0f); //!< maximum scale factors in x and y
filament::math::float2 minScale = filament::math::float2(0.5f); //!< minimum scale factors in x and y
filament::math::float2 maxScale = filament::math::float2(1.0f); //!< maximum scale factors in x and y
float scaleRate = 0.125f; //!< rate at which the scale will change
float targetFrameTimeMilli = 1000.0f / 60.0f; //!< desired frame time, or budget.
float headRoomRatio = 0.0f; //!< additional headroom for the GPU
+1 -1
View File
@@ -46,7 +46,7 @@ public:
bool empty() const noexcept { return !width || !height; }
Viewport scale(math::float2 s) const noexcept;
Viewport scale(filament::math::float2 s) const noexcept;
// left coordinate in pixels
int32_t left = 0;
+3 -3
View File
@@ -16,16 +16,16 @@
#include <filament/Box.h>
using namespace math;
using namespace filament::math;
namespace filament {
Box rigidTransform(Box const& UTILS_RESTRICT box, const math::mat4f& UTILS_RESTRICT m) noexcept {
Box rigidTransform(Box const& UTILS_RESTRICT box, const filament::math::mat4f& UTILS_RESTRICT m) noexcept {
const mat3f u(m.upperLeft());
return { u * box.center + m[3].xyz, abs(u) * box.halfExtent };
}
Box rigidTransform(Box const& UTILS_RESTRICT box, const math::mat3f& UTILS_RESTRICT u) noexcept {
Box rigidTransform(Box const& UTILS_RESTRICT box, const filament::math::mat3f& UTILS_RESTRICT u) noexcept {
return { u * box.center, abs(u) * box.halfExtent };
}
+11 -11
View File
@@ -25,7 +25,7 @@
#include <math/scalar.h>
using namespace math;
using namespace filament::math;
using namespace utils;
namespace filament {
@@ -68,7 +68,7 @@ void FCamera::setLensProjection(double focalLength, double near, double far) noe
* All methods for setting the projection funnel through here
*/
void UTILS_NOINLINE FCamera::setCustomProjection(math::mat4 const& p, double near, double far) noexcept {
void UTILS_NOINLINE FCamera::setCustomProjection(filament::math::mat4 const& p, double near, double far) noexcept {
mProjectionForCulling = p;
mProjection = p;
mNear = (float)near;
@@ -192,8 +192,8 @@ void FCamera::setExposure(float aperture, float shutterSpeed, float sensitivity)
}
template<typename T>
math::details::TMat44<T> inverseProjection(const math::details::TMat44<T>& p) noexcept {
math::details::TMat44<T> r;
math::details::TMat44<T> inverseProjection(const filament::math::details::TMat44<T>& p) noexcept {
filament::math::details::TMat44<T> r;
const T A = 1 / p[0][0];
const T B = 1 / p[1][1];
if (p[2][3] != T(0)) {
@@ -231,11 +231,11 @@ math::details::TMat44<T> inverseProjection(const math::details::TMat44<T>& p) no
UTILS_NOINLINE
math::mat4f FCamera::getViewMatrix(math::mat4f const& model) noexcept {
math::mat4f FCamera::getViewMatrix(filament::math::mat4f const& model) noexcept {
return FCamera::rigidTransformInverse(model);
}
Frustum FCamera::getFrustum(math::mat4 const& projection, math::mat4f const& viewMatrix) noexcept {
Frustum FCamera::getFrustum(filament::math::mat4 const& projection, filament::math::mat4f const& viewMatrix) noexcept {
return Frustum(mat4f{ projection * viewMatrix });
}
@@ -269,15 +269,15 @@ void Camera::setLensProjection(double focalLength, double near, double far) noex
upcast(this)->setLensProjection(focalLength, near, far);
}
void Camera::setCustomProjection(math::mat4 const& projection, double near, double far) noexcept {
void Camera::setCustomProjection(filament::math::mat4 const& projection, double near, double far) noexcept {
upcast(this)->setCustomProjection(projection, near, far);
}
const math::mat4& Camera::getProjectionMatrix() const noexcept {
const filament::math::mat4& Camera::getProjectionMatrix() const noexcept {
return upcast(this)->getProjectionMatrix();
}
const math::mat4& Camera::getCullingProjectionMatrix() const noexcept {
const filament::math::mat4& Camera::getCullingProjectionMatrix() const noexcept {
return upcast(this)->getCullingProjectionMatrix();
}
@@ -289,11 +289,11 @@ float Camera::getCullingFar() const noexcept {
return upcast(this)->getCullingFar();
}
void Camera::setModelMatrix(const math::mat4f& modelMatrix) noexcept {
void Camera::setModelMatrix(const filament::math::mat4f& modelMatrix) noexcept {
upcast(this)->setModelMatrix(modelMatrix);
}
void Camera::lookAt(const math::float3& eye, const math::float3& center, float3 const& up) noexcept {
void Camera::lookAt(const filament::math::float3& eye, const filament::math::float3& center, float3 const& up) noexcept {
upcast(this)->lookAt(eye, center, up);
}
+3 -3
View File
@@ -20,12 +20,12 @@
#include <math/mat3.h>
using namespace math;
using namespace filament::math;
namespace filament {
using xyY = math::float3;
using XYZ = math::float3;
using xyY = filament::math::float3;
using XYZ = filament::math::float3;
float3 Color::sRGBToLinear(float3 color) noexcept {
return image::sRGBToLinear(color);
+11 -11
View File
@@ -18,7 +18,7 @@
#include <math/fast.h>
using namespace math;
using namespace filament::math;
namespace filament {
namespace details {
@@ -26,10 +26,10 @@ namespace details {
void Culler::intersects(
result_type* UTILS_RESTRICT results,
Frustum const& UTILS_RESTRICT frustum,
math::float4 const* UTILS_RESTRICT b,
filament::math::float4 const* UTILS_RESTRICT b,
size_t count) noexcept {
math::float4 const * const UTILS_RESTRICT planes = frustum.mPlanes;
filament::math::float4 const * const UTILS_RESTRICT planes = frustum.mPlanes;
// we use a vectorize width of 8 because, on ARMv8 it allow the compiler to write 8
// 8-bits results in one go. Without this it has to do 4 separate byte writes, which
@@ -38,7 +38,7 @@ void Culler::intersects(
#pragma clang loop vectorize_width(8)
for (size_t i = 0; i < count; i++) {
int visible = ~0;
math::float4 const sphere(b[i]);
filament::math::float4 const sphere(b[i]);
#pragma clang loop unroll(full)
for (size_t j = 0; j < 6; j++) {
@@ -57,11 +57,11 @@ void Culler::intersects(
void Culler::intersects(
result_type* UTILS_RESTRICT results,
Frustum const& UTILS_RESTRICT frustum,
math::float3 const* UTILS_RESTRICT center,
math::float3 const* UTILS_RESTRICT extent,
filament::math::float3 const* UTILS_RESTRICT center,
filament::math::float3 const* UTILS_RESTRICT extent,
size_t count, size_t bit) noexcept {
math::float4 const * UTILS_RESTRICT const planes = frustum.mPlanes;
filament::math::float4 const * UTILS_RESTRICT const planes = frustum.mPlanes;
// we use a vectorize width of 8 because, on ARMv8 it allows the compiler to write eight
// 8-bits results in one go. Without this it has to do 4 separate byte writes, which
@@ -107,7 +107,7 @@ bool Culler::intersects(Frustum const& frustum, Box const& box) noexcept {
/*
* returns whether an sphere intersects with the frustum
*/
bool Culler::intersects(Frustum const& frustum, math::float4 const& sphere) noexcept {
bool Culler::intersects(Frustum const& frustum, filament::math::float4 const& sphere) noexcept {
// The main intersection routine assumes multiples of 8 items
float4 spheres[MODULO];
Culler::result_type results[MODULO];
@@ -122,8 +122,8 @@ bool Culler::intersects(Frustum const& frustum, math::float4 const& sphere) noex
void Culler::Test::intersects(
result_type* UTILS_RESTRICT results,
Frustum const& UTILS_RESTRICT frustum,
math::float3 const* UTILS_RESTRICT c,
math::float3 const* UTILS_RESTRICT e,
filament::math::float3 const* UTILS_RESTRICT c,
filament::math::float3 const* UTILS_RESTRICT e,
size_t count) noexcept {
Culler::intersects(results, frustum, c, e, count, 0);
}
@@ -131,7 +131,7 @@ void Culler::Test::intersects(
void Culler::Test::intersects(
result_type* UTILS_RESTRICT results,
Frustum const& UTILS_RESTRICT frustum,
math::float4 const* UTILS_RESTRICT b, size_t count) noexcept {
filament::math::float4 const* UTILS_RESTRICT b, size_t count) noexcept {
Culler::intersects(results, frustum, b, count);
}
+7 -7
View File
@@ -22,7 +22,7 @@
# define DEBUG_PROPERTIES_WRITABLE false
#endif
using namespace math;
using namespace filament::math;
using namespace utils;
namespace filament {
@@ -105,15 +105,15 @@ bool DebugRegistry::setProperty(const char* name, float v) noexcept {
return upcast(this)->setProperty(name, v);
}
bool DebugRegistry::setProperty(const char* name, math::float2 v) noexcept {
bool DebugRegistry::setProperty(const char* name, filament::math::float2 v) noexcept {
return upcast(this)->setProperty(name, v);
}
bool DebugRegistry::setProperty(const char* name, math::float3 v) noexcept {
bool DebugRegistry::setProperty(const char* name, filament::math::float3 v) noexcept {
return upcast(this)->setProperty(name, v);
}
bool DebugRegistry::setProperty(const char* name, math::float4 v) noexcept {
bool DebugRegistry::setProperty(const char* name, filament::math::float4 v) noexcept {
return upcast(this)->setProperty(name, v);
}
@@ -130,15 +130,15 @@ bool DebugRegistry::getProperty(const char* name, float* v) const noexcept {
return upcast(this)->getProperty(name, v);
}
bool DebugRegistry::getProperty(const char* name, math::float2* v) const noexcept {
bool DebugRegistry::getProperty(const char* name, filament::math::float2* v) const noexcept {
return upcast(this)->getProperty(name, v);
}
bool DebugRegistry::getProperty(const char* name, math::float3* v) const noexcept {
bool DebugRegistry::getProperty(const char* name, filament::math::float3* v) const noexcept {
return upcast(this)->getProperty(name, v);
}
bool DebugRegistry::getProperty(const char* name, math::float4* v) const noexcept {
bool DebugRegistry::getProperty(const char* name, filament::math::float4* v) const noexcept {
return upcast(this)->getProperty(name, v);
}
+1 -1
View File
@@ -55,7 +55,7 @@
#include "generated/resources/materials.h"
using namespace math;
using namespace filament::math;
using namespace utils;
namespace filament {
+1 -1
View File
@@ -188,7 +188,7 @@ public:
mOut.resize(HISTORY);
}
void push(T value, float b = 1.0f - math::fast::exp(-0.125f)) noexcept {
void push(T value, float b = 1.0f - filament::math::fast::exp(-0.125f)) noexcept {
mIn.push_back(value);
mIn.pop_front();
std::array<T, MEDIAN> median;
+2 -2
View File
@@ -35,7 +35,7 @@
#include <stddef.h>
using namespace math;
using namespace filament::math;
using namespace utils;
namespace filament {
@@ -151,7 +151,7 @@ void Froxelizer::setProjection(const mat4f& projection, float near, float far) n
bool Froxelizer::prepare(
FEngine::DriverApi& driverApi, ArenaScope& arena, Viewport const& viewport,
const math::mat4f& projection, float projectionNear, float projectionFar) noexcept {
const filament::math::mat4f& projection, float projectionNear, float projectionFar) noexcept {
setViewport(viewport);
setProjection(projection, projectionNear, projectionFar);
+1 -1
View File
@@ -20,7 +20,7 @@
#include <utils/compiler.h>
using namespace math;
using namespace filament::math;
namespace filament {
+5 -5
View File
@@ -27,7 +27,7 @@
#define IBL_INTEGRATION_IMPORTANCE_SAMPLING 1
#define IBL_INTEGRATION IBL_INTEGRATION_PREFILTERED_CUBEMAP
using namespace math;
using namespace filament::math;
namespace filament {
@@ -38,7 +38,7 @@ using namespace details;
struct IndirectLight::BuilderDetails {
Texture const* mReflectionsMap = nullptr;
Texture const* mIrradianceMap = nullptr;
math::float3 mIrradianceCoefs[9] = {};
filament::math::float3 mIrradianceCoefs[9] = {};
mat3f mRotation;
float mIntensity = 30000.0f;
uint8_t mNumBands = 0;
@@ -57,7 +57,7 @@ IndirectLight::Builder& IndirectLight::Builder::reflections(Texture const* cubem
return *this;
}
IndirectLight::Builder& IndirectLight::Builder::irradiance(uint8_t bands, math::float3 const* sh) noexcept {
IndirectLight::Builder& IndirectLight::Builder::irradiance(uint8_t bands, filament::math::float3 const* sh) noexcept {
// clamp to 3 bands for now
bands = std::min(bands, uint8_t(3));
size_t numCoefs = bands * bands;
@@ -77,7 +77,7 @@ IndirectLight::Builder& IndirectLight::Builder::intensity(float envIntensity) no
return *this;
}
IndirectLight::Builder& IndirectLight::Builder::rotation(math::mat3f const& rotation) noexcept {
IndirectLight::Builder& IndirectLight::Builder::rotation(filament::math::mat3f const& rotation) noexcept {
mImpl->mRotation = rotation;
return *this;
}
@@ -164,7 +164,7 @@ float IndirectLight::getIntensity() const noexcept {
return upcast(this)->getIntensity();
}
void IndirectLight::setRotation(math::mat3f const& rotation) noexcept {
void IndirectLight::setRotation(filament::math::mat3f const& rotation) noexcept {
upcast(this)->setRotation(rotation);
}
+13 -13
View File
@@ -27,7 +27,7 @@ namespace filament {
// sphere radius must be squared
// plane equation must be normalized, sphere radius must be squared
// return float4.w <= 0 if no intersection
inline constexpr math::float4 spherePlaneIntersection(math::float4 s, math::float4 p) noexcept {
inline constexpr filament::math::float4 spherePlaneIntersection(filament::math::float4 s, filament::math::float4 p) noexcept {
const float d = dot(s.xyz, p.xyz) + p.w;
const float rr = s.w - d * d;
s.x -= p.x * d;
@@ -40,21 +40,21 @@ inline constexpr math::float4 spherePlaneIntersection(math::float4 s, math::floa
// sphere radius must be squared
// plane equation must be normalized and have the form {x,0,z,0}, sphere radius must be squared
// return float4.w <= 0 if no intersection
inline float spherePlaneDistanceSquared(math::float4 s, float px, float pz) noexcept {
inline float spherePlaneDistanceSquared(filament::math::float4 s, float px, float pz) noexcept {
return spherePlaneIntersection(s, { px, 0.f, pz, 0.f }).w;
}
// sphere radius must be squared
// plane equation must be normalized and have the form {0,y,z,0}, sphere radius must be squared
// return float4.w <= 0 if no intersection
inline math::float4 spherePlaneIntersection(math::float4 s, float py, float pz) noexcept {
inline filament::math::float4 spherePlaneIntersection(filament::math::float4 s, float py, float pz) noexcept {
return spherePlaneIntersection(s, { 0.f, py, pz, 0.f });
}
// sphere radius must be squared
// plane equation must be normalized and have the form {0,0,1,w}, sphere radius must be squared
// return float4.w <= 0 if no intersection
inline math::float4 spherePlaneIntersection(math::float4 s, float pw) noexcept {
inline filament::math::float4 spherePlaneIntersection(filament::math::float4 s, float pw) noexcept {
return spherePlaneIntersection(s, { 0.f, 0.f, 1.f, pw });
}
@@ -62,13 +62,13 @@ inline math::float4 spherePlaneIntersection(math::float4 s, float pw) noexcept {
// this version returns a false-positive intersection in a small area near the origin
// of the cone extended outward by the sphere's radius.
inline bool sphereConeIntersectionFast(
math::float4 const& sphere,
math::float3 const& conePosition,
math::float3 const& coneAxis,
filament::math::float4 const& sphere,
filament::math::float3 const& conePosition,
filament::math::float3 const& coneAxis,
float coneSinInverse,
float coneCosSquared) noexcept {
const math::float3 u = conePosition - (sphere.w * coneSinInverse) * coneAxis;
math::float3 d = sphere.xyz - u;
const filament::math::float3 u = conePosition - (sphere.w * coneSinInverse) * coneAxis;
filament::math::float3 d = sphere.xyz - u;
float e = dot(coneAxis, d);
float dd = dot(d, d);
// we do the e>0 last here to avoid a branch
@@ -76,14 +76,14 @@ inline bool sphereConeIntersectionFast(
}
inline bool sphereConeIntersection(
math::float4 const& sphere,
math::float3 const& conePosition,
math::float3 const& coneAxis,
filament::math::float4 const& sphere,
filament::math::float3 const& conePosition,
filament::math::float3 const& coneAxis,
float coneSinInverse,
float coneCosSquared) noexcept {
if (sphereConeIntersectionFast(sphere,
conePosition, coneAxis, coneSinInverse, coneCosSquared)) {
math::float3 d = sphere.xyz - conePosition;
filament::math::float3 d = sphere.xyz - conePosition;
float e = -dot(coneAxis, d);
float dd = dot(d, d);
if (e * e >= dd * (1 - coneCosSquared) && e > 0) {
+1 -1
View File
@@ -26,7 +26,7 @@
#include <string.h>
using namespace math;
using namespace filament::math;
namespace filament {
+1 -1
View File
@@ -71,7 +71,7 @@ void PostProcessManager::setSource(uint32_t viewportWidth, uint32_t viewportHeig
UniformBuffer& ub = mPostProcessUb;
ub.setUniform(offsetof(PostProcessingUib, time), fraction);
ub.setUniform(offsetof(PostProcessingUib, uvScale),
math::float2{ viewportWidth, viewportHeight } / math::float2{ textureWidth, textureHeight });
filament::math::float2{ viewportWidth, viewportHeight } / filament::math::float2{ textureWidth, textureHeight });
// The shader may need to know the offset between the top of the texture and the top
// of the rectangle that it actually needs to sample from.
+2 -2
View File
@@ -32,7 +32,7 @@
#include <utils/Systrace.h>
using namespace utils;
using namespace math;
using namespace filament::math;
namespace filament {
@@ -206,7 +206,7 @@ void RenderPass::setupColorCommand(Command& cmdDraw, bool hasDepthPass,
UTILS_NOINLINE
void RenderPass::generateCommands(uint32_t commandTypeFlags, Command* const commands,
FScene::RenderableSoa const& soa, utils::Range<uint32_t> range, RenderFlags renderFlags,
math::float3 cameraPosition, math::float3 cameraForward) noexcept {
filament::math::float3 cameraPosition, filament::math::float3 cameraForward) noexcept {
// generateCommands() writes both the draw and depth commands simultaneously such that
// we go throw the list of renderables just once.
+3 -3
View File
@@ -239,12 +239,12 @@ private:
static inline void generateCommands(uint32_t commandTypeFlags, Command* commands,
FScene::RenderableSoa const& soa, utils::Range<uint32_t> range, RenderFlags renderFlags,
math::float3 cameraPosition, math::float3 cameraForward) noexcept;
filament::math::float3 cameraPosition, filament::math::float3 cameraForward) noexcept;
template<uint32_t commandTypeFlags>
static inline void generateCommandsImpl(uint32_t, Command* commands, FScene::RenderableSoa const& soa,
utils::Range<uint32_t> range, RenderFlags renderFlags, math::float3 cameraPosition,
math::float3 cameraForward) noexcept;
utils::Range<uint32_t> range, RenderFlags renderFlags, filament::math::float3 cameraPosition,
filament::math::float3 cameraForward) noexcept;
static void setupColorCommand(Command& cmdDraw, bool hasDepthPass,
FMaterialInstance const* mi) noexcept;
+1 -1
View File
@@ -39,7 +39,7 @@
#include <assert.h>
using namespace math;
using namespace filament::math;
using namespace utils;
namespace filament {
+2 -2
View File
@@ -33,7 +33,7 @@
#include <algorithm>
using namespace math;
using namespace filament::math;
using namespace utils;
namespace filament {
@@ -49,7 +49,7 @@ FScene::FScene(FEngine& engine) :
FScene::~FScene() noexcept = default;
void FScene::prepare(const math::mat4f& worldOriginTransform) {
void FScene::prepare(const filament::math::mat4f& worldOriginTransform) {
// TODO: can we skip this in most cases? Since we rely on indices staying the same,
// we could only skip, if nothing changed in the RCM.
+6 -6
View File
@@ -28,7 +28,7 @@
#include <limits>
using namespace math;
using namespace filament::math;
using namespace utils;
namespace filament {
@@ -194,7 +194,7 @@ void ShadowMap::update(
}
void ShadowMap::computeShadowCameraDirectional(
math::float3 const& dir, FScene const* scene, CameraInfo const& camera,
filament::math::float3 const& dir, FScene const* scene, CameraInfo const& camera,
uint8_t visibleLayers) noexcept {
// scene bounds in world space
@@ -492,7 +492,7 @@ mat4f ShadowMap::getTextureCoordsMapping() const noexcept {
return Mb * Mt;
}
// This construct a frustum (similar to glFrustum or math::frustum), except
// This construct a frustum (similar to glFrustum or filament::math::frustum), except
// it looks towards the +y axis, and assumes -1,1 for the left/right and bottom/top planes.
mat4f ShadowMap::warpFrustum(float n, float f) noexcept {
const float d = 1 / (f - n);
@@ -699,7 +699,7 @@ size_t ShadowMap::intersectFrustumWithBox(
return vertexCount;
}
void ShadowMap::snapLightFrustum(math::float2& s, math::float2& o,
void ShadowMap::snapLightFrustum(filament::math::float2& s, filament::math::float2& o,
uint32_t shadowMapDimension) noexcept {
// TODO: we can also quantize the scaling value
const float r = shadowMapDimension * 0.5f;
@@ -804,7 +804,7 @@ bool ShadowMap::intersectSegmentWithPlane(float3& UTILS_RESTRICT p,
return false;
}
float ShadowMap::texelSizeWorldSpace(const math::mat4f& lightSpaceMatrix) const noexcept {
float ShadowMap::texelSizeWorldSpace(const filament::math::mat4f& lightSpaceMatrix) const noexcept {
// this version works only for orthographic projections
const mat3f shadowmapToWorldMatrix(inverse(lightSpaceMatrix.upperLeft()));
const float3 texelSizeWs = shadowmapToWorldMatrix * float3{ 1, 1, 0 };
@@ -812,7 +812,7 @@ float ShadowMap::texelSizeWorldSpace(const math::mat4f& lightSpaceMatrix) const
return s;
}
float ShadowMap::texelSizeWorldSpace(const math::mat4f& lightSpaceMatrix, float3 const& str) const noexcept {
float ShadowMap::texelSizeWorldSpace(const filament::math::mat4f& lightSpaceMatrix, float3 const& str) const noexcept {
// for non-orthographic projection, the projection of a texel in world-space is not constant
// therefore we need to specify which texel we want to back-project.
const mat4f shadowmapToWorldMatrix(inverse(lightSpaceMatrix));
+1 -1
View File
@@ -32,7 +32,7 @@
#include "generated/resources/materials.h"
using namespace math;
using namespace filament::math;
namespace filament {
using namespace details;
+1 -1
View File
@@ -19,7 +19,7 @@
#include <stdlib.h>
#include <string.h>
using namespace math;
using namespace filament::math;
namespace filament {
+21 -21
View File
@@ -101,21 +101,21 @@ public:
std::is_same<float, T>::value ||
std::is_same<int32_t, T>::value ||
std::is_same<uint32_t, T>::value ||
std::is_same<math::quatf, T>::value ||
std::is_same<math::bool2, T>::value ||
std::is_same<math::bool3, T>::value ||
std::is_same<math::bool4, T>::value ||
std::is_same<math::int2, T>::value ||
std::is_same<math::int3, T>::value ||
std::is_same<math::int4, T>::value ||
std::is_same<math::uint2, T>::value ||
std::is_same<math::uint3, T>::value ||
std::is_same<math::uint4, T>::value ||
std::is_same<math::float2, T>::value ||
std::is_same<math::float3, T>::value ||
std::is_same<math::float4, T>::value ||
std::is_same<math::mat3f, T>::value ||
std::is_same<math::mat4f, T>::value
std::is_same<filament::math::quatf, T>::value ||
std::is_same<filament::math::bool2, T>::value ||
std::is_same<filament::math::bool3, T>::value ||
std::is_same<filament::math::bool4, T>::value ||
std::is_same<filament::math::int2, T>::value ||
std::is_same<filament::math::int3, T>::value ||
std::is_same<filament::math::int4, T>::value ||
std::is_same<filament::math::uint2, T>::value ||
std::is_same<filament::math::uint3, T>::value ||
std::is_same<filament::math::uint4, T>::value ||
std::is_same<filament::math::float2, T>::value ||
std::is_same<filament::math::float3, T>::value ||
std::is_same<filament::math::float4, T>::value ||
std::is_same<filament::math::mat3f, T>::value ||
std::is_same<filament::math::mat4f, T>::value
>::type;
};
@@ -145,7 +145,7 @@ public:
template<typename T, typename = typename is_supported_type<T>::type>
T const& getUniform(size_t offset) const noexcept {
// we don't support mat3f because a specialization would force us to return by value.
static_assert(!std::is_same<math::mat3f, T>::value, "mat3f not supported");
static_assert(!std::is_same<filament::math::mat3f, T>::value, "mat3f not supported");
return *reinterpret_cast<T const*>(static_cast<char const*>(mBuffer) + offset);
}
@@ -198,10 +198,10 @@ private:
// specialization for float3 (which has a different alignment)
template<>
inline void
UniformBuffer::setUniformArray(size_t offset, math::float3 const* begin, size_t count) noexcept {
math::float4* p = static_cast<math::float4*>(invalidateUniforms(offset,
sizeof(math::float4) * count));
math::float3 const* const end = begin + count;
UniformBuffer::setUniformArray(size_t offset, filament::math::float3 const* begin, size_t count) noexcept {
filament::math::float4* p = static_cast<filament::math::float4*>(invalidateUniforms(offset,
sizeof(filament::math::float4) * count));
filament::math::float3 const* const end = begin + count;
while (begin != end) {
p->xyz = *begin++;
++p;
@@ -210,7 +210,7 @@ UniformBuffer::setUniformArray(size_t offset, math::float3 const* begin, size_t
// specialization for mat3f (which has a different alignment, see std140 layout rules)
template<>
inline void UniformBuffer::setUniform(void* addr, size_t offset, const math::mat3f& v) noexcept {
inline void UniformBuffer::setUniform(void* addr, size_t offset, const filament::math::mat3f& v) noexcept {
struct mat43 {
float v[3][4];
};
+5 -5
View File
@@ -31,7 +31,7 @@
namespace filament {
using namespace details;
using namespace math;
using namespace filament::math;
struct VertexBuffer::BuilderDetails {
VertexBuffer::Builder::AttributeData mAttributes[MAX_ATTRIBUTE_BUFFERS_COUNT];
@@ -193,7 +193,7 @@ void FVertexBuffer::setBufferAt(FEngine& engine, uint8_t bufferIndex,
// Trampoline calling into private implementation
// ------------------------------------------------------------------------------------------------
using namespace details;
using namespace filament::details;
size_t VertexBuffer::getVertexCount() const noexcept {
return upcast(this)->getVertexCount();
@@ -211,7 +211,7 @@ void VertexBuffer::populateTangentQuaternions(const QuatTangentContext& ctx) {
}
// Define a small lambda that converts fp32 into the desired output format.
void (*writeQuat)(math::quatf, uint8_t*);
void (*writeQuat)(filament::math::quatf, uint8_t*);
switch (ctx.quatType) {
case HALF4:
writeQuat = [] (quatf inquat, uint8_t* outquat) {
@@ -231,7 +231,7 @@ void VertexBuffer::populateTangentQuaternions(const QuatTangentContext& ctx) {
}
const float3* normal = ctx.normals;
const size_t nstride = ctx.normalsStride ? ctx.normalsStride : sizeof(math::float3);
const size_t nstride = ctx.normalsStride ? ctx.normalsStride : sizeof(filament::math::float3);
uint8_t* outquat = (uint8_t*) ctx.outBuffer;
// If tangents are not provided, simply cross N with arbitrary vector (1, 0, 0)
@@ -249,7 +249,7 @@ void VertexBuffer::populateTangentQuaternions(const QuatTangentContext& ctx) {
const float3* tanvec = &ctx.tangents->xyz;
const float* tandir = &ctx.tangents->w;
const size_t tstride = ctx.tangentsStride ? ctx.tangentsStride : sizeof(math::float4);
const size_t tstride = ctx.tangentsStride ? ctx.tangentsStride : sizeof(filament::math::float4);
for (size_t qindex = 0, qcount = ctx.quatCount; qindex < qcount; ++qindex) {
float3 n = *normal;
+2 -2
View File
@@ -41,7 +41,7 @@
#include <memory>
using namespace math;
using namespace filament::math;
using namespace utils;
namespace filament {
@@ -398,7 +398,7 @@ void FView::prepareLighting(FEngine& engine, FEngine::DriverApi& driver, ArenaSc
}
void FView::prepare(FEngine& engine, driver::DriverApi& driver, ArenaScope& arena,
Viewport const& viewport, math::float4 const& userTime) noexcept {
Viewport const& viewport, filament::math::float4 const& userTime) noexcept {
JobSystem& js = engine.getJobSystem();
/*
+1 -1
View File
@@ -18,7 +18,7 @@
namespace filament {
Viewport Viewport::scale(math::float2 s) const noexcept {
Viewport Viewport::scale(filament::math::float2 s) const noexcept {
// round to nearest to avoid overlapping viewports
// this could result to empty viewport, though.
+1 -1
View File
@@ -25,7 +25,7 @@
#include <math/mat4.h>
using namespace utils;
using namespace math;
using namespace filament::math;
namespace filament {
namespace details {
+5 -5
View File
@@ -25,7 +25,7 @@
#include <filament/LightManager.h>
using namespace math;
using namespace filament::math;
using namespace utils;
namespace filament {
@@ -38,12 +38,12 @@ struct LightManager::BuilderDetails {
Type mType;
bool mCastShadows = false;
bool mCastLight = true;
math::float3 mPosition = {};
filament::math::float3 mPosition = {};
float mFalloff = 1.0f;
LinearColor mColor = LinearColor{ 1.0f };
float mIntensity = 100000.0f;
math::float3 mDirection = { 0.0f, -1.0f, 0.0f };
math::float2 mSpotInnerOuter = { (float)M_PI, (float)M_PI };
filament::math::float3 mDirection = { 0.0f, -1.0f, 0.0f };
filament::math::float2 mSpotInnerOuter = { (float)M_PI, (float)M_PI };
float mSunAngle = 0.00951f; // 0.545° in radians
float mSunHaloSize = 10.0f;
float mSunHaloFalloff = 80.0f;
@@ -215,7 +215,7 @@ void FLightManager::terminate() noexcept {
}
}
void FLightManager::setLocalPosition(Instance i, const math::float3& position) noexcept {
void FLightManager::setLocalPosition(Instance i, const filament::math::float3& position) noexcept {
assert(i);
auto& manager = mManager;
manager[i].position = position;
+9 -9
View File
@@ -75,7 +75,7 @@ public:
float cosOuterSquared = 1;
float sinInverse = std::numeric_limits<float>::infinity();
float luminousPower = 0;
math::float2 scaleOffset = {};
filament::math::float2 scaleOffset = {};
};
struct ShadowParams {
@@ -86,8 +86,8 @@ public:
float shadowFarHint;
};
UTILS_NOINLINE void setLocalPosition(Instance i, const math::float3& position) noexcept;
UTILS_NOINLINE void setLocalDirection(Instance i, math::float3 direction) noexcept;
UTILS_NOINLINE void setLocalPosition(Instance i, const filament::math::float3& position) noexcept;
UTILS_NOINLINE void setLocalDirection(Instance i, filament::math::float3 direction) noexcept;
UTILS_NOINLINE void setColor(Instance i, const LinearColor& color) noexcept;
UTILS_NOINLINE void setSpotLightCone(Instance i, float inner, float outer) noexcept;
UTILS_NOINLINE void setIntensity(Instance i, float intensity) noexcept;
@@ -154,7 +154,7 @@ public:
return getShadowParams(i).shadowFar;
}
constexpr const math::float3& getColor(Instance i) const noexcept {
constexpr const filament::math::float3& getColor(Instance i) const noexcept {
return mManager[i].color;
}
@@ -194,11 +194,11 @@ public:
return getSpotParams(i).radius;
}
constexpr const math::float3& getLocalPosition(Instance i) const noexcept {
constexpr const filament::math::float3& getLocalPosition(Instance i) const noexcept {
return mManager[i].position;
}
constexpr const math::float3& getLocalDirection(Instance i) const noexcept {
constexpr const filament::math::float3& getLocalDirection(Instance i) const noexcept {
return mManager[i].direction;
}
@@ -221,9 +221,9 @@ private:
using Base = utils::SingleInstanceComponentManager< // 120 bytes
LightType, // 1
math::float3, // 12
math::float3, // 12
math::float3, // 12
filament::math::float3, // 12
filament::math::float3, // 12
filament::math::float3, // 12
ShadowParams, // 12
SpotParams, // 24
float, // 4
@@ -29,7 +29,7 @@
#include <utils/Log.h>
#include <utils/Panic.h>
using namespace math;
using namespace filament::math;
using namespace utils;
namespace filament {
@@ -48,7 +48,7 @@ struct RenderableManager::BuilderDetails {
bool mReceiveShadows : 1;
size_t mSkinningBoneCount = 0;
Bone const* mUserBones = nullptr;
math::mat4f const* mUserBoneMatrices = nullptr;
filament::math::mat4f const* mUserBoneMatrices = nullptr;
explicit BuilderDetails(size_t count)
: mEntriesCount(count), mCulling(true), mCastShadows(false), mReceiveShadows(true) {
@@ -148,7 +148,7 @@ RenderableManager::Builder& RenderableManager::Builder::skinning(
}
RenderableManager::Builder& RenderableManager::Builder::skinning(
size_t boneCount, math::mat4f const* transforms) noexcept {
size_t boneCount, filament::math::mat4f const* transforms) noexcept {
mImpl->mSkinningBoneCount = boneCount;
mImpl->mUserBoneMatrices = transforms;
return *this;
@@ -482,7 +482,7 @@ void FRenderableManager::setBones(Instance ci,
}
void FRenderableManager::setBones(Instance ci,
math::mat4f const* UTILS_RESTRICT transforms, size_t boneCount, size_t offset) noexcept {
filament::math::mat4f const* UTILS_RESTRICT transforms, size_t boneCount, size_t offset) noexcept {
if (ci) {
std::unique_ptr<Bones> const& bones = mManager[ci].bones;
assert(bones && offset + boneCount <= bones->count);
@@ -498,7 +498,7 @@ void FRenderableManager::setBones(Instance ci,
}
}
void FRenderableManager::makeBone(PerRenderableUibBone* UTILS_RESTRICT out, math::mat4f const& t) noexcept {
void FRenderableManager::makeBone(PerRenderableUibBone* UTILS_RESTRICT out, filament::math::mat4f const& t) noexcept {
mat4f m(t);
// figure out the scales
+2 -2
View File
@@ -102,7 +102,7 @@ public:
inline void setSkinning(Instance instance, bool enable) noexcept;
inline void setPrimitives(Instance instance, utils::Slice<FRenderPrimitive> const& primitives) noexcept;
inline void setBones(Instance instance, Bone const* transforms, size_t boneCount, size_t offset = 0) noexcept;
inline void setBones(Instance instance, math::mat4f const* transforms, size_t boneCount, size_t offset = 0) noexcept;
inline void setBones(Instance instance, filament::math::mat4f const* transforms, size_t boneCount, size_t offset = 0) noexcept;
inline bool isShadowCaster(Instance instance) const noexcept;
@@ -146,7 +146,7 @@ private:
friend class ::FilamentTest_Bones_Test;
static void makeBone(PerRenderableUibBone* out, math::mat4f const& transforms) noexcept;
static void makeBone(PerRenderableUibBone* out, filament::math::mat4f const& transforms) noexcept;
enum {
AABB, // user data
+1 -1
View File
@@ -17,7 +17,7 @@
#include "components/TransformManager.h"
using namespace utils;
using namespace math;
using namespace filament::math;
namespace filament {
namespace details {
+7 -7
View File
@@ -56,7 +56,7 @@ public:
void create(utils::Entity entity);
void create(utils::Entity entity, Instance parent, const math::mat4f& localTransform);
void create(utils::Entity entity, Instance parent, const filament::math::mat4f& localTransform);
void destroy(utils::Entity e) noexcept;
@@ -68,17 +68,17 @@ public:
void gc(utils::EntityManager& em) noexcept;
utils::Slice<const math::mat4f> getWorldTransforms() const noexcept {
utils::Slice<const filament::math::mat4f> getWorldTransforms() const noexcept {
return mManager.slice<WORLD>();
}
void setTransform(Instance ci, const math::mat4f& model) noexcept;
void setTransform(Instance ci, const filament::math::mat4f& model) noexcept;
const math::mat4f& getTransform(Instance ci) const noexcept {
const filament::math::mat4f& getTransform(Instance ci) const noexcept {
return mManager[ci].local;
}
const math::mat4f& getWorldTransform(Instance ci) const noexcept {
const filament::math::mat4f& getWorldTransform(Instance ci) const noexcept {
return mManager[ci].world;
}
@@ -104,8 +104,8 @@ private:
};
using Base = utils::SingleInstanceComponentManager<
math::mat4f,
math::mat4f,
filament::math::mat4f,
filament::math::mat4f,
Instance,
Instance,
Instance,
+26 -26
View File
@@ -57,14 +57,14 @@ public:
// Sets a custom projection matrix (sets both the viewing and culling projections).
void setCustomProjection(math::mat4 const& projection, double near, double far) noexcept;
void setCustomProjection(filament::math::mat4 const& projection, double near, double far) noexcept;
// returns the projection matrix
const math::mat4& getProjectionMatrix() const noexcept {
const filament::math::mat4& getProjectionMatrix() const noexcept {
return mProjection;
}
const math::mat4& getCullingProjectionMatrix() const noexcept {
const filament::math::mat4& getCullingProjectionMatrix() const noexcept {
return mProjectionForCulling;
}
@@ -72,41 +72,41 @@ public:
float getCullingFar() const noexcept { return mFar; }
// sets the camera's view matrix (must be a rigid transform)
void setModelMatrix(const math::mat4f& modelMatrix) noexcept;
void setModelMatrix(const filament::math::mat4f& modelMatrix) noexcept;
// sets the camera's view matrix
void lookAt(const math::float3& eye, const math::float3& center, const math::float3& up = { 0, 1, 0 }) noexcept;
void lookAt(const filament::math::float3& eye, const filament::math::float3& center, const filament::math::float3& up = { 0, 1, 0 }) noexcept;
// returns the view matrix
math::mat4f const& getModelMatrix() const noexcept;
filament::math::mat4f const& getModelMatrix() const noexcept;
// returns the inverse of the view matrix
math::mat4f getViewMatrix() const noexcept;
filament::math::mat4f getViewMatrix() const noexcept;
template <typename T>
static math::details::TMat44<T> rigidTransformInverse(math::details::TMat44<T> const& v) noexcept {
static filament::math::details::TMat44<T> rigidTransformInverse(filament::math::details::TMat44<T> const& v) noexcept {
// The inverse of a rigid transform can be computed from the transpose
// | R T |^-1 | Rt -Rt*T |
// | 0 1 | = | 0 1 |
const math::details::TMat33<T> rt(transpose(v.upperLeft()));
const math::details::TVec3<T> t(rt * v[3].xyz);
return math::details::TMat44<T>(rt, -t);
const filament::math::details::TMat33<T> rt(transpose(v.upperLeft()));
const filament::math::details::TVec3<T> t(rt * v[3].xyz);
return filament::math::details::TMat44<T>(rt, -t);
}
math::float3 const& getPosition() const noexcept {
filament::math::float3 const& getPosition() const noexcept {
return getModelMatrix()[3].xyz;
}
math::float3 getLeftVector() const noexcept {
filament::math::float3 getLeftVector() const noexcept {
return normalize(getModelMatrix()[0].xyz);
}
math::float3 getUpVector() const noexcept {
filament::math::float3 getUpVector() const noexcept {
return normalize(getModelMatrix()[1].xyz);
}
math::float3 getForwardVector() const noexcept {
filament::math::float3 getForwardVector() const noexcept {
// the camera looks towards -z
return normalize(-getModelMatrix()[2].xyz);
}
@@ -136,15 +136,15 @@ public:
return mEntity;
}
static math::mat4f getViewMatrix(math::mat4f const& model) noexcept;
static Frustum getFrustum(math::mat4 const& projection, math::mat4f const& viewMatrix) noexcept;
static filament::math::mat4f getViewMatrix(filament::math::mat4f const& model) noexcept;
static Frustum getFrustum(filament::math::mat4 const& projection, filament::math::mat4f const& viewMatrix) noexcept;
private:
FEngine& mEngine;
utils::Entity mEntity;
math::mat4 mProjection; // projection matrix (infinite far)
math::mat4 mProjectionForCulling; // projection matrix (with far plane)
filament::math::mat4 mProjection; // projection matrix (infinite far)
filament::math::mat4 mProjectionForCulling; // projection matrix (with far plane)
float mNear;
float mFar;
@@ -155,18 +155,18 @@ private:
};
struct CameraInfo {
math::mat4f projection;
math::mat4f cullingProjection;
math::mat4f model;
math::mat4f view;
filament::math::mat4f projection;
filament::math::mat4f cullingProjection;
filament::math::mat4f model;
filament::math::mat4f view;
float zn;
float zf;
float ev100 = 0.0f;
math::float3 const& getPosition() const noexcept { return model[3].xyz; }
math::float3 getForwardVector() const noexcept { return normalize(-model[2].xyz); }
filament::math::float3 const& getPosition() const noexcept { return model[3].xyz; }
filament::math::float3 getForwardVector() const noexcept { return normalize(-model[2].xyz); }
// for debugging:
math::mat4f worldOrigin; // this is already applied to model and view
filament::math::mat4f worldOrigin; // this is already applied to model and view
};
FILAMENT_UPCAST(Camera)
+7 -7
View File
@@ -53,8 +53,8 @@ public:
*/
static void intersects(result_type* results,
Frustum const& frustum,
math::float3 const* center,
math::float3 const* extent,
filament::math::float3 const* center,
filament::math::float3 const* extent,
size_t count, size_t bit) noexcept;
/*
@@ -63,7 +63,7 @@ public:
static void intersects(
result_type* results,
Frustum const& frustum,
math::float4 const* b,
filament::math::float4 const* b,
size_t count) noexcept;
/*
@@ -78,19 +78,19 @@ public:
*/
static bool intersects(
Frustum const& frustum,
math::float4 const& sphere) noexcept;
filament::math::float4 const& sphere) noexcept;
struct UTILS_PUBLIC Test {
static void intersects(result_type* results,
Frustum const& frustum,
math::float3 const* c,
math::float3 const* e,
filament::math::float3 const* c,
filament::math::float3 const* e,
size_t count) noexcept;
static void intersects(result_type* results,
Frustum const& frustum,
math::float4 const* b,
filament::math::float4 const* b,
size_t count) noexcept;
};
};
+3 -3
View File
@@ -53,9 +53,9 @@ public:
if (std::is_same<T, bool>::value) type = BOOL;
if (std::is_same<T, int>::value) type = INT;
if (std::is_same<T, float>::value) type = FLOAT;
if (std::is_same<T, math::float2>::value) type = FLOAT2;
if (std::is_same<T, math::float3>::value) type = FLOAT3;
if (std::is_same<T, math::float4>::value) type = FLOAT3;
if (std::is_same<T, filament::math::float2>::value) type = FLOAT2;
if (std::is_same<T, filament::math::float3>::value) type = FLOAT3;
if (std::is_same<T, filament::math::float4>::value) type = FLOAT3;
registerProperty(name, p, type);
}
+16 -16
View File
@@ -51,7 +51,7 @@ public:
enum Planes {
LEFT, RIGHT, BOTTOM, TOP, NEAR, FAR
};
math::float4 planes[6];
filament::math::float4 planes[6];
};
//
@@ -114,7 +114,7 @@ public:
* return true if updateUniforms() needs to be called
*/
bool prepare(driver::DriverApi& driverApi, ArenaScope& arena, Viewport const& viewport,
const math::mat4f& projection, float projectionNear, float projectionFar) noexcept;
const filament::math::mat4f& projection, float projectionNear, float projectionFar) noexcept;
Froxel getFroxelAt(size_t x, size_t y, size_t z) const noexcept;
size_t getFroxelCountX() const noexcept { return mFroxelCountX; }
@@ -174,9 +174,9 @@ private:
};
struct LightParams {
math::float3 position;
filament::math::float3 position;
float cosSqr;
math::float3 axis;
filament::math::float3 axis;
// this must be initialized to indicate this is a point light
float invSin = std::numeric_limits<float>::infinity();
// radius is not used in the hot loop, so leave it at the end
@@ -199,7 +199,7 @@ private:
using FroxelThreadData = std::array<LightGroupType, FROXEL_BUFFER_ENTRY_COUNT_MAX + 1>;
void setViewport(Viewport const& viewport) noexcept;
void setProjection(const math::mat4f& projection, float near, float far) noexcept;
void setProjection(const filament::math::mat4f& projection, float near, float far) noexcept;
bool update() noexcept;
void froxelizeLoop(FEngine& engine,
@@ -208,7 +208,7 @@ private:
void froxelizeAssignRecordsCompress() noexcept;
void froxelizePointAndSpotLight(FroxelThreadData& froxelThread, size_t bit,
math::mat4f const& projection, const LightParams& light) const noexcept;
filament::math::mat4f const& projection, const LightParams& light) const noexcept;
static void computeLightTree(LightTreeNode* lightTree,
utils::Slice<RecordBufferType> const& lightList,
@@ -220,19 +220,19 @@ private:
size_t findSliceZ(float viewSpaceZ) const noexcept UTILS_PURE;
std::pair<size_t, size_t> clipToIndices(math::float2 const& clip) const noexcept;
std::pair<size_t, size_t> clipToIndices(filament::math::float2 const& clip) const noexcept;
static void computeFroxelLayout(
math::uint2* dim, uint16_t* countX, uint16_t* countY, uint16_t* countZ,
filament::math::uint2* dim, uint16_t* countX, uint16_t* countY, uint16_t* countZ,
Viewport const& viewport) noexcept;
// internal state dependant on the viewport and needed for froxelizing
LinearAllocatorArena mArena; // ~256 KiB
float* mDistancesZ = nullptr; // max 2.1 MiB (actual: resolution dependant)
math::float4* mPlanesX = nullptr;
math::float4* mPlanesY = nullptr;
math::float4* mBoundingSpheres = nullptr;
filament::math::float4* mPlanesX = nullptr;
filament::math::float4* mPlanesY = nullptr;
filament::math::float4* mBoundingSpheres = nullptr;
utils::Slice<FroxelThreadData> mFroxelShardedData; // 256 KiB w/ 256 lights
utils::Slice<FroxelEntry> mFroxelBufferUser; // 32 KiB w/ 8192 froxels
@@ -245,21 +245,21 @@ private:
uint16_t mFroxelCountY = 0;
uint16_t mFroxelCountZ = 0;
uint16_t mFroxelCount = 0;
math::uint2 mFroxelDimension = {};
filament::math::uint2 mFroxelDimension = {};
math::mat4f mProjection;
filament::math::mat4f mProjection;
float mLinearizer = 0.0f;
float mLog2ZLightFar = 0.0f;
float mClipToFroxelX = 0.0f;
float mClipToFroxelY = 0.0f;
math::float2 mOneOverDimension = {};
filament::math::float2 mOneOverDimension = {};
GPUBuffer mRecordsBuffer;
GPUBuffer mFroxelBuffer;
// needed for update()
Viewport mViewport;
math::float4 mParamsZ = {};
math::uint3 mParamsF = {};
filament::math::float4 mParamsZ = {};
filament::math::uint3 mParamsF = {};
float mNear = 0.0f; // camera near
float mZLightFar = FEngine::CONFIG_Z_LIGHT_FAR;
float mZLightNear = FEngine::CONFIG_Z_LIGHT_NEAR; // light near (first slice)
+5 -5
View File
@@ -42,18 +42,18 @@ public:
Handle<HwTexture> getReflectionMap() const noexcept { return mReflectionsMapHandle; }
Handle<HwTexture> getIrradianceMap() const noexcept { return mIrradianceMapHandle; }
math::float3 const* getSH() const noexcept{ return mIrradianceCoefs.data(); }
filament::math::float3 const* getSH() const noexcept{ return mIrradianceCoefs.data(); }
float getIntensity() const noexcept { return mIntensity; }
void setIntensity(float intensity) noexcept { mIntensity = intensity; }
void setRotation(math::mat3f const& rotation) noexcept { mRotation = rotation; }
const math::mat3f& getRotation() const { return mRotation; }
void setRotation(filament::math::mat3f const& rotation) noexcept { mRotation = rotation; }
const filament::math::mat3f& getRotation() const { return mRotation; }
private:
Handle<HwTexture> mReflectionsMapHandle;
Handle<HwTexture> mIrradianceMapHandle;
std::array<math::float3, 9> mIrradianceCoefs;
std::array<filament::math::float3, 9> mIrradianceCoefs;
float mIntensity = DEFAULT_INTENSITY;
math::mat3f mRotation;
filament::math::mat3f mRotation;
};
FILAMENT_UPCAST(IndirectLight)
+2 -2
View File
@@ -60,7 +60,7 @@ public:
FEngine& getEngine() const noexcept { return mEngine; }
math::float4 getShaderUserTime() const { return mShaderUserTime; }
filament::math::float4 getShaderUserTime() const { return mShaderUserTime; }
// do all the work here!
void render(FView const* view);
@@ -150,7 +150,7 @@ private:
bool mIsRGB16FSupported : 1;
bool mIsRGB8Supported : 1;
Epoch mUserEpoch;
math::float4 mShaderUserTime;
filament::math::float4 mShaderUserTime;
// per-frame arena for this Renderer
LinearAllocatorArena& mPerRenderPassArena;
+10 -10
View File
@@ -80,7 +80,7 @@ public:
~FScene() noexcept;
void terminate(FEngine& engine);
void prepare(const math::mat4f& worldOriginTransform);
void prepare(const filament::math::mat4f& worldOriginTransform);
void prepareDynamicLights(const CameraInfo& camera, ArenaScope& arena, Handle<HwUniformBuffer> lightUbh) noexcept;
void computeBounds(Aabb& castersBox, Aabb& receiversBox, uint32_t visibleLayers) const noexcept;
@@ -112,13 +112,13 @@ public:
using RenderableSoa = utils::StructureOfArrays<
utils::EntityInstance<RenderableManager>,
math::mat4f,
filament::math::mat4f,
FRenderableManager::Visibility,
Handle<HwUniformBuffer>,
math::float3,
filament::math::float3,
Culler::result_type,
uint8_t,
math::float3,
filament::math::float3,
utils::Slice<FRenderPrimitive>,
uint32_t
>;
@@ -151,11 +151,11 @@ public:
};
using LightSoa = utils::StructureOfArrays<
math::float4,
math::float3,
filament::math::float4,
filament::math::float3,
FLightManager::Instance,
Culler::result_type,
math::float2
filament::math::float2
>;
LightSoa const& getLightData() const noexcept { return mLightData; }
@@ -164,11 +164,11 @@ public:
void updateUBOs(utils::Range<uint32_t> visibleRenderables, Handle<HwUniformBuffer> renderableUbh) noexcept;
private:
static inline void computeLightRanges(math::float2* zrange,
CameraInfo const& camera, const math::float4* spheres, size_t count) noexcept;
static inline void computeLightRanges(filament::math::float2* zrange,
CameraInfo const& camera, const filament::math::float4* spheres, size_t count) noexcept;
static inline void computeLightCameraPlaneDistances(float* distances,
const CameraInfo& camera, const math::float4* spheres, size_t count) noexcept;
const CameraInfo& camera, const filament::math::float4* spheres, size_t count) noexcept;
FEngine& mEngine;
FSkybox const* mSkybox = nullptr;
+35 -35
View File
@@ -57,7 +57,7 @@ public:
// Computes the transform to use in the shader to access the shadow map.
// Valid after calling update().
math::mat4f const& getLightSpaceMatrix() const noexcept { return mLightSpace; }
filament::math::mat4f const& getLightSpaceMatrix() const noexcept { return mLightSpace; }
// return the size of a texel in world space (pre-warping)
float getTexelSizeWorldSpace() const noexcept { return mTexelSizeWs; }
@@ -76,10 +76,10 @@ public:
private:
struct CameraInfo {
math::mat4f projection;
math::mat4f model;
math::mat4f view;
math::mat4f worldOrigin;
filament::math::mat4f projection;
filament::math::mat4f model;
filament::math::mat4f view;
filament::math::mat4f worldOrigin;
float zn = 0;
float zf = 0;
float dzn = 0;
@@ -87,8 +87,8 @@ private:
Frustum frustum;
float getNear() const noexcept { return zn; }
float getFar() const noexcept { return zf; }
math::float3 const& getPosition() const noexcept { return model[3].xyz; }
math::float3 getForwardVector() const noexcept {
filament::math::float3 const& getPosition() const noexcept { return model[3].xyz; }
filament::math::float3 getForwardVector() const noexcept {
return -normalize(model[2].xyz); // the camera looks towards -z
}
};
@@ -102,56 +102,56 @@ private:
};
// 8 corners, 12 segments w/ 2 intersection max -- all of this twice (8 + 12 * 2) * 2 (768 bytes)
using FrustumBoxIntersection = std::array<math::float3, 64>;
using FrustumBoxIntersection = std::array<filament::math::float3, 64>;
void computeShadowCameraDirectional(
math::float3 const& direction, FScene const* scene, CameraInfo const& camera,
filament::math::float3 const& direction, FScene const* scene, CameraInfo const& camera,
uint8_t visibleLayers) noexcept;
static math::mat4f applyLISPSM(
CameraInfo const& camera, float dzn, float dzf, const math::mat4f& LMpMv,
Aabb const& wsShadowReceiversVolume, const math::float3 wsViewFrustumCorners[8],
const math::float3& dir);
static filament::math::mat4f applyLISPSM(
CameraInfo const& camera, float dzn, float dzf, const filament::math::mat4f& LMpMv,
Aabb const& wsShadowReceiversVolume, const filament::math::float3 wsViewFrustumCorners[8],
const filament::math::float3& dir);
static inline void snapLightFrustum(math::float2& s, math::float2& o,
static inline void snapLightFrustum(filament::math::float2& s, filament::math::float2& o,
uint32_t shadowMapDimension) noexcept;
static inline void computeFrustumCorners(math::float3* out,
const math::mat4f& projectionViewInverse) noexcept;
static inline void computeFrustumCorners(filament::math::float3* out,
const filament::math::mat4f& projectionViewInverse) noexcept;
static inline math::float2 computeNearFar(math::mat4f const& lightView,
static inline filament::math::float2 computeNearFar(filament::math::mat4f const& lightView,
Aabb const& wsShadowCastersVolume) noexcept;
static inline void intersectWithShadowCasters(Aabb& lightFrustum, const math::mat4f& lightView,
static inline void intersectWithShadowCasters(Aabb& lightFrustum, const filament::math::mat4f& lightView,
Aabb const& wsShadowCastersVolume) noexcept;
static inline math::float2 computeWpNearFarOfWarpSpace(math::mat4f const& lightView,
math::float3 const wsViewFrustumCorners[8]) noexcept;
static inline filament::math::float2 computeWpNearFarOfWarpSpace(filament::math::mat4f const& lightView,
filament::math::float3 const wsViewFrustumCorners[8]) noexcept;
static inline bool intersectSegmentWithPlane(math::float3& p,
math::float3 s0, math::float3 s1,
math::float3 pn, math::float3 p0) noexcept;
static inline bool intersectSegmentWithPlane(filament::math::float3& p,
filament::math::float3 s0, filament::math::float3 s1,
filament::math::float3 pn, filament::math::float3 p0) noexcept;
static inline bool intersectSegmentWithPlanarQuad(math::float3& p,
math::float3 s0, math::float3 s1,
math::float3 t0, math::float3 t1,
math::float3 t2, math::float3 t3) noexcept;
static inline bool intersectSegmentWithPlanarQuad(filament::math::float3& p,
filament::math::float3 s0, filament::math::float3 s1,
filament::math::float3 t0, filament::math::float3 t1,
filament::math::float3 t2, filament::math::float3 t3) noexcept;
static size_t intersectFrustums(math::float3* out, size_t vertexCount,
math::float3 const* segmentsVertices, math::float3 const* quadsVertices) noexcept;
static size_t intersectFrustums(filament::math::float3* out, size_t vertexCount,
filament::math::float3 const* segmentsVertices, filament::math::float3 const* quadsVertices) noexcept;
static size_t intersectFrustumWithBox(
FrustumBoxIntersection& outVertices,
const Frustum& frustum,
const math::float3* wsFrustumCorners,
const filament::math::float3* wsFrustumCorners,
Aabb const& wsBox);
static math::mat4f warpFrustum(float n, float f) noexcept;
static filament::math::mat4f warpFrustum(float n, float f) noexcept;
math::mat4f getTextureCoordsMapping() const noexcept;
filament::math::mat4f getTextureCoordsMapping() const noexcept;
float texelSizeWorldSpace(const math::mat4f& lightSpaceMatrix) const noexcept;
float texelSizeWorldSpace(const math::mat4f& lightSpaceMatrix, math::float3 const& str) const noexcept;
float texelSizeWorldSpace(const filament::math::mat4f& lightSpaceMatrix) const noexcept;
float texelSizeWorldSpace(const filament::math::mat4f& lightSpaceMatrix, filament::math::float3 const& str) const noexcept;
static constexpr const Segment sBoxSegments[12] = {
{ 0, 1 }, { 1, 3 }, { 3, 2 }, { 2, 0 },
@@ -169,7 +169,7 @@ private:
FCamera* mCamera = nullptr;
FCamera* mDebugCamera = nullptr;
math::mat4f mLightSpace;
filament::math::mat4f mLightSpace;
float mSceneRange = 0.0f;
float mTexelSizeWs = 0.0f;
+3 -3
View File
@@ -62,7 +62,7 @@ public:
void terminate(FEngine& engine);
void prepare(FEngine& engine, driver::DriverApi& driver, ArenaScope& arena,
Viewport const& viewport, math::float4 const& userTime) noexcept;
Viewport const& viewport, filament::math::float4 const& userTime) noexcept;
void setScene(FScene* scene) { mScene = scene; }
FScene const* getScene() const noexcept { return mScene; }
@@ -168,7 +168,7 @@ public:
return mHasPostProcessPass;
}
math::float2 updateScale(std::chrono::duration<float, std::milli> frameTime) noexcept;
filament::math::float2 updateScale(std::chrono::duration<float, std::milli> frameTime) noexcept;
void setDynamicResolutionOptions(View::DynamicResolutionOptions const& options) noexcept;
@@ -288,7 +288,7 @@ private:
std::array<duration, MAX_FRAMETIME_HISTORY> mFrameTimeHistory;
size_t mFrameTimeHistorySize = 0;
math::float2 mScale = 1.0f;
filament::math::float2 mScale = 1.0f;
float mDynamicWorkloadScale = 1.0f;
bool mIsDynamicResolutionSupported = false;
+19 -19
View File
@@ -183,31 +183,31 @@ Driver::SamplerFormat Driver::getSamplerFormat(TextureFormat format) noexcept {
size_t Driver::getElementTypeSize(ElementType type) noexcept {
switch (type) {
case ElementType::BYTE: return sizeof(int8_t);
case ElementType::BYTE2: return sizeof(math::byte2);
case ElementType::BYTE3: return sizeof(math::byte3);
case ElementType::BYTE4: return sizeof(math::byte4);
case ElementType::BYTE2: return sizeof(filament::math::byte2);
case ElementType::BYTE3: return sizeof(filament::math::byte3);
case ElementType::BYTE4: return sizeof(filament::math::byte4);
case ElementType::UBYTE: return sizeof(uint8_t);
case ElementType::UBYTE2: return sizeof(math::ubyte2);
case ElementType::UBYTE3: return sizeof(math::ubyte3);
case ElementType::UBYTE4: return sizeof(math::ubyte4);
case ElementType::UBYTE2: return sizeof(filament::math::ubyte2);
case ElementType::UBYTE3: return sizeof(filament::math::ubyte3);
case ElementType::UBYTE4: return sizeof(filament::math::ubyte4);
case ElementType::SHORT: return sizeof(int16_t);
case ElementType::SHORT2: return sizeof(math::short2);
case ElementType::SHORT3: return sizeof(math::short3);
case ElementType::SHORT4: return sizeof(math::short4);
case ElementType::SHORT2: return sizeof(filament::math::short2);
case ElementType::SHORT3: return sizeof(filament::math::short3);
case ElementType::SHORT4: return sizeof(filament::math::short4);
case ElementType::USHORT: return sizeof(uint16_t);
case ElementType::USHORT2: return sizeof(math::ushort2);
case ElementType::USHORT3: return sizeof(math::ushort3);
case ElementType::USHORT4: return sizeof(math::ushort4);
case ElementType::USHORT2: return sizeof(filament::math::ushort2);
case ElementType::USHORT3: return sizeof(filament::math::ushort3);
case ElementType::USHORT4: return sizeof(filament::math::ushort4);
case ElementType::INT: return sizeof(int32_t);
case ElementType::UINT: return sizeof(uint32_t);
case ElementType::FLOAT: return sizeof(float);
case ElementType::FLOAT2: return sizeof(math::float2);
case ElementType::FLOAT3: return sizeof(math::float3);
case ElementType::FLOAT4: return sizeof(math::float4);
case ElementType::HALF: return sizeof(math::half);
case ElementType::HALF2: return sizeof(math::half2);
case ElementType::HALF3: return sizeof(math::half3);
case ElementType::HALF4: return sizeof(math::half4);
case ElementType::FLOAT2: return sizeof(filament::math::float2);
case ElementType::FLOAT3: return sizeof(filament::math::float3);
case ElementType::FLOAT4: return sizeof(filament::math::float4);
case ElementType::HALF: return sizeof(filament::math::half);
case ElementType::HALF2: return sizeof(filament::math::half2);
case ElementType::HALF3: return sizeof(filament::math::half3);
case ElementType::HALF4: return sizeof(filament::math::half4);
}
}
+1 -1
View File
@@ -34,7 +34,7 @@ static size_t dataTypeToSize(GPUBuffer::Element element) noexcept {
case ET::INT16: return element.size * sizeof(int16_t);
case ET::UINT32: return element.size * sizeof(uint32_t);
case ET::INT32: return element.size * sizeof(int32_t);
case ET::HALF: return element.size * sizeof(math::half);
case ET::HALF: return element.size * sizeof(filament::math::half);
case ET::FLOAT: return element.size * sizeof(float);
}
}
+1 -1
View File
@@ -26,7 +26,7 @@
#include "driver/opengl/OpenGLDriver.h"
#include "driver/opengl/GLUtils.h"
using namespace math;
using namespace filament::math;
using namespace utils;
namespace filament {
+1 -1
View File
@@ -52,7 +52,7 @@
# define DEBUG_MARKER()
#endif
using namespace math;
using namespace filament::math;
using namespace utils;
namespace filament {
+5 -5
View File
@@ -263,7 +263,7 @@ private:
return static_cast<Dp>(static_cast<void *>(base + offset));
}
typedef math::details::TVec4<GLint> vec4gli;
typedef filament::math::details::TVec4<GLint> vec4gli;
friend class OpenGLProgram;
@@ -471,7 +471,7 @@ private:
} window;
struct {
math::float4 color = {};
filament::math::float4 color = {};
GLfloat depth = 1.0f;
GLint stencil = 0;
} clears;
@@ -496,13 +496,13 @@ private:
GLuint mClearProgram;
GLint mClearColorLocation;
GLint mClearDepthLocation;
static const math::float2 mClearTriangle[3];
static const filament::math::float2 mClearTriangle[3];
void initClearProgram() noexcept;
void terminateClearProgram() noexcept;
void clearWithRasterPipe(bool clearColor, math::float4 const& linearColor,
void clearWithRasterPipe(bool clearColor, filament::math::float4 const& linearColor,
bool clearDepth, double depth,
bool clearStencil, uint32_t stencil) noexcept;
void clearWithGeometryPipe(bool clearColor, math::float4 const& linearColor,
void clearWithGeometryPipe(bool clearColor, filament::math::float4 const& linearColor,
bool clearDepth, double depth,
bool clearStencil, uint32_t stencil) noexcept;
+1 -1
View File
@@ -27,7 +27,7 @@
namespace filament {
using namespace math;
using namespace filament::math;
using namespace utils;
// we just want a small, tight loop for our purpose here, so we avoid std::copy_n
+3 -3
View File
@@ -42,10 +42,10 @@
#include "UniformBuffer.h"
using namespace filament;
using namespace math;
using namespace filament::math;
using namespace utils;
static bool isGray(math::float3 v) {
static bool isGray(filament::math::float3 v) {
return v.r == v.g && v.g == v.b;
}
@@ -55,7 +55,7 @@ static bool almostEqualUlps(float a, float b, int maxUlps) {
return intDiff <= maxUlps;
}
static bool vec3eq(math::float3 a, math::float3 b) {
static bool vec3eq(filament::math::float3 a, filament::math::float3 b) {
return almostEqualUlps(a.x, b.x, 1) &&
almostEqualUlps(a.y, b.y, 1) &&
almostEqualUlps(a.z, b.z, 1);
@@ -47,7 +47,7 @@ struct App {
};
struct Vertex {
math::float2 position;
filament::math::float2 position;
uint32_t color;
};
@@ -211,8 +211,8 @@ static constexpr uint8_t BAKED_COLOR_PACKAGE[] = {
[self updateRotation];
tcm.setTransform(tcm.getInstance(app.renderable),
math::mat4f::rotate(CACurrentMediaTime(), math::float3{0, 0, 1}) *
math::mat4f::rotate(deviceRotation, math::float3{0, 0, 1}));
filament::math::mat4f::rotate(CACurrentMediaTime(), filament::math::float3{0, 0, 1}) *
filament::math::mat4f::rotate(deviceRotation, filament::math::float3{0, 0, 1}));
}
- (void)didRotate:(NSNotification*)notification
@@ -96,7 +96,7 @@ struct RenderPassParams {
uint32_t width = 0;
uint32_t height = 0;
// Clear values (32 bytes)
math::float4 clearColor = {};
filament::math::float4 clearColor = {};
double clearDepth = 1.0;
uint32_t clearStencil = 0;
uint32_t reserved1 = 0;
@@ -44,76 +44,76 @@ struct PerViewUib { // NOLINT(cppcoreguidelines-pro-type-member-init)
static const UniformInterfaceBlock& getUib() noexcept {
return UibGenerator::getPerViewUib();
}
math::mat4f viewFromWorldMatrix;
math::mat4f worldFromViewMatrix;
math::mat4f clipFromViewMatrix;
math::mat4f viewFromClipMatrix;
math::mat4f clipFromWorldMatrix;
math::mat4f worldFromClipMatrix;
math::mat4f lightFromWorldMatrix;
filament::math::mat4f viewFromWorldMatrix;
filament::math::mat4f worldFromViewMatrix;
filament::math::mat4f clipFromViewMatrix;
filament::math::mat4f viewFromClipMatrix;
filament::math::mat4f clipFromWorldMatrix;
filament::math::mat4f worldFromClipMatrix;
filament::math::mat4f lightFromWorldMatrix;
math::float4 resolution; // viewport width, height, 1/width, 1/height
filament::math::float4 resolution; // viewport width, height, 1/width, 1/height
math::float3 cameraPosition;
filament::math::float3 cameraPosition;
float time; // time in seconds, with a 1 second period
math::float4 lightColorIntensity; // directional light
filament::math::float4 lightColorIntensity; // directional light
math::float4 sun; // cos(sunAngle), sin(sunAngle), 1/(sunAngle*HALO_SIZE-sunAngle), HALO_EXP
filament::math::float4 sun; // cos(sunAngle), sin(sunAngle), 1/(sunAngle*HALO_SIZE-sunAngle), HALO_EXP
math::float3 lightDirection;
filament::math::float3 lightDirection;
uint32_t fParamsX; // stride-x
math::float3 shadowBias; // constant bias, normal bias, unused
filament::math::float3 shadowBias; // constant bias, normal bias, unused
float oneOverFroxelDimensionY;
math::float4 zParams; // froxel Z parameters
filament::math::float4 zParams; // froxel Z parameters
math::uint2 fParams; // stride-y, stride-z
math::float2 origin; // viewport left, viewport bottom
filament::math::uint2 fParams; // stride-y, stride-z
filament::math::float2 origin; // viewport left, viewport bottom
float oneOverFroxelDimensionX;
float iblLuminance;
float exposure;
float ev100;
alignas(16) math::float4 iblSH[9]; // actually float3 entries (std140 requires float4 alignment)
alignas(16) filament::math::float4 iblSH[9]; // actually float3 entries (std140 requires float4 alignment)
math::float4 userTime; // time(s), (double)time - (float)time, 0, 0
filament::math::float4 userTime; // time(s), (double)time - (float)time, 0, 0
};
// PerRenderableUib must have an alignment of 256 to be compatible with all versions of GLES.
struct alignas(256) PerRenderableUib {
math::mat4f worldFromModelMatrix;
math::mat3f worldFromModelNormalMatrix;
filament::math::mat4f worldFromModelMatrix;
filament::math::mat3f worldFromModelNormalMatrix;
};
struct LightsUib {
static const UniformInterfaceBlock& getUib() noexcept {
return UibGenerator::getLightsUib();
}
math::float4 positionFalloff; // { float3(pos), 1/falloff^2 }
math::float4 colorIntensity; // { float3(col), intensity }
math::float4 directionIES; // { float3(dir), IES index }
math::float4 spotScaleOffset; // { scale, offset, unused, unused }
filament::math::float4 positionFalloff; // { float3(pos), 1/falloff^2 }
filament::math::float4 colorIntensity; // { float3(col), intensity }
filament::math::float4 directionIES; // { float3(dir), IES index }
filament::math::float4 spotScaleOffset; // { scale, offset, unused, unused }
};
struct PostProcessingUib {
static const UniformInterfaceBlock& getUib() noexcept {
return UibGenerator::getPostProcessingUib();
}
math::float2 uvScale;
filament::math::float2 uvScale;
float time; // time in seconds, with a 1 second period, used for dithering
float yOffset;
};
// This is not the UBO proper, but just an element of a bone array.
struct PerRenderableUibBone {
math::quatf q = { 1, 0, 0, 0 };
math::float4 t = {};
math::float4 s = { 1, 1, 1, 0 };
math::float4 ns = { 1, 1, 1, 0 };
filament::math::quatf q = { 1, 0, 0, 0 };
filament::math::float4 t = {};
filament::math::float4 s = { 1, 1, 1, 0 };
filament::math::float4 ns = { 1, 1, 1, 0 };
};
} // namespace filament
+3 -3
View File
@@ -32,7 +32,7 @@
#include <filament/TransformManager.h>
#include <utils/EntityManager.h>
using namespace math;
using namespace filament::math;
using namespace filament;
using namespace utils;
@@ -236,9 +236,9 @@ void ImGuiHelper::createVertexBuffer(size_t bufferIndex, size_t capacity) {
.attribute(VertexAttribute::POSITION, 0, VertexBuffer::AttributeType::FLOAT2, 0,
sizeof(ImDrawVert))
.attribute(VertexAttribute::UV0, 0, VertexBuffer::AttributeType::FLOAT2,
sizeof(math::float2), sizeof(ImDrawVert))
sizeof(filament::math::float2), sizeof(ImDrawVert))
.attribute(VertexAttribute::COLOR, 0, VertexBuffer::AttributeType::UBYTE4,
2 * sizeof(math::float2), sizeof(ImDrawVert))
2 * sizeof(filament::math::float2), sizeof(ImDrawVert))
.normalized(VertexAttribute::COLOR)
.build(*mEngine);
}
+1 -1
View File
@@ -42,7 +42,7 @@
using namespace filament;
using namespace filamesh;
using namespace math;
using namespace filament::math;
#define DEFAULT_MATERIAL "DefaultMaterial"
+1 -1
View File
@@ -33,7 +33,7 @@
using namespace filament;
using namespace filamesh;
using namespace math;
using namespace filament::math;
using namespace std;
static const Box unitBox = {
+26 -26
View File
@@ -30,8 +30,8 @@
namespace image {
template <typename T>
inline math::float4 linearToRGBM(const T& linear) {
using math::float4;
inline filament::math::float4 linearToRGBM(const T& linear) {
using filament::math::float4;
float4 RGBM(linear[0], linear[1], linear[2], 1.0f);
@@ -42,7 +42,7 @@ inline math::float4 linearToRGBM(const T& linear) {
float maxComponent = std::max(std::max(RGBM.r, RGBM.g), std::max(RGBM.b, 1e-6f));
// Don't let M go below 1 in the [0..16] range
RGBM.a = math::clamp(maxComponent, 1.0f / 16.0f, 1.0f);
RGBM.a = filament::math::clamp(maxComponent, 1.0f / 16.0f, 1.0f);
RGBM.a = std::ceil(RGBM.a * 255.0f) / 255.0f;
RGBM.rgb = saturate(RGBM.rgb / RGBM.a);
@@ -51,8 +51,8 @@ inline math::float4 linearToRGBM(const T& linear) {
}
template <typename T>
inline math::float3 RGBMtoLinear(const T& rgbm) {
using math::float3;
inline filament::math::float3 RGBMtoLinear(const T& rgbm) {
using filament::math::float3;
float3 linear(rgbm[0], rgbm[1], rgbm[2]);
linear *= rgbm.a * 16.0f;
@@ -61,8 +61,8 @@ inline math::float3 RGBMtoLinear(const T& rgbm) {
}
template <typename T>
inline math::float3 linearTosRGB(const T& linear) {
using math::float3;
inline filament::math::float3 linearTosRGB(const T& linear) {
using filament::math::float3;
constexpr float a = 0.055f;
constexpr float a1 = 1.055f;
constexpr float p = 1 / 2.4f;
@@ -92,8 +92,8 @@ template<typename T>
T sRGBToLinear(const T& sRGB);
template<>
inline math::float3 sRGBToLinear(const math::float3& sRGB) {
using math::float3;
inline filament::math::float3 sRGBToLinear(const filament::math::float3& sRGB) {
using filament::math::float3;
constexpr float a = 0.055f;
constexpr float a1 = 1.055f;
constexpr float p = 2.4f;
@@ -109,8 +109,8 @@ inline math::float3 sRGBToLinear(const math::float3& sRGB) {
}
template<>
inline math::float4 sRGBToLinear(const math::float4& sRGB) {
using math::float4;
inline filament::math::float4 sRGBToLinear(const filament::math::float4& sRGB) {
using filament::math::float4;
constexpr float a = 0.055f;
constexpr float a1 = 1.055f;
constexpr float p = 2.4f;
@@ -130,8 +130,8 @@ template<typename T>
T linearToSRGB(const T& color);
template<>
inline math::float3 linearToSRGB(const math::float3& color) {
using math::float3;
inline filament::math::float3 linearToSRGB(const filament::math::float3& color) {
using filament::math::float3;
float3 sRGBColor{color};
#pragma nounroll
for (size_t i = 0; i < sRGBColor.size(); i++) {
@@ -156,7 +156,7 @@ std::unique_ptr<uint8_t[]> fromLinearTosRGB(const LinearImage& image) {
for (size_t x = 0; x < w; ++x, p += nchan, d += N) {
for (int n = 0; n < N; n++) {
float source = n < 3 ? linearTosRGB(p[n]) : p[n];
float target = math::saturate(source) * std::numeric_limits<T>::max() + 0.5f;
float target = filament::math::saturate(source) * std::numeric_limits<T>::max() + 0.5f;
d[n] = T(target);
}
}
@@ -168,7 +168,7 @@ std::unique_ptr<uint8_t[]> fromLinearTosRGB(const LinearImage& image) {
// The source image can have three or more channels, but only the first N are honored.
template <typename T, int N = 3>
std::unique_ptr<uint8_t[]> fromLinearToRGB(const LinearImage& image) {
using math::float3;
using filament::math::float3;
size_t w = image.getWidth();
size_t h = image.getHeight();
size_t channels = image.getChannels();
@@ -179,7 +179,7 @@ std::unique_ptr<uint8_t[]> fromLinearToRGB(const LinearImage& image) {
float const* p = image.getPixelRef(0, y);
for (size_t x = 0; x < w; ++x, p += channels, d += N) {
for (int n = 0; n < N; n++) {
float target = math::saturate(p[n]) * std::numeric_limits<T>::max() + 0.5f;
float target = filament::math::saturate(p[n]) * std::numeric_limits<T>::max() + 0.5f;
d[n] = T(target);
}
}
@@ -191,7 +191,7 @@ std::unique_ptr<uint8_t[]> fromLinearToRGB(const LinearImage& image) {
// The source image can have three or more channels, but only the first three are honored.
template <typename T>
std::unique_ptr<uint8_t[]> fromLinearToRGBM(const LinearImage& image) {
using namespace math;
using namespace filament::math;
size_t w = image.getWidth();
size_t h = image.getHeight();
UTILS_UNUSED_IN_RELEASE size_t channels = image.getChannels();
@@ -222,7 +222,7 @@ std::unique_ptr<uint8_t[]> fromLinearToGrayscale(const LinearImage& image) {
for (size_t y = 0; y < h; ++y) {
float const* p = image.getPixelRef(0, y);
for (size_t x = 0; x < w; ++x, ++p, ++d) {
const float gray = math::saturate(*p) * std::numeric_limits<T>::max() + 0.5f;
const float gray = filament::math::saturate(*p) * std::numeric_limits<T>::max() + 0.5f;
d[0] = T(gray);
}
}
@@ -236,11 +236,11 @@ template<typename T, typename PROCESS, typename TRANSFORM>
static LinearImage toLinear(size_t w, size_t h, size_t bpr,
const uint8_t* src, PROCESS proc, TRANSFORM transform) {
LinearImage result((uint32_t) w, (uint32_t) h, 3);
auto d = result.get<math::float3>();
auto d = result.get< filament::math::float3>();
for (size_t y = 0; y < h; ++y) {
T const* p = reinterpret_cast<T const*>(src + y * bpr);
for (size_t x = 0; x < w; ++x, p += 3) {
math::float3 sRGB(proc(p[0]), proc(p[1]), proc(p[2]));
filament::math::float3 sRGB(proc(p[0]), proc(p[1]), proc(p[2]));
sRGB /= std::numeric_limits<T>::max();
*d++ = transform(sRGB);
}
@@ -264,11 +264,11 @@ template<typename T, typename PROCESS, typename TRANSFORM>
static LinearImage toLinearWithAlpha(size_t w, size_t h, size_t bpr,
const uint8_t* src, PROCESS proc, TRANSFORM transform) {
LinearImage result((uint32_t) w, (uint32_t) h, 4);
auto d = result.get<math::float4>();
auto d = result.get< filament::math::float4>();
for (size_t y = 0; y < h; ++y) {
T const* p = reinterpret_cast<T const*>(src + y * bpr);
for (size_t x = 0; x < w; ++x, p += 4) {
math::float4 sRGB(proc(p[0]), proc(p[1]), proc(p[2]), proc(p[3]));
filament::math::float4 sRGB(proc(p[0]), proc(p[1]), proc(p[2]), proc(p[3]));
sRGB /= std::numeric_limits<T>::max();
*d++ = transform(sRGB);
}
@@ -286,9 +286,9 @@ static LinearImage toLinearWithAlpha(size_t w, size_t h, size_t bpr,
}
// Constructs a 3-channel LinearImage from RGBM data.
inline LinearImage toLinearFromRGBM(math::float4 const* src, uint32_t w, uint32_t h) {
inline LinearImage toLinearFromRGBM( filament::math::float4 const* src, uint32_t w, uint32_t h) {
LinearImage result(w, h, 3);
auto dst = result.get<math::float3>();
auto dst = result.get< filament::math::float3>();
for (uint32_t row = 0; row < h; ++row) {
for (uint32_t col = 0; col < w; ++col, ++src, ++dst) {
*dst = RGBMtoLinear(*src);
@@ -301,8 +301,8 @@ inline LinearImage fromLinearToRGBM(const LinearImage& image) {
assert(image.getChannels() == 3);
const uint32_t w = image.getWidth(), h = image.getHeight();
LinearImage result(w, h, 4);
auto src = image.get<math::float3>();
auto dst = result.get<math::float4>();
auto src = image.get< filament::math::float3>();
auto dst = result.get< filament::math::float4>();
for (uint32_t row = 0; row < h; ++row) {
for (uint32_t col = 0; col < w; ++col, ++src, ++dst) {
*dst = linearToRGBM(*src);
+1 -1
View File
@@ -24,7 +24,7 @@
#include <memory>
#include <ratio>
using namespace math;
using namespace filament::math;
namespace image {
+2 -2
View File
@@ -218,9 +218,9 @@ void normalize(LinearImage& image) {
ASSERT_PRECONDITION(image.getChannels() == 3 || image.getChannels() == 4,
"Must be a 3 or 4 channel image");
if (image.getChannels() == 3) {
normalizeImpl<math::float3>(image);
normalizeImpl< filament::math::float3>(image);
} else {
normalizeImpl<math::float4>(image);
normalizeImpl< filament::math::float4>(image);
}
}
+4 -4
View File
@@ -42,8 +42,8 @@ using std::string;
using std::swap;
using std::vector;
using math::float3;
using math::float4;
using filament::math::float3;
using filament::math::float4;
using namespace image;
@@ -249,7 +249,7 @@ TEST_F(ImageTest, ColorTransformRGB) { // NOLINT
memcpy(data.get(), texels, sizeof(texels));
LinearImage img = image::toLinear<uint16_t>(w, h, bpr, data,
[ ](uint16_t v) -> uint16_t { return v; },
sRGBToLinear<math::float3>);
sRGBToLinear< filament::math::float3>);
auto pixels = img.get<float3>();
ASSERT_NEAR(pixels[0].x, 0.0f, 0.001f);
ASSERT_NEAR(pixels[0].y, 0.0f, 0.001f);
@@ -273,7 +273,7 @@ TEST_F(ImageTest, ColorTransformRGBA) { // NOLINT
memcpy(data.get(), texels, sizeof(texels));
LinearImage img = image::toLinearWithAlpha<uint16_t>(w, h, bpr, data,
[ ](uint16_t v) -> uint16_t { return v; },
sRGBToLinear<math::float4>);
sRGBToLinear< filament::math::float4>);
auto pixels = reinterpret_cast<float4*>(img.getPixelRef());
ASSERT_NEAR(pixels[3].x, 0.04282892f, 0.001f);
ASSERT_NEAR(pixels[3].y, 0.12025354f, 0.001f);
@@ -114,7 +114,7 @@ enum class AstcSemantic {
struct AstcConfig {
AstcPreset quality;
AstcSemantic semantic;
math::ushort2 blocksize;
filament::math::ushort2 blocksize;
bool srgb;
};
+14 -14
View File
@@ -47,33 +47,33 @@ CompressedTexture astcCompress(const LinearImage& original, AstcConfig config) {
using Format = CompressedFormat;
Format format;
if (config.blocksize == math::ushort2 {4, 4}) {
if (config.blocksize == filament::math::ushort2 {4, 4}) {
format = config.srgb ? Format::SRGB8_ALPHA8_ASTC_4x4 : Format::RGBA_ASTC_4x4;
} else if (config.blocksize == math::ushort2 {5, 4}) {
} else if (config.blocksize == filament::math::ushort2 {5, 4}) {
format = config.srgb ? Format::SRGB8_ALPHA8_ASTC_5x4 : Format::RGBA_ASTC_5x4;
} else if (config.blocksize == math::ushort2 {5, 5}) {
} else if (config.blocksize == filament::math::ushort2 {5, 5}) {
format = config.srgb ? Format::SRGB8_ALPHA8_ASTC_5x5 : Format::RGBA_ASTC_5x5;
} else if (config.blocksize == math::ushort2 {6, 5}) {
} else if (config.blocksize == filament::math::ushort2 {6, 5}) {
format = config.srgb ? Format::SRGB8_ALPHA8_ASTC_6x5 : Format::RGBA_ASTC_6x5;
} else if (config.blocksize == math::ushort2 {6, 6}) {
} else if (config.blocksize == filament::math::ushort2 {6, 6}) {
format = config.srgb ? Format::SRGB8_ALPHA8_ASTC_6x6 : Format::RGBA_ASTC_6x6;
} else if (config.blocksize == math::ushort2 {8, 5}) {
} else if (config.blocksize == filament::math::ushort2 {8, 5}) {
format = config.srgb ? Format::SRGB8_ALPHA8_ASTC_8x5 : Format::RGBA_ASTC_8x5;
} else if (config.blocksize == math::ushort2 {8, 6}) {
} else if (config.blocksize == filament::math::ushort2 {8, 6}) {
format = config.srgb ? Format::SRGB8_ALPHA8_ASTC_8x6 : Format::RGBA_ASTC_8x6;
} else if (config.blocksize == math::ushort2 {8, 8}) {
} else if (config.blocksize == filament::math::ushort2 {8, 8}) {
format = config.srgb ? Format::SRGB8_ALPHA8_ASTC_8x8 : Format::RGBA_ASTC_8x8;
} else if (config.blocksize == math::ushort2 {10, 5}) {
} else if (config.blocksize == filament::math::ushort2 {10, 5}) {
format = config.srgb ? Format::SRGB8_ALPHA8_ASTC_10x5 : Format::RGBA_ASTC_10x5;
} else if (config.blocksize == math::ushort2 {10, 6}) {
} else if (config.blocksize == filament::math::ushort2 {10, 6}) {
format = config.srgb ? Format::SRGB8_ALPHA8_ASTC_10x6 : Format::RGBA_ASTC_10x6;
} else if (config.blocksize == math::ushort2 {10, 8}) {
} else if (config.blocksize == filament::math::ushort2 {10, 8}) {
format = config.srgb ? Format::SRGB8_ALPHA8_ASTC_10x8 : Format::RGBA_ASTC_10x8;
} else if (config.blocksize == math::ushort2 {10, 10}) {
} else if (config.blocksize == filament::math::ushort2 {10, 10}) {
format = config.srgb ? Format::SRGB8_ALPHA8_ASTC_10x10 : Format::RGBA_ASTC_10x10;
} else if (config.blocksize == math::ushort2 {12, 10}) {
} else if (config.blocksize == filament::math::ushort2 {12, 10}) {
format = config.srgb ? Format::SRGB8_ALPHA8_ASTC_12x10 : Format::RGBA_ASTC_12x10;
} else if (config.blocksize == math::ushort2 {12, 12}) {
} else if (config.blocksize == filament::math::ushort2 {12, 12}) {
format = config.srgb ? Format::SRGB8_ALPHA8_ASTC_12x12 : Format::RGBA_ASTC_12x12;
} else {
return {};
+13 -13
View File
@@ -273,22 +273,22 @@ LinearImage PNGDecoder::decode() {
if (getColorSpace() == ImageDecoder::ColorSpace::SRGB) {
return toLinearWithAlpha<uint16_t>(width, height, rowBytes, imageData,
[ ](uint16_t v) -> uint16_t { return ntohs(v); },
sRGBToLinear<math::float4>);
sRGBToLinear< filament::math::float4>);
} else {
return toLinearWithAlpha<uint16_t>(width, height, rowBytes, imageData,
[ ](uint16_t v) -> uint16_t { return ntohs(v); },
[ ](const math::float4& color) -> math::float4 { return color; });
[ ](const filament::math::float4& color) -> filament::math::float4 { return color; });
}
} else {
// Convert to linear float (PNG 16 stores data in network order (big endian).
if (getColorSpace() == ImageDecoder::ColorSpace::SRGB) {
return toLinear<uint16_t>(width, height, rowBytes, imageData,
[ ](uint16_t v) -> uint16_t { return ntohs(v); },
sRGBToLinear<math::float3>);
sRGBToLinear< filament::math::float3>);
} else {
return toLinear<uint16_t>(width, height, rowBytes, imageData,
[ ](uint16_t v) -> uint16_t { return ntohs(v); },
[ ](const math::float3& color) -> math::float3 { return color; });
[ ](const filament::math::float3& color) -> filament::math::float3 { return color; });
}
}
} catch(std::runtime_error& e) {
@@ -376,12 +376,12 @@ LinearImage HDRDecoder::decode() {
if (width < 8 || width > 32767) {
for (uint32_t y = 0; y < height; y++) {
math::float3* i = reinterpret_cast<math::float3*>(image.getPixelRef(0, y));
filament::math::float3* i = reinterpret_cast< filament::math::float3*>(image.getPixelRef(0, y));
mStream.read((char*) &rgbe, width * 4);
// (rgb/256) * 2^(e-128)
size_t pixel = 0;
for (size_t x = 0; x < width; x++, pixel += 4) {
math::float3 v(rgbe[pixel], rgbe[pixel + 1], rgbe[pixel + 2]);
filament::math::float3 v(rgbe[pixel], rgbe[pixel + 1], rgbe[pixel + 2]);
i[x] = v * std::ldexp(1.0f, rgbe[pixel + 3] - (128 + 8));
}
}
@@ -424,10 +424,10 @@ LinearImage HDRDecoder::decode() {
uint8_t const* g = &rgbe[width];
uint8_t const* b = &rgbe[2 * width];
uint8_t const* e = &rgbe[3 * width];
math::float3* i = reinterpret_cast<math::float3*>(image.getPixelRef(0, y));
filament::math::float3* i = reinterpret_cast< filament::math::float3*>(image.getPixelRef(0, y));
// (rgb/256) * 2^(e-128)
for (size_t x = 0; x < width; x++, r++, g++, b++, e++) {
math::float3 v(r[0], g[0], b[0]);
filament::math::float3 v(r[0], g[0], b[0]);
i[x] = v * std::ldexp(1.0f, e[0] - (128 + 8));
}
}
@@ -527,8 +527,8 @@ LinearImage PSDDecoder::decode() {
for (size_t i = 0; i < 3; i++) {
for (uint32_t y = 0; y < height; y++) {
for (uint32_t x = 0; x < width; x++) {
math::float3& pixel =
*reinterpret_cast<math::float3*>(image.getPixelRef(x, y));
filament::math::float3& pixel =
*reinterpret_cast< filament::math::float3*>(image.getPixelRef(x, y));
pixel[i] = read32(mStream);
}
}
@@ -537,8 +537,8 @@ LinearImage PSDDecoder::decode() {
for (size_t i = 0; i < 3; i++) {
for (uint32_t y = 0; y < height; y++) {
for (uint32_t x = 0; x < width; x++) {
math::float3& pixel =
*reinterpret_cast<math::float3*>(image.getPixelRef(x, y));
filament::math::float3& pixel =
*reinterpret_cast< filament::math::float3*>(image.getPixelRef(x, y));
pixel[i] = read16(mStream);
}
}
@@ -605,7 +605,7 @@ LinearImage EXRDecoder::decode() {
size_t i = 0;
for (uint32_t y = 0; y < height; y++) {
for (uint32_t x = 0; x < width; x++) {
math::float3& pixel = *reinterpret_cast<math::float3*>(image.getPixelRef(x, y));
filament::math::float3& pixel = *reinterpret_cast< filament::math::float3*>(image.getPixelRef(x, y));
pixel.r = rgba[i++];
pixel.g = rgba[i++];
pixel.b = rgba[i++];
+1 -1
View File
@@ -57,7 +57,7 @@ void updateOrCompare(LinearImage limgResult, const utils::Path& fnameGolden,
// Convert 4-channel RGBM into proper RGB.
if (fnameGolden.getExtension() == "rgbm" && limgGolden.getChannels() == 4) {
limgGolden = toLinearFromRGBM(
reinterpret_cast<math::float4 const*>(limgGolden.getPixelRef()),
reinterpret_cast< filament::math::float4 const*>(limgGolden.getPixelRef()),
limgGolden.getWidth(), limgGolden.getHeight());
}
+3 -3
View File
@@ -43,7 +43,7 @@
#include <image/ColorTransform.h>
using namespace math;
using namespace filament::math;
namespace image {
@@ -102,7 +102,7 @@ private:
// ImageEncoder::Encoder interface
bool encode(const LinearImage& image) override;
static void float2rgbe(uint8_t rgbe[4], const math::float3& in);
static void float2rgbe(uint8_t rgbe[4], const float3& in);
static size_t countRepeats(uint8_t const* data, size_t length);
static size_t countNonRepeats(uint8_t const* data, size_t length);
static void rle(std::ostream& out, uint8_t const* data, size_t length);
@@ -988,7 +988,7 @@ bool DDSEncoder::encode(const LinearImage& image) {
for (uint32_t y = 0; y < height; y++) {
const float* data = image.getPixelRef(0, y);
for (size_t x = 0; x < width; x++) {
math::half p = math::half(*data);
half p = half(*data);
mStream.write((const char*) &p, 2);
data++;
}
+3 -3
View File
@@ -24,7 +24,7 @@
#include <cmath>
using namespace math;
using namespace filament::math;
struct Scalar{};
@@ -152,8 +152,8 @@ struct FastPow2dot2 {
};
struct Float16 {
using result_type = math::half;
math::half operator()(float v) { return math::half(v); }
using result_type = half;
half operator()(float v) { return half(v); }
static const char* label() { return "half"; }
};
+2
View File
@@ -33,6 +33,7 @@
#include <math/quat.h>
#include <math/TVecHelpers.h>
namespace filament {
namespace math {
namespace details {
// -------------------------------------------------------------------------------------
@@ -589,5 +590,6 @@ public:
// -------------------------------------------------------------------------------------
} // namespace details
} // namespace math
} // namespace filament
#endif // MATH_TMATHELPERS_H_
+2
View File
@@ -27,6 +27,7 @@
#include <math/compiler.h>
#include <math/vec3.h>
namespace filament {
namespace math {
namespace details {
// -------------------------------------------------------------------------------------
@@ -297,5 +298,6 @@ public:
// -------------------------------------------------------------------------------------
} // namespace details
} // namespace math
} // namespace filament
#endif // MATH_TQUATHELPERS_H_
+2
View File
@@ -29,6 +29,7 @@
#include <math/compiler.h>
namespace filament {
namespace math {
namespace details {
// -------------------------------------------------------------------------------------
@@ -593,5 +594,6 @@ public:
// -------------------------------------------------------------------------------------
} // namespace details
} // namespace math
} // namespace filament
#endif // MATH_TVECHELPERS_H_
+3 -1
View File
@@ -26,6 +26,7 @@
#include <arm_neon.h>
#endif
namespace filament {
namespace math {
namespace fast {
@@ -46,7 +47,7 @@ constexpr T MATH_PURE cos(T x) noexcept {
// x between -pi and pi
template <typename T, typename = typename std::enable_if<std::is_floating_point<T>::value>::type>
constexpr T MATH_PURE sin(T x) noexcept {
return math::fast::cos<T>(x - T(M_PI_2));
return filament::math::fast::cos<T>(x - T(M_PI_2));
}
constexpr inline float MATH_PURE ilog2(float x) noexcept {
@@ -180,5 +181,6 @@ inline T MATH_PURE qdec(T a) noexcept {
} // namespace fast
} // namespace math
} // namespace filament
#endif // TNT_MATH_FAST_H
+17 -15
View File
@@ -23,6 +23,7 @@
#include <math/compiler.h>
namespace filament {
namespace math {
/*
@@ -101,7 +102,7 @@ private:
};
constexpr inline half makeHalf(uint16_t bits) noexcept {
return half(math::half::binary, bits);
return half(half::binary, bits);
}
constexpr half::fp16 half::ftoh(float f) noexcept {
@@ -140,20 +141,21 @@ constexpr float half::htof(half::fp16 in) noexcept {
#endif // __ARM_NEON
inline constexpr math::half operator"" _h(long double v) {
return math::half(static_cast<float>(v));
inline constexpr half operator"" _h(long double v) {
return half(static_cast<float>(v));
}
} // namespace math
} // namespace filament
namespace std {
template<> struct is_floating_point<math::half> : public std::true_type {};
template<> struct is_floating_point< filament::math::half> : public std::true_type {};
template<>
class numeric_limits<math::half> {
class numeric_limits< filament::math::half> {
public:
typedef math::half type;
typedef filament::math::half type;
static constexpr const bool is_specialized = true;
static constexpr const bool is_signed = true;
@@ -180,15 +182,15 @@ public:
static constexpr const int max_exponent = 16;
static constexpr const int max_exponent10 = 4;
inline static constexpr type round_error() noexcept { return math::makeHalf(0x3800); }
inline static constexpr type min() noexcept { return math::makeHalf(0x0400); }
inline static constexpr type max() noexcept { return math::makeHalf(0x7bff); }
inline static constexpr type lowest() noexcept { return math::makeHalf(0xfbff); }
inline static constexpr type epsilon() noexcept { return math::makeHalf(0x1400); }
inline static constexpr type infinity() noexcept { return math::makeHalf(0x7c00); }
inline static constexpr type quiet_NaN() noexcept { return math::makeHalf(0x7fff); }
inline static constexpr type denorm_min() noexcept { return math::makeHalf(0x0001); }
inline static constexpr type signaling_NaN() noexcept { return math::makeHalf(0x7dff); }
inline static constexpr type round_error() noexcept { return filament::math::makeHalf(0x3800); }
inline static constexpr type min() noexcept { return filament::math::makeHalf(0x0400); }
inline static constexpr type max() noexcept { return filament::math::makeHalf(0x7bff); }
inline static constexpr type lowest() noexcept { return filament::math::makeHalf(0xfbff); }
inline static constexpr type epsilon() noexcept { return filament::math::makeHalf(0x1400); }
inline static constexpr type infinity() noexcept { return filament::math::makeHalf(0x7c00); }
inline static constexpr type quiet_NaN() noexcept { return filament::math::makeHalf(0x7fff); }
inline static constexpr type denorm_min() noexcept { return filament::math::makeHalf(0x0001); }
inline static constexpr type signaling_NaN() noexcept { return filament::math::makeHalf(0x7dff); }
};
} // namespace std
+4 -2
View File
@@ -23,6 +23,7 @@
#include <stdint.h>
#include <sys/types.h>
namespace filament {
namespace math {
// -------------------------------------------------------------------------------------
namespace details {
@@ -398,14 +399,15 @@ typedef details::TMat22<float> mat2f;
// ----------------------------------------------------------------------------------------
} // namespace math
} // namespace filament
namespace std {
template <typename T>
constexpr void swap(math::details::TMat22<T>& lhs, math::details::TMat22<T>& rhs) noexcept {
constexpr void swap( filament::math::details::TMat22<T>& lhs, filament::math::details::TMat22<T>& rhs) noexcept {
// This generates much better code than the default implementation
// It's unclear why, I believe this is due to an optimization bug in the clang.
//
// math::details::TMat22<T> t(lhs);
// filament::math::details::TMat22<T> t(lhs);
// lhs = rhs;
// rhs = t;
//
+4 -2
View File
@@ -26,6 +26,7 @@
#include <stdint.h>
#include <sys/types.h>
namespace filament {
namespace math {
// -------------------------------------------------------------------------------------
namespace details {
@@ -467,14 +468,15 @@ typedef details::TMat33<float> mat3f;
// ----------------------------------------------------------------------------------------
} // namespace math
} // namespace filament
namespace std {
template <typename T>
constexpr void swap(math::details::TMat33<T>& lhs, math::details::TMat33<T>& rhs) noexcept {
constexpr void swap( filament::math::details::TMat33<T>& lhs, filament::math::details::TMat33<T>& rhs) noexcept {
// This generates much better code than the default implementation
// It's unclear why, I believe this is due to an optimization bug in the clang.
//
// math::details::TMat33<T> t(lhs);
// filament::math::details::TMat33<T> t(lhs);
// lhs = rhs;
// rhs = t;
//
+4 -2
View File
@@ -28,6 +28,7 @@
#include <sys/types.h>
#include <limits>
namespace filament {
namespace math {
// -------------------------------------------------------------------------------------
namespace details {
@@ -603,14 +604,15 @@ typedef details::TMat44<float> mat4f;
// ----------------------------------------------------------------------------------------
} // namespace math
} // namespace filament
namespace std {
template <typename T>
constexpr void swap(math::details::TMat44<T>& lhs, math::details::TMat44<T>& rhs) noexcept {
constexpr void swap( filament::math::details::TMat44<T>& lhs, filament::math::details::TMat44<T>& rhs) noexcept {
// This generates much better code than the default implementation
// It's unclear why, I believe this is due to an optimization bug in the clang.
//
// math::details::TMat44<T> t(lhs);
// filament::math::details::TMat44<T> t(lhs);
// lhs = rhs;
// rhs = t;
//
+3 -1
View File
@@ -23,6 +23,7 @@
#include <cmath>
#include <stdint.h>
namespace filament {
namespace math {
inline uint16_t packUnorm16(float v) noexcept {
@@ -93,6 +94,7 @@ inline float4 unpackSnorm8(byte4 v) noexcept {
return float4{unpackSnorm8(v.x), unpackSnorm8(v.y), unpackSnorm8(v.z), unpackSnorm8(v.w)};
}
} // namespace std
} // namespace math
} // namespace filament
#endif // TNT_MATH_NORM_H
+2
View File
@@ -26,6 +26,7 @@
#include <stdint.h>
#include <sys/types.h>
namespace filament {
namespace math {
// -------------------------------------------------------------------------------------
@@ -157,5 +158,6 @@ constexpr inline quat operator"" _k(unsigned long long v) {
// ----------------------------------------------------------------------------------------
} // namespace math
} // namespace filament
#endif // MATH_QUAT_H_
+2
View File
@@ -21,6 +21,7 @@
#include <cmath>
#include <math/compiler.h>
namespace filament {
namespace math {
template<typename T>
@@ -44,5 +45,6 @@ inline constexpr T MATH_PURE lerp(T x, T y, T a) noexcept {
}
} // namespace math
} // namespace filament
#endif // TNT_MATH_SCALAR_H
+2
View File
@@ -25,6 +25,7 @@
#include <type_traits>
namespace filament {
namespace math {
// -------------------------------------------------------------------------------------
@@ -107,5 +108,6 @@ typedef details::TVec2<bool> bool2;
// ----------------------------------------------------------------------------------------
} // namespace math
} // namespace filament
#endif // MATH_VEC2_H_
+2
View File
@@ -23,6 +23,7 @@
#include <sys/types.h>
namespace filament {
namespace math {
// -------------------------------------------------------------------------------------
@@ -126,5 +127,6 @@ typedef details::TVec3<bool> bool3;
// ----------------------------------------------------------------------------------------
} // namespace math
} // namespace filament
#endif // MATH_VEC3_H_
+2
View File
@@ -23,6 +23,7 @@
#include <sys/types.h>
namespace filament {
namespace math {
// -------------------------------------------------------------------------------------
@@ -119,5 +120,6 @@ typedef details::TVec4<bool> bool4;
// ----------------------------------------------------------------------------------------
} // namespace math
} // namespace filament
#endif // MATH_VEC4_H_

Some files were not shown because too many files have changed in this diff Show More