From e9554ad4986900a0839d5a85d09f233b330a65c3 Mon Sep 17 00:00:00 2001 From: Gawaboumga Date: Sun, 13 Jul 2014 16:03:15 +0200 Subject: [PATCH 1/2] Coherence update Audio: GetListenerDirection was using ALfloat and GetListenerRotation not. ByteArray: Two return *this, hazh is perturbing, is it intended ? String: Same ? Camera: Adds of security (don't think it's usefull) Parser: size() = 0 -> empty() Utility: update 13 to 14 was forgotten VertexDeclaration: same Former-commit-id: f6db5cd15e5a4dc5ac2af12366b18d1f6922b0e0 --- src/Nazara/Audio/Audio.cpp | 2 +- src/Nazara/Core/ByteArray.cpp | 6 ++---- src/Nazara/Core/String.cpp | 4 ++-- src/Nazara/Graphics/Camera.cpp | 21 +++++++++++++++++++ src/Nazara/Utility/Loaders/MD5Mesh/Parser.cpp | 6 +++--- src/Nazara/Utility/Utility.cpp | 4 ++-- src/Nazara/Utility/VertexDeclaration.cpp | 1 + 7 files changed, 32 insertions(+), 12 deletions(-) diff --git a/src/Nazara/Audio/Audio.cpp b/src/Nazara/Audio/Audio.cpp index 68f91878a..656dccdcd 100644 --- a/src/Nazara/Audio/Audio.cpp +++ b/src/Nazara/Audio/Audio.cpp @@ -62,7 +62,7 @@ NzVector3f NzAudio::GetListenerPosition() NzQuaternionf NzAudio::GetListenerRotation() { - float orientation[6]; + ALfloat orientation[6]; alGetListenerfv(AL_ORIENTATION, orientation); NzVector3f forward(orientation[0], orientation[1], orientation[2]); diff --git a/src/Nazara/Core/ByteArray.cpp b/src/Nazara/Core/ByteArray.cpp index bc4f0281e..94903dd4d 100644 --- a/src/Nazara/Core/ByteArray.cpp +++ b/src/Nazara/Core/ByteArray.cpp @@ -169,8 +169,6 @@ NzByteArray& NzByteArray::Insert(int pos, const void* buffer, unsigned int size) } return *this; - - return *this; } NzByteArray& NzByteArray::Insert(int pos, const NzByteArray& array) @@ -464,9 +462,9 @@ void NzByteArray::EnsureOwnership() } } -bool NzByteArray::FillHash(NzAbstractHash* hazh) const +bool NzByteArray::FillHash(NzAbstractHash* hash) const { - hazh->Append(m_sharedArray->buffer, m_sharedArray->size); + hash->Append(m_sharedArray->buffer, m_sharedArray->size); return true; } diff --git a/src/Nazara/Core/String.cpp b/src/Nazara/Core/String.cpp index 5ae47c8cf..54e5b3eb7 100644 --- a/src/Nazara/Core/String.cpp +++ b/src/Nazara/Core/String.cpp @@ -4351,9 +4351,9 @@ void NzString::EnsureOwnership(bool discardContent) } } -bool NzString::FillHash(NzAbstractHash* hazh) const +bool NzString::FillHash(NzAbstractHash* hash) const { - hazh->Append(reinterpret_cast(m_sharedString->string), m_sharedString->size); + hash->Append(reinterpret_cast(m_sharedString->string), m_sharedString->size); return true; } diff --git a/src/Nazara/Graphics/Camera.cpp b/src/Nazara/Graphics/Camera.cpp index ff941eba7..b32c9d96a 100644 --- a/src/Nazara/Graphics/Camera.cpp +++ b/src/Nazara/Graphics/Camera.cpp @@ -134,6 +134,13 @@ float NzCamera::GetZNear() const void NzCamera::SetFOV(float fov) { + #if NAZARA_GRAPHICS_SAFE + if (NzNumberEquals(fov, 0.f)) + { + NazaraError("Fov is null."); + return; + } + #endif m_fov = fov; m_frustumUpdated = false; @@ -183,6 +190,13 @@ void NzCamera::SetViewport(const NzRecti& viewport) 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_frustumUpdated = false; @@ -191,6 +205,13 @@ void NzCamera::SetZFar(float zFar) void NzCamera::SetZNear(float zNear) { + #if NAZARA_GRAPHICS_SAFE + if (zNear < 0.f || NzNumberEquals(zNear, 0.f)) + { + NazaraError("zNear is less than/equals 0."); + return; + } + #endif m_zNear = zNear; m_frustumUpdated = false; diff --git a/src/Nazara/Utility/Loaders/MD5Mesh/Parser.cpp b/src/Nazara/Utility/Loaders/MD5Mesh/Parser.cpp index 4415fad1b..03e244a0c 100644 --- a/src/Nazara/Utility/Loaders/MD5Mesh/Parser.cpp +++ b/src/Nazara/Utility/Loaders/MD5Mesh/Parser.cpp @@ -632,19 +632,19 @@ bool NzMD5MeshParser::ParseMesh() } } - if (m_meshes[m_meshIndex].triangles.size() == 0) + if (m_meshes[m_meshIndex].triangles.empty()) { NazaraError("Mesh has no triangles"); return false; } - if (m_meshes[m_meshIndex].vertices.size() == 0) + if (m_meshes[m_meshIndex].vertices.empty()) { NazaraError("Mesh has no vertices"); return false; } - if (m_meshes[m_meshIndex].weights.size() == 0) + if (m_meshes[m_meshIndex].weights.empty()) { NazaraError("Mesh has no weights"); return false; diff --git a/src/Nazara/Utility/Utility.cpp b/src/Nazara/Utility/Utility.cpp index 639272c79..f5acedf22 100644 --- a/src/Nazara/Utility/Utility.cpp +++ b/src/Nazara/Utility/Utility.cpp @@ -143,7 +143,7 @@ unsigned int NzUtility::ComponentCount[nzComponentType_Max+1] = 4 // nzComponentType_Int4 }; -static_assert(nzComponentType_Max+1 == 13, "Component count array is incomplete"); +static_assert(nzComponentType_Max+1 == 14, "Component count array is incomplete"); unsigned int NzUtility::ComponentStride[nzComponentType_Max+1] = { @@ -162,6 +162,6 @@ unsigned int NzUtility::ComponentStride[nzComponentType_Max+1] = 4*sizeof(nzUInt32) // nzComponentType_Int4 }; -static_assert(nzComponentType_Max+1 == 13, "Component stride array is incomplete"); +static_assert(nzComponentType_Max+1 == 14, "Component stride array is incomplete"); unsigned int NzUtility::s_moduleReferenceCounter = 0; diff --git a/src/Nazara/Utility/VertexDeclaration.cpp b/src/Nazara/Utility/VertexDeclaration.cpp index dcef40e6b..37c9ef9bf 100644 --- a/src/Nazara/Utility/VertexDeclaration.cpp +++ b/src/Nazara/Utility/VertexDeclaration.cpp @@ -167,6 +167,7 @@ bool NzVertexDeclaration::IsTypeSupported(nzComponentType type) case nzComponentType_Int2: case nzComponentType_Int3: case nzComponentType_Int4: + case nzComponentType_Quaternion: return true; } From 4c63c53c44e15596dddfa7da5ed5a78e63262924 Mon Sep 17 00:00:00 2001 From: Gawaboumga Date: Sun, 13 Jul 2014 16:09:21 +0200 Subject: [PATCH 2/2] Indentation Former-commit-id: 17c357f50ffec9787e6c50dd638c85388fb344ca --- src/Nazara/Graphics/Camera.cpp | 5 ++++- src/Nazara/Utility/VertexDeclaration.cpp | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Nazara/Graphics/Camera.cpp b/src/Nazara/Graphics/Camera.cpp index b32c9d96a..77b797123 100644 --- a/src/Nazara/Graphics/Camera.cpp +++ b/src/Nazara/Graphics/Camera.cpp @@ -141,6 +141,7 @@ void NzCamera::SetFOV(float fov) return; } #endif + m_fov = fov; m_frustumUpdated = false; @@ -190,13 +191,14 @@ void NzCamera::SetViewport(const NzRecti& viewport) void NzCamera::SetZFar(float zFar) { - #if NAZARA_GRAPHICS_SAFE + #if NAZARA_GRAPHICS_SAFE if (m_zNear > zFar) { NazaraError("zNear is greater than zFar."); return; } #endif + m_zFar = zFar; m_frustumUpdated = false; @@ -212,6 +214,7 @@ void NzCamera::SetZNear(float zNear) return; } #endif + m_zNear = zNear; m_frustumUpdated = false; diff --git a/src/Nazara/Utility/VertexDeclaration.cpp b/src/Nazara/Utility/VertexDeclaration.cpp index 37c9ef9bf..29c1bd463 100644 --- a/src/Nazara/Utility/VertexDeclaration.cpp +++ b/src/Nazara/Utility/VertexDeclaration.cpp @@ -167,7 +167,7 @@ bool NzVertexDeclaration::IsTypeSupported(nzComponentType type) case nzComponentType_Int2: case nzComponentType_Int3: case nzComponentType_Int4: - case nzComponentType_Quaternion: + case nzComponentType_Quaternion: return true; }