diff --git a/examples/HardwareInfo/main.cpp b/examples/HardwareInfo/main.cpp index 07beced54..d1a12dade 100644 --- a/examples/HardwareInfo/main.cpp +++ b/examples/HardwareInfo/main.cpp @@ -24,9 +24,6 @@ int main() // On va afficher le tout via un ostringstream, pour écrire dans la console et aussi dans un fichier std::ostringstream oss; - - char accentAigu = static_cast(130); // C'est crade, mais ça marche chez 95% des Windowsiens - oss << "--Processeur--" << std::endl; // Plutôt que d'initialiser le Renderer de Nazara, nous initialisons les deux classes utilisées ici // Elles sont compatibles avec NzInitialiser et seront donc libérées automatiquement @@ -44,7 +41,7 @@ int main() oss << std::endl; // Ensuite, Nazara récupère les capacités du processeur, dont des jeux d'extensions supplémentaires - oss << "Report des capacit" << accentAigu << "s: " << std::endl; + oss << "Rapport des capacites: " << std::endl;// Pas d'accent car écriture dans un fichier (et on ne va pas s'embêter avec ça) printCap(oss, "-64bits", NzHardwareInfo::HasCapability(nzProcessorCap_x64)); printCap(oss, "-AVX", NzHardwareInfo::HasCapability(nzProcessorCap_AVX)); printCap(oss, "-FMA3", NzHardwareInfo::HasCapability(nzProcessorCap_FMA3)); @@ -81,7 +78,7 @@ int main() oss << std::endl; // Ainsi qu'un report des capacités de la carte graphique (avec le driver actuel) - oss << "Report des capacit" << accentAigu << "s: " << std::endl; + oss << "Rapport des capacites: " << std::endl; // Pas d'accent car écriture dans un fichier (et on ne va pas s'embêter avec ça) printCap(oss, "-Calculs 64bits", NzOpenGL::IsSupported(nzOpenGLExtension_FP64)); printCap(oss, "-Compression de textures (s3tc)", NzOpenGL::IsSupported(nzOpenGLExtension_TextureCompression_s3tc)); printCap(oss, "-Filtrage anisotrope", NzOpenGL::IsSupported(nzOpenGLExtension_AnisotropicFilter)); @@ -108,6 +105,7 @@ int main() reportFile.Write(oss.str()); // Conversion implicite en NzString reportFile.Close(); + char accentAigu = static_cast(130); // C'est crade, mais ça marche chez 95% des Windowsiens std::cout << "Un fichier (RapportHardwareInfo.txt) contenant le rapport a " << accentAigu << 't' << accentAigu << " cr" << accentAigu << accentAigu << std::endl; } else diff --git a/include/Nazara/Math/Box.inl b/include/Nazara/Math/Box.inl index 989e7108e..e8f9b8fed 100644 --- a/include/Nazara/Math/Box.inl +++ b/include/Nazara/Math/Box.inl @@ -159,7 +159,7 @@ NzSphere NzBox::GetBoundingSphere() const template NzVector3 NzBox::GetCenter() const { - return GetPosition() + F(0.5)*GetLengths(); + return GetPosition() + GetLengths()/F(2.0); } template @@ -237,7 +237,7 @@ template T NzBox::GetSquaredRadius() const { NzVector3 size(GetLengths()); - size *= F(0.5); // La taille étant relative à la position (minimum) de la boite et non pas à son centre + size /= F(2.0); // La taille étant relative à la position (minimum) de la boite et non pas à son centre return size.GetSquaredLength(); } @@ -394,7 +394,7 @@ template NzBox& NzBox::Transform(const NzMatrix4& matrix, bool applyTranslation) { NzVector3 center = matrix.Transform(GetCenter(), (applyTranslation) ? F(1.0) : F(0.0)); // Valeur multipliant la translation - NzVector3 halfSize = GetLengths() * F(0.5); + NzVector3 halfSize = GetLengths()/F(2.0); halfSize.Set(std::fabs(matrix(0,0))*halfSize.x + std::fabs(matrix(1,0))*halfSize.y + std::fabs(matrix(2,0))*halfSize.z, std::fabs(matrix(0,1))*halfSize.x + std::fabs(matrix(1,1))*halfSize.y + std::fabs(matrix(2,1))*halfSize.z, @@ -465,6 +465,7 @@ NzBox& NzBox::operator*=(T scalar) width *= scalar; height *= scalar; depth *= scalar; + return *this; } @@ -474,6 +475,7 @@ NzBox& NzBox::operator*=(const NzVector3& vec) width *= vec.x; height *= vec.y; depth *= vec.z; + return *this; } diff --git a/include/Nazara/Math/Frustum.inl b/include/Nazara/Math/Frustum.inl index 300031d88..8541a34f1 100644 --- a/include/Nazara/Math/Frustum.inl +++ b/include/Nazara/Math/Frustum.inl @@ -24,9 +24,9 @@ template NzFrustum& NzFrustum::Build(T angle, T ratio, T zNear, T zFar, const NzVector3& eye, const NzVector3& target, const NzVector3& up) { #if NAZARA_MATH_ANGLE_RADIAN - angle *= F(0.5); + angle /= F(2.0); #else - angle = NzDegreeToRadian(angle * F(0.5)); + angle = NzDegreeToRadian(angle/F(2.0)); #endif T tangent = std::tan(angle); diff --git a/include/Nazara/Math/Matrix4.inl b/include/Nazara/Math/Matrix4.inl index 173653ebb..2531b51dd 100644 --- a/include/Nazara/Math/Matrix4.inl +++ b/include/Nazara/Math/Matrix4.inl @@ -573,9 +573,9 @@ NzMatrix4& NzMatrix4::MakePerspective(T angle, T ratio, T zNear, T zFar) { // http://msdn.microsoft.com/en-us/library/windows/desktop/bb204945(v=vs.85).aspx #if NAZARA_MATH_ANGLE_RADIAN - angle *= F(0.5); + angle /= F(2.0); #else - angle = NzDegreeToRadian(angle * F(0.5)); + angle = NzDegreeToRadian(angle/F(2.0)); #endif T yScale = F(1.0) / std::tan(angle); diff --git a/include/Nazara/Math/OrientedBox.inl b/include/Nazara/Math/OrientedBox.inl index fcc91e4d1..33a131c72 100644 --- a/include/Nazara/Math/OrientedBox.inl +++ b/include/Nazara/Math/OrientedBox.inl @@ -7,6 +7,8 @@ #include #include +///DOC: Pour que les coins soient valides, la méthode Update doit être appelée + #define F(a) static_cast(a) template @@ -60,8 +62,7 @@ template NzOrientedBox& NzOrientedBox::MakeZero() { localBox.MakeZero(); - for (unsigned int i = 0; i <= nzCorner_Max; ++i) - m_corners[i].Set(NzVector3::Zero()); + return *this; } @@ -70,8 +71,6 @@ NzOrientedBox& NzOrientedBox::Set(T X, T Y, T Z, T Width, T Height, T Dept { localBox.Set(X, Y, Z, Width, Height, Depth); - for (unsigned int i = 0; i <= nzCorner_Max; ++i) - m_corners[i].Set(localBox.GetCorner(static_cast(i))); return *this; } @@ -80,8 +79,6 @@ NzOrientedBox& NzOrientedBox::Set(const NzBox& box) { localBox.Set(box); - for (unsigned int i = 0; i <= nzCorner_Max; ++i) - m_corners[i].Set(localBox.GetCorner(static_cast(i))); return *this; } @@ -98,8 +95,6 @@ NzOrientedBox& NzOrientedBox::Set(const NzVector3& vec1, const NzVector { localBox.Set(vec1, vec2); - for (unsigned int i = 0; i <= nzCorner_Max; ++i) - m_corners[i].Set(localBox.GetCorner(static_cast(i))); return *this; } @@ -134,7 +129,7 @@ template void NzOrientedBox::Update(const NzMatrix4& transformMatrix) { for (unsigned int i = 0; i <= nzCorner_Max; ++i) - m_corners[i] = transformMatrix.Transform(m_corners[i]); + m_corners[i] = transformMatrix.Transform(localBox.GetCorner(static_cast(i))); } template @@ -189,8 +184,6 @@ NzOrientedBox NzOrientedBox::operator*(T scalar) const NzOrientedBox box(*this); box *= scalar; - for (unsigned int i = 0; i <= nzCorner_Max; ++i) - box.m_corners[i].Set(box.GetCorner(static_cast(i))); return box; } @@ -199,8 +192,6 @@ NzOrientedBox& NzOrientedBox::operator*=(T scalar) { localBox *= scalar; - for (unsigned int i = 0; i <= nzCorner_Max; ++i) - m_corners[i].Set(localBox.GetCorner(static_cast(i))); return *this; } diff --git a/include/Nazara/Math/Rect.hpp b/include/Nazara/Math/Rect.hpp index df7611b13..a133b7ed6 100644 --- a/include/Nazara/Math/Rect.hpp +++ b/include/Nazara/Math/Rect.hpp @@ -68,7 +68,7 @@ class NzRect NzRect& operator*=(T scalar); NzRect& operator*=(const NzVector2& vec); - NzRect& operator/=(T scalar); + NzRect& operator/=(T scalar); NzRect& operator/=(const NzVector2& vec); bool operator==(const NzRect& rect) const; diff --git a/include/Nazara/Math/Rect.inl b/include/Nazara/Math/Rect.inl index b2fd3a3e4..ab35b30c5 100644 --- a/include/Nazara/Math/Rect.inl +++ b/include/Nazara/Math/Rect.inl @@ -353,6 +353,7 @@ NzRect& NzRect::operator*=(T scalar) { width *= scalar; height *= scalar; + return *this; } @@ -361,6 +362,7 @@ NzRect& NzRect::operator*=(const NzVector2& vec) { width *= vec.x; height *= vec.y; + return *this; } diff --git a/include/Nazara/Math/Sphere.hpp b/include/Nazara/Math/Sphere.hpp index 975893076..64378a949 100644 --- a/include/Nazara/Math/Sphere.hpp +++ b/include/Nazara/Math/Sphere.hpp @@ -8,7 +8,6 @@ #define NAZARA_SPHERE_HPP #include -#include #include template diff --git a/include/Nazara/Math/Sphere.inl b/include/Nazara/Math/Sphere.inl index 2f74945dc..9c56fac16 100644 --- a/include/Nazara/Math/Sphere.inl +++ b/include/Nazara/Math/Sphere.inl @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -81,7 +82,6 @@ template NzSphere& NzSphere::ExtendTo(T X, T Y, T Z) { T distance = SquaredDistance(X, Y, Z); - if (distance > radius*radius) radius = std::sqrt(distance); @@ -120,32 +120,48 @@ NzVector3 NzSphere::GetPositiveVertex(const NzVector3& normal) const template bool NzSphere::Intersect(const NzBox& box) const { - // Arvo's algorithm. - T dmin = T(0); - if (x < box.x) - dmin += (x - box.x) * (x - box.x); - else if (x > box.x + box.width) - dmin += (x - (box.x + box.width)) * (x - (box.x + box.width)); + // Arvo's algorithm. + T squaredDistance = T(0.0); + if (x < box.x) + { + T diff = x - box.x; + squaredDistance += diff*diff; + } + else if (x > box.x + box.width) + { + T diff = x - (box.x + box.width); + squaredDistance += diff*diff; + } - if (y < box.y) - dmin += (y - box.y) * (y - box.y); - else if (x > box.x + box.width) - dmin += (y - (box.y + box.height)) * (y - (box.y + box.height)); + if (y < box.y) + { + T diff = y - box.y; + squaredDistance += diff*diff; + } + else if (y > box.y + box.height) + { + T diff = y - (box.y + box.height); + squaredDistance += diff*diff; + } - if (z < box.z) - dmin += (z - box.z) * (z - box.z); - else if (x > box.x + box.width) - dmin += (z - (box.z + box.depth)) * (z - (box.z + box.depth)); + if (z < box.z) + { + T diff = z - box.z; + squaredDistance += diff*diff; + } + else if (z > box.z + box.depth) + { + T diff = z - (box.z + box.depth); + squaredDistance += diff*diff; + } - if (dmin <= radius * radius) - return true; - return false; + return squaredDistance <= radius * radius; } template bool NzSphere::Intersect(const NzSphere& sphere) const { - return std::abs(SquaredDistance(sphere.x, sphere.y, sphere.z) - radius*radius) <= sphere.radius*sphere.radius; + return SquaredDistance(sphere.x, sphere.y, sphere.z) - radius*radius <= sphere.radius*sphere.radius; } template diff --git a/src/Nazara/Core/Win32/TaskSchedulerImpl.cpp b/src/Nazara/Core/Win32/TaskSchedulerImpl.cpp index 0dccbff11..c55d84202 100644 --- a/src/Nazara/Core/Win32/TaskSchedulerImpl.cpp +++ b/src/Nazara/Core/Win32/TaskSchedulerImpl.cpp @@ -4,10 +4,10 @@ #include #include -#include #include -#include +#include // std::ldiv #include +#include bool NzTaskSchedulerImpl::Initialize(unsigned int workerCount) {