Skip to content

Commit

Permalink
Pass at making more imath header methods inline
Browse files Browse the repository at this point in the history
Signed-off-by: Owen Thompson <[email protected]>
  • Loading branch information
oxt3479 committed Aug 13, 2020
1 parent 6a7668f commit f3d2724
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 56 deletions.
29 changes: 14 additions & 15 deletions Imath/ImathEuler.h
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ Euler<T>::toXYZVector() const
}

template <class T>
constexpr Euler<T>::Euler()
constexpr inline Euler<T>::Euler()
: Vec3<T> (0, 0, 0),
_frameStatic (true),
_initialRepeated (false),
Expand All @@ -406,8 +406,7 @@ constexpr Euler<T>::Euler()
{}

template <class T>
IMATH_CONSTEXPR14
Euler<T>::Euler (typename Euler<T>::Order p)
IMATH_CONSTEXPR14 inline Euler<T>::Euler (typename Euler<T>::Order p)
: Vec3<T> (0, 0, 0),
_frameStatic (true),
_initialRepeated (false),
Expand Down Expand Up @@ -485,7 +484,7 @@ Euler<T>::extract (const Quat<T>& q)
}

template <class T>
void
inline void
Euler<T>::extract (const Matrix33<T>& M)
{
int i, j, k;
Expand Down Expand Up @@ -592,7 +591,7 @@ Euler<T>::extract (const Matrix33<T>& M)
}

template <class T>
void
inline void
Euler<T>::extract (const Matrix44<T>& M)
{
int i, j, k;
Expand Down Expand Up @@ -669,7 +668,7 @@ Euler<T>::extract (const Matrix44<T>& M)
}

template <class T>
Matrix33<T>
inline Matrix33<T>
Euler<T>::toMatrix33() const
{
int i, j, k;
Expand Down Expand Up @@ -728,7 +727,7 @@ Euler<T>::toMatrix33() const
}

template <class T>
Matrix44<T>
inline Matrix44<T>
Euler<T>::toMatrix44() const
{
int i, j, k;
Expand Down Expand Up @@ -787,7 +786,7 @@ Euler<T>::toMatrix44() const
}

template <class T>
Quat<T>
inline Quat<T>
Euler<T>::toQuat() const
{
Vec3<T> angles;
Expand Down Expand Up @@ -875,7 +874,7 @@ Euler<T>::setOrder (typename Euler<T>::Order p)
}

template <class T>
void
inline void
Euler<T>::set (typename Euler<T>::Axis axis, bool relative, bool parityEven, bool firstRepeats)
{
_initialAxis = axis;
Expand All @@ -885,7 +884,7 @@ Euler<T>::set (typename Euler<T>::Axis axis, bool relative, bool parityEven, boo
}

template <class T>
IMATH_CONSTEXPR14 const Euler<T>&
IMATH_CONSTEXPR14 inline const Euler<T>&
Euler<T>::operator= (const Euler<T>& euler)
{
x = euler.x;
Expand All @@ -899,7 +898,7 @@ Euler<T>::operator= (const Euler<T>& euler)
}

template <class T>
IMATH_CONSTEXPR14 const Euler<T>&
IMATH_CONSTEXPR14 inline const Euler<T>&
Euler<T>::operator= (const Vec3<T>& v)
{
x = v.x;
Expand All @@ -926,7 +925,7 @@ operator<< (std::ostream& o, const Euler<T>& euler)
}

template <class T>
IMATH_CONSTEXPR14 float
IMATH_CONSTEXPR14 inline float
Euler<T>::angleMod (T angle)
{
const T pi = static_cast<T> (M_PI);
Expand All @@ -941,7 +940,7 @@ Euler<T>::angleMod (T angle)
}

template <class T>
void
inline void
Euler<T>::simpleXYZRotation (Vec3<T>& xyzRot, const Vec3<T>& targetXyzRot)
{
Vec3<T> d = xyzRot - targetXyzRot;
Expand All @@ -951,7 +950,7 @@ Euler<T>::simpleXYZRotation (Vec3<T>& xyzRot, const Vec3<T>& targetXyzRot)
}

template <class T>
void
inline void
Euler<T>::nearestRotation (Vec3<T>& xyzRot, const Vec3<T>& targetXyzRot, Order order)
{
int i, j, k;
Expand Down Expand Up @@ -979,7 +978,7 @@ Euler<T>::nearestRotation (Vec3<T>& xyzRot, const Vec3<T>& targetXyzRot, Order o
}

template <class T>
void
inline void
Euler<T>::makeNear (const Euler<T>& target)
{
Vec3<T> xyzRot = toXYZVector();
Expand Down
52 changes: 26 additions & 26 deletions Imath/ImathFrustum.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ template <class T> Frustum<T>::~Frustum()
{}

template <class T>
IMATH_CONSTEXPR14 const Frustum<T>&
IMATH_CONSTEXPR14 inline const Frustum<T>&
Frustum<T>::operator= (const Frustum& f)
{
_nearPlane = f._nearPlane;
Expand All @@ -215,7 +215,7 @@ Frustum<T>::operator= (const Frustum& f)
}

template <class T>
constexpr bool
constexpr inline bool
Frustum<T>::operator== (const Frustum<T>& src) const
{
return _nearPlane == src._nearPlane && _farPlane == src._farPlane && _left == src._left &&
Expand All @@ -227,11 +227,11 @@ template <class T>
constexpr inline bool
Frustum<T>::operator!= (const Frustum<T>& src) const
{
return !operator== (src);
return !onperator == (src);
}

template <class T>
void
inline void
Frustum<T>::set (T n, T f, T l, T r, T t, T b, bool o)
{
_nearPlane = n;
Expand All @@ -244,7 +244,7 @@ Frustum<T>::set (T n, T f, T l, T r, T t, T b, bool o)
}

template <class T>
void
inline void
Frustum<T>::modifyNearAndFar (T n, T f)
{
if (_orthographic)
Expand Down Expand Up @@ -274,14 +274,14 @@ Frustum<T>::modifyNearAndFar (T n, T f)
}

template <class T>
void
inline void
Frustum<T>::setOrthographic (bool ortho)
{
_orthographic = ortho;
}

template <class T>
void
inline void
Frustum<T>::set (T nearPlane, T farPlane, T fovx, T fovy, T aspect)
{
if (fovx != 0 && fovy != 0)
Expand Down Expand Up @@ -309,21 +309,21 @@ Frustum<T>::set (T nearPlane, T farPlane, T fovx, T fovy, T aspect)
}

template <class T>
constexpr T
constexpr inline T
Frustum<T>::fovx() const
{
return Math<T>::atan2 (_right, _nearPlane) - Math<T>::atan2 (_left, _nearPlane);
}

template <class T>
constexpr T
constexpr inline T
Frustum<T>::fovy() const
{
return Math<T>::atan2 (_top, _nearPlane) - Math<T>::atan2 (_bottom, _nearPlane);
}

template <class T>
IMATH_CONSTEXPR14 T
IMATH_CONSTEXPR14 inline T
Frustum<T>::aspect() const
{
T rightMinusLeft = _right - _left;
Expand All @@ -339,7 +339,7 @@ Frustum<T>::aspect() const
}

template <class T>
IMATH_CONSTEXPR14 T
IMATH_CONSTEXPR14 inline T
Frustum<T>::aspect_noexcept() const noexcept
{
T rightMinusLeft = _right - _left;
Expand All @@ -348,7 +348,7 @@ Frustum<T>::aspect_noexcept() const noexcept
}

template <class T>
IMATH_CONSTEXPR14 Matrix44<T>
IMATH_CONSTEXPR14 inline Matrix44<T>
Frustum<T>::projectionMatrix() const
{
T rightPlusLeft = _right + _left;
Expand Down Expand Up @@ -424,7 +424,7 @@ Frustum<T>::projectionMatrix() const
}

template <class T>
IMATH_CONSTEXPR14 Matrix44<T>
IMATH_CONSTEXPR14 inline Matrix44<T>
Frustum<T>::projectionMatrix_noexcept() const noexcept
{
T rightPlusLeft = _right + _left;
Expand Down Expand Up @@ -468,14 +468,14 @@ Frustum<T>::projectionMatrix_noexcept() const noexcept
}

template <class T>
constexpr bool
constexpr inline bool
Frustum<T>::degenerate() const
{
return (_nearPlane == _farPlane) || (_left == _right) || (_top == _bottom);
}

template <class T>
IMATH_CONSTEXPR14 Frustum<T>
IMATH_CONSTEXPR14 inline Frustum<T>
Frustum<T>::window (T l, T r, T t, T b) const
{
// move it to 0->1 space
Expand All @@ -487,15 +487,15 @@ Frustum<T>::window (T l, T r, T t, T b) const
}

template <class T>
constexpr Vec2<T>
constexpr inline Vec2<T>
Frustum<T>::screenToLocal (const Vec2<T>& s) const
{
return Vec2<T> (_left + (_right - _left) * (1.f + s.x) / 2.f,
_bottom + (_top - _bottom) * (1.f + s.y) / 2.f);
}

template <class T>
IMATH_CONSTEXPR14 Vec2<T>
IMATH_CONSTEXPR14 inline Vec2<T>
Frustum<T>::localToScreen (const Vec2<T>& p) const
{
T leftPlusRight = _left - T (2) * p.x + _right;
Expand All @@ -516,7 +516,7 @@ Frustum<T>::localToScreen (const Vec2<T>& p) const
}

template <class T>
IMATH_CONSTEXPR14 Line3<T>
IMATH_CONSTEXPR14 inline Line3<T>
Frustum<T>::projectScreenToRay (const Vec2<T>& p) const
{
Vec2<T> point = screenToLocal (p);
Expand All @@ -527,7 +527,7 @@ Frustum<T>::projectScreenToRay (const Vec2<T>& p) const
}

template <class T>
IMATH_CONSTEXPR14 Vec2<T>
IMATH_CONSTEXPR14 inline Vec2<T>
Frustum<T>::projectPointToScreen (const Vec3<T>& point) const
{
if (orthographic() || point.z == T (0))
Expand All @@ -538,7 +538,7 @@ Frustum<T>::projectPointToScreen (const Vec3<T>& point) const
}

template <class T>
IMATH_CONSTEXPR14 T
IMATH_CONSTEXPR14 inline T
Frustum<T>::ZToDepth (long zval, long zmin, long zmax) const
{
int zdiff = zmax - zmin;
Expand All @@ -556,7 +556,7 @@ Frustum<T>::ZToDepth (long zval, long zmin, long zmax) const
}

template <class T>
IMATH_CONSTEXPR14 T
IMATH_CONSTEXPR14 inline T
Frustum<T>::normalizedZToDepth (T zval) const
{
T Zp = zval * 2.0 - 1;
Expand All @@ -582,7 +582,7 @@ Frustum<T>::normalizedZToDepth (T zval) const
}

template <class T>
IMATH_CONSTEXPR14 long
IMATH_CONSTEXPR14 inline long
Frustum<T>::DepthToZ (T depth, long zmin, long zmax) const
{
long zdiff = zmax - zmin;
Expand Down Expand Up @@ -627,7 +627,7 @@ Frustum<T>::DepthToZ (T depth, long zmin, long zmax) const
}

template <class T>
IMATH_CONSTEXPR14 T
IMATH_CONSTEXPR14 inline T
Frustum<T>::screenRadius (const Vec3<T>& p, T radius) const
{
// Derivation:
Expand All @@ -654,7 +654,7 @@ Frustum<T>::screenRadius (const Vec3<T>& p, T radius) const
}

template <class T>
IMATH_CONSTEXPR14 T
IMATH_CONSTEXPR14 inline T
Frustum<T>::worldRadius (const Vec3<T>& p, T radius) const
{
if (abs (-_nearPlane) > 1 || abs (p.z) < limits<T>::max() * abs (-_nearPlane))
Expand All @@ -669,7 +669,7 @@ Frustum<T>::worldRadius (const Vec3<T>& p, T radius) const
}

template <class T>
void
inline void
Frustum<T>::planes (Plane3<T> p[6]) const
{
//
Expand Down Expand Up @@ -702,7 +702,7 @@ Frustum<T>::planes (Plane3<T> p[6]) const
}

template <class T>
void
inline void
Frustum<T>::planes (Plane3<T> p[6], const Matrix44<T>& M) const
{
//
Expand Down
2 changes: 1 addition & 1 deletion Imath/ImathPlane.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ operator* (const Plane3<T>& plane, const Matrix44<T>& M)
}

template <class T>
constexpr Plane3<T>
constexpr inline Plane3<T>
operator- (const Plane3<T>& plane)
{
return Plane3<T> (-plane.normal, -plane.distance);
Expand Down
Loading

0 comments on commit f3d2724

Please sign in to comment.