Fixed per-class thread safety

This commit is contained in:
Lynix
2012-05-08 08:20:57 +02:00
parent 45f3fc4e28
commit e91cde657b
44 changed files with 90 additions and 145 deletions

View File

@@ -14,6 +14,9 @@
#include <cstring>
#include <limits>
#include <stdexcept>
#define NAZARA_CLASS_MATRIX4
#include <Nazara/Math/ThreadSafety.hpp>
#include <Nazara/Core/Debug.hpp>
template<typename T>
@@ -289,6 +292,22 @@ void NzMatrix4<T>::SetIdentity()
0.0, 0.0, 0.0, 1.0);
}
template<typename T>
void NzMatrix4<T>::SetOrtho(T left, T top, T width, T height, T zNear, T zFar)
{
#if NAZARA_MATH_MATRIX_COLUMN_MAJOR
Set(2.0/(width-left), 0.0, 0.0, -(width+left)/(width-left),
0.0, 2.0/(top-height), 0.0, -(top+height)/(top-height),
0.0, 0.0, -2.0/(zFar-zNear), -(zFar+zNear)/(zFar-zNear),
0.0, 0.0, 0.0, 1.0);
#else
Set(2.0/(width-left), 0.0, 0.0, 0.0,
0.0, 2.0/(top-height), 0.0, 0.0,
0.0, 0.0, -2.0/(zFar-zNear), 0.0,
-(width+left)/(width-left), -(top+height)/(top-height), -(zFar+zNear)/(zFar-zNear), 1.0);
#endif
}
template<typename T>
void NzMatrix4<T>::SetLookAt(const NzVector3<T>& eye, const NzVector3<T>& center, const NzVector3<T>& up)
{
@@ -320,7 +339,7 @@ void NzMatrix4<T>::SetPerspective(T angle, T ratio, T zNear, T zFar)
angle = NzDegreeToRadian(angle/2);
#endif
T f = 1 / std::tan(angle);
auto f = 1 / std::tan(angle);
#if NAZARA_MATH_MATRIX_COLUMN_MAJOR
Set(f / ratio, 0.0, 0.0, 0.0,
@@ -713,6 +732,15 @@ NzMatrix4<T> NzMatrix4<T>::LookAt(const NzVector3<T>& eye, const NzVector3<T>& c
return matrix;
}
template<typename T>
NzMatrix4<T> NzMatrix4<T>::Ortho(T left, T top, T width, T height, T zNear, T zFar)
{
NzMatrix4 matrix;
matrix.SetOrtho(left, top, width, height, zNear, zFar);
return matrix;
}
template<typename T>
NzMatrix4<T> NzMatrix4<T>::Perspective(T angle, T ratio, T zNear, T zFar)
{
@@ -789,5 +817,6 @@ void NzMatrix4<T>::ReleaseMatrix()
m_sharedMatrix = nullptr;
}
#undef NAZARA_MATRIX4_INL
#include <Nazara/Core/DebugOff.hpp>