Improved error messages and moved safety check

Former-commit-id: 010051ae56a1d2c1ebfe8dca3ceae3488a4cef18
This commit is contained in:
Lynix 2014-07-13 17:08:13 +02:00
parent 73ba06ac1c
commit 8ecae371ee
1 changed files with 10 additions and 12 deletions

View File

@ -137,11 +137,11 @@ void NzCamera::SetFOV(float fov)
#if NAZARA_GRAPHICS_SAFE #if NAZARA_GRAPHICS_SAFE
if (NzNumberEquals(fov, 0.f)) if (NzNumberEquals(fov, 0.f))
{ {
NazaraError("Fov is null."); NazaraError("FOV must be different from zero");
return; return;
} }
#endif #endif
m_fov = fov; m_fov = fov;
m_frustumUpdated = false; m_frustumUpdated = false;
@ -191,14 +191,6 @@ void NzCamera::SetViewport(const NzRecti& viewport)
void NzCamera::SetZFar(float zFar) void NzCamera::SetZFar(float zFar)
{ {
#if NAZARA_GRAPHICS_SAFE
if (m_zNear > zFar)
{
NazaraError("zNear is greater than zFar.");
return;
}
#endif
m_zFar = zFar; m_zFar = zFar;
m_frustumUpdated = false; m_frustumUpdated = false;
@ -210,11 +202,11 @@ void NzCamera::SetZNear(float zNear)
#if NAZARA_GRAPHICS_SAFE #if NAZARA_GRAPHICS_SAFE
if (zNear < 0.f || NzNumberEquals(zNear, 0.f)) if (zNear < 0.f || NzNumberEquals(zNear, 0.f))
{ {
NazaraError("zNear is less than/equals 0."); NazaraError("ZNear shall be a strictly positive number");
return; return;
} }
#endif #endif
m_zNear = zNear; m_zNear = zNear;
m_frustumUpdated = false; m_frustumUpdated = false;
@ -298,6 +290,12 @@ void NzCamera::UpdateFrustum() const
void NzCamera::UpdateProjectionMatrix() const void NzCamera::UpdateProjectionMatrix() const
{ {
#if NAZARA_GRAPHICS_SAFE
// Il n'y a pas grand chose à faire d'autre qu'un avertissement à ce stade
if (m_zNear >= m_zFar)
NazaraWarning("ZNear is greater or equal to ZFar (" + NzString::Number(m_zNear) + " >= " + NzString::Number(m_zFar) + ").");
#endif
if (!m_viewportUpdated) if (!m_viewportUpdated)
UpdateViewport(); // Peut affecter l'aspect ratio UpdateViewport(); // Peut affecter l'aspect ratio