Fixed some of the pull request code in order to merge it

Former-commit-id: d8a9734fc622cb57f98b3b6abd2579922d562aa0
This commit is contained in:
Lynix 2014-06-15 01:55:07 +02:00 committed by Gawaboumga
parent 55c205a5e5
commit dc3f3eb344
10 changed files with 56 additions and 48 deletions

View File

@ -24,9 +24,6 @@ int main()
// On va afficher le tout via un ostringstream, pour écrire dans la console et aussi dans un fichier // On va afficher le tout via un ostringstream, pour écrire dans la console et aussi dans un fichier
std::ostringstream oss; std::ostringstream oss;
char accentAigu = static_cast<char>(130); // C'est crade, mais ça marche chez 95% des Windowsiens
oss << "--Processeur--" << std::endl; oss << "--Processeur--" << std::endl;
// Plutôt que d'initialiser le Renderer de Nazara, nous initialisons les deux classes utilisées ici // 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 // Elles sont compatibles avec NzInitialiser et seront donc libérées automatiquement
@ -44,7 +41,7 @@ int main()
oss << std::endl; oss << std::endl;
// Ensuite, Nazara récupère les capacités du processeur, dont des jeux d'extensions supplémentaires // 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, "-64bits", NzHardwareInfo::HasCapability(nzProcessorCap_x64));
printCap(oss, "-AVX", NzHardwareInfo::HasCapability(nzProcessorCap_AVX)); printCap(oss, "-AVX", NzHardwareInfo::HasCapability(nzProcessorCap_AVX));
printCap(oss, "-FMA3", NzHardwareInfo::HasCapability(nzProcessorCap_FMA3)); printCap(oss, "-FMA3", NzHardwareInfo::HasCapability(nzProcessorCap_FMA3));
@ -81,7 +78,7 @@ int main()
oss << std::endl; oss << std::endl;
// Ainsi qu'un report des capacités de la carte graphique (avec le driver actuel) // 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, "-Calculs 64bits", NzOpenGL::IsSupported(nzOpenGLExtension_FP64));
printCap(oss, "-Compression de textures (s3tc)", NzOpenGL::IsSupported(nzOpenGLExtension_TextureCompression_s3tc)); printCap(oss, "-Compression de textures (s3tc)", NzOpenGL::IsSupported(nzOpenGLExtension_TextureCompression_s3tc));
printCap(oss, "-Filtrage anisotrope", NzOpenGL::IsSupported(nzOpenGLExtension_AnisotropicFilter)); printCap(oss, "-Filtrage anisotrope", NzOpenGL::IsSupported(nzOpenGLExtension_AnisotropicFilter));
@ -108,6 +105,7 @@ int main()
reportFile.Write(oss.str()); // Conversion implicite en NzString reportFile.Write(oss.str()); // Conversion implicite en NzString
reportFile.Close(); reportFile.Close();
char accentAigu = static_cast<char>(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; std::cout << "Un fichier (RapportHardwareInfo.txt) contenant le rapport a " << accentAigu << 't' << accentAigu << " cr" << accentAigu << accentAigu << std::endl;
} }
else else

View File

@ -159,7 +159,7 @@ NzSphere<T> NzBox<T>::GetBoundingSphere() const
template<typename T> template<typename T>
NzVector3<T> NzBox<T>::GetCenter() const NzVector3<T> NzBox<T>::GetCenter() const
{ {
return GetPosition() + F(0.5)*GetLengths(); return GetPosition() + GetLengths()/F(2.0);
} }
template<typename T> template<typename T>
@ -237,7 +237,7 @@ template<typename T>
T NzBox<T>::GetSquaredRadius() const T NzBox<T>::GetSquaredRadius() const
{ {
NzVector3<T> size(GetLengths()); NzVector3<T> 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(); return size.GetSquaredLength();
} }
@ -394,7 +394,7 @@ template<typename T>
NzBox<T>& NzBox<T>::Transform(const NzMatrix4<T>& matrix, bool applyTranslation) NzBox<T>& NzBox<T>::Transform(const NzMatrix4<T>& matrix, bool applyTranslation)
{ {
NzVector3<T> center = matrix.Transform(GetCenter(), (applyTranslation) ? F(1.0) : F(0.0)); // Valeur multipliant la translation NzVector3<T> center = matrix.Transform(GetCenter(), (applyTranslation) ? F(1.0) : F(0.0)); // Valeur multipliant la translation
NzVector3<T> halfSize = GetLengths() * F(0.5); NzVector3<T> 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, 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, 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<T>& NzBox<T>::operator*=(T scalar)
width *= scalar; width *= scalar;
height *= scalar; height *= scalar;
depth *= scalar; depth *= scalar;
return *this; return *this;
} }
@ -474,6 +475,7 @@ NzBox<T>& NzBox<T>::operator*=(const NzVector3<T>& vec)
width *= vec.x; width *= vec.x;
height *= vec.y; height *= vec.y;
depth *= vec.z; depth *= vec.z;
return *this; return *this;
} }

View File

@ -24,9 +24,9 @@ template<typename T>
NzFrustum<T>& NzFrustum<T>::Build(T angle, T ratio, T zNear, T zFar, const NzVector3<T>& eye, const NzVector3<T>& target, const NzVector3<T>& up) NzFrustum<T>& NzFrustum<T>::Build(T angle, T ratio, T zNear, T zFar, const NzVector3<T>& eye, const NzVector3<T>& target, const NzVector3<T>& up)
{ {
#if NAZARA_MATH_ANGLE_RADIAN #if NAZARA_MATH_ANGLE_RADIAN
angle *= F(0.5); angle /= F(2.0);
#else #else
angle = NzDegreeToRadian(angle * F(0.5)); angle = NzDegreeToRadian(angle/F(2.0));
#endif #endif
T tangent = std::tan(angle); T tangent = std::tan(angle);

View File

@ -573,9 +573,9 @@ NzMatrix4<T>& NzMatrix4<T>::MakePerspective(T angle, T ratio, T zNear, T zFar)
{ {
// http://msdn.microsoft.com/en-us/library/windows/desktop/bb204945(v=vs.85).aspx // http://msdn.microsoft.com/en-us/library/windows/desktop/bb204945(v=vs.85).aspx
#if NAZARA_MATH_ANGLE_RADIAN #if NAZARA_MATH_ANGLE_RADIAN
angle *= F(0.5); angle /= F(2.0);
#else #else
angle = NzDegreeToRadian(angle * F(0.5)); angle = NzDegreeToRadian(angle/F(2.0));
#endif #endif
T yScale = F(1.0) / std::tan(angle); T yScale = F(1.0) / std::tan(angle);

View File

@ -7,6 +7,8 @@
#include <cstring> #include <cstring>
#include <Nazara/Core/Debug.hpp> #include <Nazara/Core/Debug.hpp>
///DOC: Pour que les coins soient valides, la méthode Update doit être appelée
#define F(a) static_cast<T>(a) #define F(a) static_cast<T>(a)
template<typename T> template<typename T>
@ -60,8 +62,7 @@ template<typename T>
NzOrientedBox<T>& NzOrientedBox<T>::MakeZero() NzOrientedBox<T>& NzOrientedBox<T>::MakeZero()
{ {
localBox.MakeZero(); localBox.MakeZero();
for (unsigned int i = 0; i <= nzCorner_Max; ++i)
m_corners[i].Set(NzVector3<T>::Zero());
return *this; return *this;
} }
@ -70,8 +71,6 @@ NzOrientedBox<T>& NzOrientedBox<T>::Set(T X, T Y, T Z, T Width, T Height, T Dept
{ {
localBox.Set(X, Y, Z, Width, Height, Depth); 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<nzCorner>(i)));
return *this; return *this;
} }
@ -80,8 +79,6 @@ NzOrientedBox<T>& NzOrientedBox<T>::Set(const NzBox<T>& box)
{ {
localBox.Set(box); localBox.Set(box);
for (unsigned int i = 0; i <= nzCorner_Max; ++i)
m_corners[i].Set(localBox.GetCorner(static_cast<nzCorner>(i)));
return *this; return *this;
} }
@ -98,8 +95,6 @@ NzOrientedBox<T>& NzOrientedBox<T>::Set(const NzVector3<T>& vec1, const NzVector
{ {
localBox.Set(vec1, vec2); localBox.Set(vec1, vec2);
for (unsigned int i = 0; i <= nzCorner_Max; ++i)
m_corners[i].Set(localBox.GetCorner(static_cast<nzCorner>(i)));
return *this; return *this;
} }
@ -134,7 +129,7 @@ template<typename T>
void NzOrientedBox<T>::Update(const NzMatrix4<T>& transformMatrix) void NzOrientedBox<T>::Update(const NzMatrix4<T>& transformMatrix)
{ {
for (unsigned int i = 0; i <= nzCorner_Max; ++i) 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<nzCorner>(i)));
} }
template<typename T> template<typename T>
@ -189,8 +184,6 @@ NzOrientedBox<T> NzOrientedBox<T>::operator*(T scalar) const
NzOrientedBox box(*this); NzOrientedBox box(*this);
box *= scalar; box *= scalar;
for (unsigned int i = 0; i <= nzCorner_Max; ++i)
box.m_corners[i].Set(box.GetCorner(static_cast<nzCorner>(i)));
return box; return box;
} }
@ -199,8 +192,6 @@ NzOrientedBox<T>& NzOrientedBox<T>::operator*=(T scalar)
{ {
localBox *= scalar; localBox *= scalar;
for (unsigned int i = 0; i <= nzCorner_Max; ++i)
m_corners[i].Set(localBox.GetCorner(static_cast<nzCorner>(i)));
return *this; return *this;
} }

View File

@ -68,7 +68,7 @@ class NzRect
NzRect& operator*=(T scalar); NzRect& operator*=(T scalar);
NzRect& operator*=(const NzVector2<T>& vec); NzRect& operator*=(const NzVector2<T>& vec);
NzRect& operator/=(T scalar); NzRect& operator/=(T scalar);
NzRect& operator/=(const NzVector2<T>& vec); NzRect& operator/=(const NzVector2<T>& vec);
bool operator==(const NzRect& rect) const; bool operator==(const NzRect& rect) const;

View File

@ -353,6 +353,7 @@ NzRect<T>& NzRect<T>::operator*=(T scalar)
{ {
width *= scalar; width *= scalar;
height *= scalar; height *= scalar;
return *this; return *this;
} }
@ -361,6 +362,7 @@ NzRect<T>& NzRect<T>::operator*=(const NzVector2<T>& vec)
{ {
width *= vec.x; width *= vec.x;
height *= vec.y; height *= vec.y;
return *this; return *this;
} }

View File

@ -8,7 +8,6 @@
#define NAZARA_SPHERE_HPP #define NAZARA_SPHERE_HPP
#include <Nazara/Core/String.hpp> #include <Nazara/Core/String.hpp>
#include <Nazara/Math/Box.hpp>
#include <Nazara/Math/Vector3.hpp> #include <Nazara/Math/Vector3.hpp>
template<typename T> template<typename T>

View File

@ -4,6 +4,7 @@
#include <Nazara/Core/StringStream.hpp> #include <Nazara/Core/StringStream.hpp>
#include <Nazara/Math/Basic.hpp> #include <Nazara/Math/Basic.hpp>
#include <Nazara/Math/Box.hpp>
#include <algorithm> #include <algorithm>
#include <cstring> #include <cstring>
#include <Nazara/Core/Debug.hpp> #include <Nazara/Core/Debug.hpp>
@ -81,7 +82,6 @@ template<typename T>
NzSphere<T>& NzSphere<T>::ExtendTo(T X, T Y, T Z) NzSphere<T>& NzSphere<T>::ExtendTo(T X, T Y, T Z)
{ {
T distance = SquaredDistance(X, Y, Z); T distance = SquaredDistance(X, Y, Z);
if (distance > radius*radius) if (distance > radius*radius)
radius = std::sqrt(distance); radius = std::sqrt(distance);
@ -120,32 +120,48 @@ NzVector3<T> NzSphere<T>::GetPositiveVertex(const NzVector3<T>& normal) const
template<typename T> template<typename T>
bool NzSphere<T>::Intersect(const NzBox<T>& box) const bool NzSphere<T>::Intersect(const NzBox<T>& box) const
{ {
// Arvo's algorithm. // Arvo's algorithm.
T dmin = T(0); T squaredDistance = T(0.0);
if (x < box.x) if (x < box.x)
dmin += (x - box.x) * (x - box.x); {
else if (x > box.x + box.width) T diff = x - box.x;
dmin += (x - (box.x + box.width)) * (x - (box.x + box.width)); squaredDistance += diff*diff;
}
else if (x > box.x + box.width)
{
T diff = x - (box.x + box.width);
squaredDistance += diff*diff;
}
if (y < box.y) if (y < box.y)
dmin += (y - box.y) * (y - box.y); {
else if (x > box.x + box.width) T diff = y - box.y;
dmin += (y - (box.y + box.height)) * (y - (box.y + box.height)); squaredDistance += diff*diff;
}
else if (y > box.y + box.height)
{
T diff = y - (box.y + box.height);
squaredDistance += diff*diff;
}
if (z < box.z) if (z < box.z)
dmin += (z - box.z) * (z - box.z); {
else if (x > box.x + box.width) T diff = z - box.z;
dmin += (z - (box.z + box.depth)) * (z - (box.z + box.depth)); 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 squaredDistance <= radius * radius;
return true;
return false;
} }
template<typename T> template<typename T>
bool NzSphere<T>::Intersect(const NzSphere& sphere) const bool NzSphere<T>::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<typename T> template<typename T>

View File

@ -4,10 +4,10 @@
#include <Nazara/Core/Win32/TaskSchedulerImpl.hpp> #include <Nazara/Core/Win32/TaskSchedulerImpl.hpp>
#include <Nazara/Core/Config.hpp> #include <Nazara/Core/Config.hpp>
#include <Nazara/Core/Debug.hpp>
#include <Nazara/Core/Error.hpp> #include <Nazara/Core/Error.hpp>
#include <cstdlib> #include <cstdlib> // std::ldiv
#include <process.h> #include <process.h>
#include <Nazara/Core/Debug.hpp>
bool NzTaskSchedulerImpl::Initialize(unsigned int workerCount) bool NzTaskSchedulerImpl::Initialize(unsigned int workerCount)
{ {