Plasma Engine  2.0
Loading...
Searching...
No Matches
AmbientCubeBasis_inl.h
1#pragma once
2
3template <typename T>
4PL_ALWAYS_INLINE plAmbientCube<T>::plAmbientCube()
5{
7}
8
9template <typename T>
10template <typename U>
11PL_ALWAYS_INLINE plAmbientCube<T>::plAmbientCube(const plAmbientCube<U>& other)
12{
13 *this = other;
14}
15
16template <typename T>
17template <typename U>
18PL_FORCE_INLINE void plAmbientCube<T>::operator=(const plAmbientCube<U>& other)
19{
20 for (plUInt32 i = 0; i < plAmbientCubeBasis::NumDirs; ++i)
21 {
22 m_Values[i] = other.m_Values[i];
23 }
24}
25
26template <typename T>
27PL_FORCE_INLINE bool plAmbientCube<T>::operator==(const plAmbientCube& other) const
28{
29 return plMemoryUtils::IsEqual(m_Values, other.m_Values);
30}
31
32template <typename T>
33PL_ALWAYS_INLINE bool plAmbientCube<T>::operator!=(const plAmbientCube& other) const
34{
35 return !(*this == other);
36}
37
38template <typename T>
39void plAmbientCube<T>::AddSample(const plVec3& vDir, const T& value)
40{
41 m_Values[vDir.x > 0.0f ? 0 : 1] += plMath::Abs(vDir.x) * value;
42 m_Values[vDir.y > 0.0f ? 2 : 3] += plMath::Abs(vDir.y) * value;
43 m_Values[vDir.z > 0.0f ? 4 : 5] += plMath::Abs(vDir.z) * value;
44}
45
46template <typename T>
47T plAmbientCube<T>::Evaluate(const plVec3& vNormal) const
48{
49 plVec3 vNormalSquared = vNormal.CompMul(vNormal);
50 return vNormalSquared.x * m_Values[vNormal.x > 0.0f ? 0 : 1] + vNormalSquared.y * m_Values[vNormal.y > 0.0f ? 2 : 3] +
51 vNormalSquared.z * m_Values[vNormal.z > 0.0f ? 4 : 5];
52}
53
54template <typename T>
56{
57 return inout_stream.WriteArray(m_Values);
58}
59
60template <typename T>
62{
63 return inout_stream.ReadArray(m_Values);
64}
static bool IsEqual(const T *a, const T *b, size_t uiCount=1)
Tests if objects of type T from pSource and pDestination are equal.
static void ZeroFillArray(T(&destination)[N])
Zeros every byte in the provided memory buffer.
Interface for binary in (read) streams.
Definition Stream.h:22
plResult ReadArray(plArrayBase< ValueType, ArrayType > &inout_array)
Reads an array of elements from the stream.
Definition Stream_inl.h:349
Interface for binary out (write) streams.
Definition Stream.h:107
plResult WriteArray(const plArrayBase< ValueType, ArrayType > &array)
Writes an array of elements to the stream.
Definition Stream_inl.h:221
const plVec3Template< Type > CompMul(const plVec3Template< Type > &rhs) const
Returns the component-wise multiplication of *this and rhs.
Definition Vec3_inl.h:345
constexpr PL_ALWAYS_INLINE T Abs(T f)
Returns the absolute value of f.
Definition Math_inl.h:21
Definition AmbientCubeBasis.h:27
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54