Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelflinger committed Sep 7, 2023
1 parent 4e2a791 commit e0a37de
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 48 deletions.
4 changes: 2 additions & 2 deletions filament/include/filament/LightManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ class UTILS_PUBLIC LightManager : public FilamentAPI {
* @return true is this light is a type of directional light
*/
inline bool isDirectional(Instance i) const noexcept {
Type type = getType(i);
Type const type = getType(i);
return type == Type::DIRECTIONAL || type == Type::SUN;
}

Expand All @@ -700,7 +700,7 @@ class UTILS_PUBLIC LightManager : public FilamentAPI {
* @return true is this light is a type of spot light
*/
inline bool isSpotLight(Instance i) const noexcept {
Type type = getType(i);
Type const type = getType(i);
return type == Type::SPOT || type == Type::FOCUSED_SPOT;
}

Expand Down
10 changes: 5 additions & 5 deletions filament/src/PerViewUniforms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ void PerViewUniforms::prepareDirectionalLight(FEngine& engine,
float exposure,
float3 const& sceneSpaceDirection,
PerViewUniforms::LightManagerInstance directionalLight) noexcept {
FLightManager& lcm = engine.getLightManager();
FLightManager const& lcm = engine.getLightManager();
auto& s = mUniforms.edit();

const float3 l = -sceneSpaceDirection; // guaranteed normalized
Expand All @@ -302,11 +302,11 @@ void PerViewUniforms::prepareDirectionalLight(FEngine& engine,
// The last parameter must be < 0.0f for regular directional lights
float4 sun{ 0.0f, 0.0f, 0.0f, -1.0f };
if (UTILS_UNLIKELY(isSun && colorIntensity.w > 0.0f)) {
// currently we have only a single directional light, so it's probably likely that it's
// Currently we have only a single directional light, so it's probably likely that it's
// also the Sun. However, conceptually, most directional lights won't be sun lights.
float radius = lcm.getSunAngularRadius(directionalLight);
float haloSize = lcm.getSunHaloSize(directionalLight);
float haloFalloff = lcm.getSunHaloFalloff(directionalLight);
float const radius = lcm.getSunAngularRadius(directionalLight);
float const haloSize = lcm.getSunHaloSize(directionalLight);
float const haloFalloff = lcm.getSunHaloFalloff(directionalLight);
sun.x = std::cos(radius);
sun.y = std::sin(radius);
sun.z = 1.0f / (std::cos(radius * haloSize) - sun.x);
Expand Down
4 changes: 2 additions & 2 deletions filament/src/components/LightManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@ class FLightManager : public LightManager {
}

bool isSpotLight(Instance i) const noexcept {
Type type = getType(i);
Type const type = getType(i);
return type == Type::FOCUSED_SPOT || type == Type::SPOT;
}

bool isDirectionalLight(Instance i) const noexcept {
Type type = getType(i);
Type const type = getType(i);
return type == Type::DIRECTIONAL || type == Type::SUN;
}

Expand Down
20 changes: 7 additions & 13 deletions libs/math/include/math/TQuatHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@
#include <stdint.h>
#include <sys/types.h>

namespace filament {
namespace math {
namespace details {
// -------------------------------------------------------------------------------------
namespace filament::math::details {

/*
* No user serviceable parts here.
Expand All @@ -49,7 +46,7 @@ namespace details {
template<template<typename T> class QUATERNION, typename T>
class TQuatProductOperators {
public:
/* compound assignment from a another quaternion of the same size but different
/* compound assignment from another quaternion of the same size but different
* element type.
*/
template<typename OTHER>
Expand Down Expand Up @@ -85,7 +82,7 @@ class TQuatProductOperators {
* (the first one, BASE<T> being known).
*/

/* The operators below handle operation between quaternion of the same size
/* The operators below handle operation between quaternions of the same size
* but of a different element type.
*/
template<typename RT>
Expand Down Expand Up @@ -127,19 +124,19 @@ class TQuatProductOperators {
*/
friend inline
constexpr QUATERNION<T> MATH_PURE operator*(QUATERNION<T> q, T scalar) {
// don't pass q by reference because we need a copy anyways
// don't pass q by reference because we need a copy anyway
return q *= scalar;
}

friend inline
constexpr QUATERNION<T> MATH_PURE operator*(T scalar, QUATERNION<T> q) {
// don't pass q by reference because we need a copy anyways
// don't pass q by reference because we need a copy anyway
return q *= scalar;
}

friend inline
constexpr QUATERNION<T> MATH_PURE operator/(QUATERNION<T> q, T scalar) {
// don't pass q by reference because we need a copy anyways
// don't pass q by reference because we need a copy anyway
return q /= scalar;
}
};
Expand Down Expand Up @@ -283,9 +280,6 @@ class TQuatFunctions {
}
};

// -------------------------------------------------------------------------------------
} // namespace details
} // namespace math
} // namespace filament
} // namespace filament::math::details

#endif // TNT_MATH_TQUATHELPERS_H
11 changes: 7 additions & 4 deletions libs/math/include/math/mathfwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@

#include <stdint.h>

namespace filament {
namespace math {
namespace filament::math {
namespace details {

template<typename T> class TVec2;
Expand All @@ -45,6 +44,8 @@ template<typename T> class TMat22;
template<typename T> class TMat33;
template<typename T> class TMat44;

template<typename T> class TQuaternion;

} // namespace details

using double2 = details::TVec2<double>;
Expand Down Expand Up @@ -86,8 +87,10 @@ using mat3f = details::TMat33<float>;
using mat4 = details::TMat44<double>;
using mat4f = details::TMat44<float>;

} // namespace math
} // namespace filament
using quat = details::TQuaternion<double>;
using quatf = details::TQuaternion<float>;

} // namespace filament::math

#endif // _MSC_VER

Expand Down
39 changes: 17 additions & 22 deletions libs/math/include/math/quat.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@
#include <stdint.h>
#include <sys/types.h>

namespace filament {
namespace math {
// -------------------------------------------------------------------------------------

namespace filament::math {
namespace details {

template<typename T>
Expand Down Expand Up @@ -89,15 +86,15 @@ class MATH_EMPTY_BASES TQuaternion :

// constructors

// leaves object uninitialized. use with caution.
// Leaves object uninitialized. Use with caution.
explicit constexpr TQuaternion(no_init) {}

// default constructor. sets all values to zero.
constexpr TQuaternion() : x(0), y(0), z(0), w(0) {}

// handles implicit conversion to a quat. must not be explicit.
// Handles implicit conversion to a quat. Must not be explicit.
template<typename A, typename = enable_if_arithmetic_t<A>>
constexpr TQuaternion(A w) : x(0), y(0), z(0), w(w) {}
constexpr TQuaternion(A w) : x(0), y(0), z(0), w(w) {} // NOLINT(google-explicit-constructor)

// initialize from 4 values to w + xi + yj + zk
template<typename A, typename B, typename C, typename D,
Expand Down Expand Up @@ -174,32 +171,30 @@ typedef details::TQuaternion<double> quat;
typedef details::TQuaternion<float> quatf;
typedef details::TQuaternion<half> quath;

constexpr inline quat operator""_i(long double v) {
return quat(0.0, double(v), 0.0, 0.0);
constexpr inline quat operator "" _i(long double v) {
return { 0.0, double(v), 0.0, 0.0 };
}

constexpr inline quat operator""_j(long double v) {
return quat(0.0, 0.0, double(v), 0.0);
constexpr inline quat operator "" _j(long double v) {
return { 0.0, 0.0, double(v), 0.0 };
}

constexpr inline quat operator""_k(long double v) {
return quat(0.0, 0.0, 0.0, double(v));
constexpr inline quat operator "" _k(long double v) {
return { 0.0, 0.0, 0.0, double(v) };
}

constexpr inline quat operator""_i(unsigned long long v) {
return quat(0.0, double(v), 0.0, 0.0);
constexpr inline quat operator "" _i(unsigned long long v) {
return { 0.0, double(v), 0.0, 0.0 };
}

constexpr inline quat operator""_j(unsigned long long v) {
return quat(0.0, 0.0, double(v), 0.0);
constexpr inline quat operator "" _j(unsigned long long v) {
return { 0.0, 0.0, double(v), 0.0 };
}

constexpr inline quat operator""_k(unsigned long long v) {
return quat(0.0, 0.0, 0.0, double(v));
constexpr inline quat operator "" _k(unsigned long long v) {
return { 0.0, 0.0, 0.0, double(v) };
}

// ----------------------------------------------------------------------------------------
} // namespace math
} // namespace filament
} // namespace filament::math

#endif // TNT_MATH_QUAT_H

0 comments on commit e0a37de

Please sign in to comment.