Merge branch 'master' of https://github.com/Gawaboumga/NazaraEngine into Gawaboumga-master
Former-commit-id: 56e40c1b251e01c435595ac73a696d2720fb1453
This commit is contained in:
commit
62daced765
|
|
@ -24,6 +24,9 @@ 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<char>(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
|
||||
|
|
@ -41,7 +44,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 capacites: " << std::endl;
|
||||
oss << "Report des capacit" << accentAigu << "s: " << std::endl;
|
||||
printCap(oss, "-64bits", NzHardwareInfo::HasCapability(nzProcessorCap_x64));
|
||||
printCap(oss, "-AVX", NzHardwareInfo::HasCapability(nzProcessorCap_AVX));
|
||||
printCap(oss, "-FMA3", NzHardwareInfo::HasCapability(nzProcessorCap_FMA3));
|
||||
|
|
@ -78,7 +81,7 @@ int main()
|
|||
oss << std::endl;
|
||||
|
||||
// Ainsi qu'un report des capacités de la carte graphique (avec le driver actuel)
|
||||
oss << "Report des capacites: " << std::endl;
|
||||
oss << "Report des capacit" << accentAigu << "s: " << std::endl;
|
||||
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));
|
||||
|
|
@ -105,8 +108,7 @@ int main()
|
|||
reportFile.Write(oss.str()); // Conversion implicite en NzString
|
||||
reportFile.Close();
|
||||
|
||||
char accent = (char) 130; // C'est crade, mais ça marche chez 95% des Windowsiens
|
||||
std::cout << "Un fichier (RapportHardwareInfo.txt) contenant le rapport a " << accent << 't' << accent << " cr" << accent << accent << std::endl;
|
||||
std::cout << "Un fichier (RapportHardwareInfo.txt) contenant le rapport a " << accentAigu << 't' << accentAigu << " cr" << accentAigu << accentAigu << std::endl;
|
||||
}
|
||||
else
|
||||
std::cout << "Impossible de sauvegarder le rapport" << std::endl;
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ class NzBoundingVolume
|
|||
NzBoundingVolume(nzExtend Extend);
|
||||
NzBoundingVolume(T X, T Y, T Z, T Width, T Height, T Depth);
|
||||
NzBoundingVolume(const NzBox<T>& box);
|
||||
NzBoundingVolume(const NzOrientedBox<T>& orientedBox);
|
||||
NzBoundingVolume(const NzVector3<T>& vec1, const NzVector3<T>& vec2);
|
||||
template<typename U> explicit NzBoundingVolume(const NzBoundingVolume<U>& volume);
|
||||
NzBoundingVolume(const NzBoundingVolume& volume) = default;
|
||||
|
|
@ -36,6 +37,7 @@ class NzBoundingVolume
|
|||
NzBoundingVolume& Set(T X, T Y, T Z, T Width, T Height, T Depth);
|
||||
NzBoundingVolume& Set(const NzBoundingVolume<T>& volume);
|
||||
NzBoundingVolume& Set(const NzBox<T>& box);
|
||||
NzBoundingVolume& Set(const NzOrientedBox<T>& orientedBox);
|
||||
NzBoundingVolume& Set(const NzVector3<T>& vec1, const NzVector3<T>& vec2);
|
||||
template<typename U> NzBoundingVolume& Set(const NzBoundingVolume<U>& volume);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Mathematics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
|
|
@ -35,6 +35,12 @@ NzBoundingVolume<T>::NzBoundingVolume(const NzBox<T>& box)
|
|||
Set(box);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzBoundingVolume<T>::NzBoundingVolume(const NzOrientedBox<T>& orientedBox)
|
||||
{
|
||||
Set(orientedBox);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzBoundingVolume<T>::NzBoundingVolume(const NzVector3<T>& vec1, const NzVector3<T>& vec2)
|
||||
{
|
||||
|
|
@ -103,6 +109,7 @@ template<typename T>
|
|||
NzBoundingVolume<T>& NzBoundingVolume<T>::Set(const NzBoundingVolume<T>& volume)
|
||||
{
|
||||
obb.Set(volume.obb); // Seul l'OBB est importante pour la suite
|
||||
extend = volume.extend;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -116,6 +123,15 @@ NzBoundingVolume<T>& NzBoundingVolume<T>::Set(const NzBox<T>& box)
|
|||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzBoundingVolume<T>& NzBoundingVolume<T>::Set(const NzOrientedBox<T>& orientedBox)
|
||||
{
|
||||
obb.Set(orientedBox);
|
||||
extend = nzExtend_Finite;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzBoundingVolume<T>& NzBoundingVolume<T>::Set(const NzVector3<T>& vec1, const NzVector3<T>& vec2)
|
||||
{
|
||||
|
|
@ -209,17 +225,17 @@ template<typename T>
|
|||
NzBoundingVolume<T> NzBoundingVolume<T>::Lerp(const NzBoundingVolume& from, const NzBoundingVolume& to, T interpolation)
|
||||
{
|
||||
#ifdef NAZARA_DEBUG
|
||||
if (interpolation < 0.f || interpolation > 1.f)
|
||||
if (interpolation < F(0.0) || interpolation > F(1.0))
|
||||
{
|
||||
NazaraError("Interpolation must be in range [0..1] (Got " + NzString::Number(interpolation) + ')');
|
||||
return Null();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (NzNumberEquals(interpolation, 0.f))
|
||||
if (NzNumberEquals(interpolation, F(0.0)))
|
||||
return from;
|
||||
|
||||
if (NzNumberEquals(interpolation, 1.f))
|
||||
if (NzNumberEquals(interpolation, F(1.0)))
|
||||
return to;
|
||||
|
||||
switch (to.extend)
|
||||
|
|
|
|||
|
|
@ -122,32 +122,32 @@ NzVector3<T> NzBox<T>::GetCorner(nzCorner corner) const
|
|||
switch (corner)
|
||||
{
|
||||
case nzCorner_FarLeftBottom:
|
||||
return NzVector3f(x, y, z);
|
||||
return NzVector3<T>(x, y, z);
|
||||
|
||||
case nzCorner_FarLeftTop:
|
||||
return NzVector3f(x, y + height, z);
|
||||
return NzVector3<T>(x, y + height, z);
|
||||
|
||||
case nzCorner_FarRightBottom:
|
||||
return NzVector3f(x + width, y, z);
|
||||
return NzVector3<T>(x + width, y, z);
|
||||
|
||||
case nzCorner_FarRightTop:
|
||||
return NzVector3f(x + width, y + height, z);
|
||||
return NzVector3<T>(x + width, y + height, z);
|
||||
|
||||
case nzCorner_NearLeftBottom:
|
||||
return NzVector3f(x, y, z + depth);
|
||||
return NzVector3<T>(x, y, z + depth);
|
||||
|
||||
case nzCorner_NearLeftTop:
|
||||
return NzVector3f(x, y + height, z + depth);
|
||||
return NzVector3<T>(x, y + height, z + depth);
|
||||
|
||||
case nzCorner_NearRightBottom:
|
||||
return NzVector3f(x + width, y, z + depth);
|
||||
return NzVector3<T>(x + width, y, z + depth);
|
||||
|
||||
case nzCorner_NearRightTop:
|
||||
return NzVector3f(x + width, y + height, z + depth);
|
||||
return NzVector3<T>(x + width, y + height, z + depth);
|
||||
}
|
||||
|
||||
NazaraError("Corner not handled (0x" + NzString::Number(corner, 16) + ')');
|
||||
return NzVector3f();
|
||||
return NzVector3<T>();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
|
@ -465,6 +465,7 @@ NzBox<T>& NzBox<T>::operator*=(T scalar)
|
|||
width *= scalar;
|
||||
height *= scalar;
|
||||
depth *= scalar;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
|
@ -473,6 +474,7 @@ NzBox<T>& NzBox<T>::operator*=(const NzVector3<T>& vec)
|
|||
width *= vec.x;
|
||||
height *= vec.y;
|
||||
depth *= vec.z;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
|
|
|||
|
|
@ -262,10 +262,10 @@ NzFrustum<T>& NzFrustum<T>::Extract(const NzMatrix4<T>& clipMatrix)
|
|||
// Une fois les plans extraits, il faut extraire les points du frustum
|
||||
// Je me base sur cette page: http://www.gamedev.net/topic/393309-calculating-the-view-frustums-vertices/
|
||||
|
||||
NzMatrix4f invClipMatrix;
|
||||
NzMatrix4<T> invClipMatrix;
|
||||
if (clipMatrix.GetInverse(&invClipMatrix))
|
||||
{
|
||||
NzVector4f corner;
|
||||
NzVector4<T> corner;
|
||||
|
||||
// FarLeftBottom
|
||||
corner.Set(F(-1.0), F(-1.0), F(1.0));
|
||||
|
|
@ -332,7 +332,7 @@ NzFrustum<T>& NzFrustum<T>::Extract(const NzMatrix4<T>& clipMatrix)
|
|||
template<typename T>
|
||||
NzFrustum<T>& NzFrustum<T>::Extract(const NzMatrix4<T>& view, const NzMatrix4<T>& projection)
|
||||
{
|
||||
NzMatrix4f clipMatrix(view);
|
||||
NzMatrix4<T> clipMatrix(view);
|
||||
clipMatrix *= projection;
|
||||
|
||||
return Extract(clipMatrix);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Mathematics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
|
|
@ -46,7 +46,7 @@ NzMatrix4<T>::NzMatrix4(const NzMatrix4<U>& matrix)
|
|||
template<typename T>
|
||||
NzMatrix4<T>& NzMatrix4<T>::ApplyRotation(const NzQuaternion<T>& rotation)
|
||||
{
|
||||
return Concatenate(NzMatrix4f::Rotate(rotation));
|
||||
return Concatenate(NzMatrix4<T>::Rotate(rotation));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
|
@ -404,7 +404,7 @@ NzQuaternion<T> NzMatrix4<T>::GetRotation() const
|
|||
T trace = m11 + m22 + m33;
|
||||
if (trace > F(0.0))
|
||||
{
|
||||
float s = F(0.5)/std::sqrt(trace + F(1.0));
|
||||
T s = F(0.5)/std::sqrt(trace + F(1.0));
|
||||
quat.w = F(0.25) / s;
|
||||
quat.x = (m23 - m32) * s;
|
||||
quat.y = (m31 - m13) * s;
|
||||
|
|
@ -414,7 +414,7 @@ NzQuaternion<T> NzMatrix4<T>::GetRotation() const
|
|||
{
|
||||
if (m11 > m22 && m11 > m33)
|
||||
{
|
||||
float s = F(2.0) * std::sqrt(F(1.0) + m11 - m22 - m33);
|
||||
T s = F(2.0) * std::sqrt(F(1.0) + m11 - m22 - m33);
|
||||
|
||||
quat.w = (m23 - m32) / s;
|
||||
quat.x = F(0.25) * s;
|
||||
|
|
@ -423,7 +423,7 @@ NzQuaternion<T> NzMatrix4<T>::GetRotation() const
|
|||
}
|
||||
else if (m22 > m33)
|
||||
{
|
||||
float s = F(2.0) * std::sqrt(F(1.0) + m22 - m11 - m33);
|
||||
T s = F(2.0) * std::sqrt(F(1.0) + m22 - m11 - m33);
|
||||
|
||||
quat.w = (m31 - m13) / s;
|
||||
quat.x = (m21 + m12) / s;
|
||||
|
|
@ -432,7 +432,7 @@ NzQuaternion<T> NzMatrix4<T>::GetRotation() const
|
|||
}
|
||||
else
|
||||
{
|
||||
float s = F(2.0) * std::sqrt(F(1.0) + m33 - m11 - m22);
|
||||
T s = F(2.0) * std::sqrt(F(1.0) + m33 - m11 - m22);
|
||||
|
||||
quat.w = (m12 - m21) / s;
|
||||
quat.x = (m31 + m13) / s;
|
||||
|
|
@ -658,7 +658,7 @@ template<typename T>
|
|||
NzMatrix4<T>& NzMatrix4<T>::MakeViewMatrix(const NzVector3<T>& translation, const NzQuaternion<T>& rotation)
|
||||
{
|
||||
// Une matrice de vue doit appliquer une transformation opposée à la matrice "monde"
|
||||
NzQuaternionf invRot = rotation.GetConjugate(); // Inverse de la rotation
|
||||
NzQuaternion<T> invRot = rotation.GetConjugate(); // Inverse de la rotation
|
||||
|
||||
return MakeTransform(-(invRot*translation), invRot);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,8 @@ template<typename T>
|
|||
NzOrientedBox<T>& NzOrientedBox<T>::MakeZero()
|
||||
{
|
||||
localBox.MakeZero();
|
||||
|
||||
for (unsigned int i = 0; i <= nzCorner_Max; ++i)
|
||||
m_corners[i].Set(NzVector3<T>::Zero());
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
@ -69,6 +70,8 @@ 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);
|
||||
|
||||
for (unsigned int i = 0; i <= nzCorner_Max; ++i)
|
||||
m_corners[i].Set(localBox.GetCorner(static_cast<nzCorner>(i)));
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
@ -77,6 +80,8 @@ NzOrientedBox<T>& NzOrientedBox<T>::Set(const NzBox<T>& 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;
|
||||
}
|
||||
|
||||
|
|
@ -93,6 +98,8 @@ NzOrientedBox<T>& NzOrientedBox<T>::Set(const NzVector3<T>& vec1, const NzVector
|
|||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -127,7 +134,7 @@ template<typename T>
|
|||
void NzOrientedBox<T>::Update(const NzMatrix4<T>& transformMatrix)
|
||||
{
|
||||
for (unsigned int i = 0; i <= nzCorner_Max; ++i)
|
||||
m_corners[i] = transformMatrix.Transform(localBox.GetCorner(static_cast<nzCorner>(i)));
|
||||
m_corners[i] = transformMatrix.Transform(m_corners[i]);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
|
@ -182,6 +189,8 @@ NzOrientedBox<T> NzOrientedBox<T>::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<nzCorner>(i)));
|
||||
return box;
|
||||
}
|
||||
|
||||
|
|
@ -190,6 +199,8 @@ NzOrientedBox<T>& NzOrientedBox<T>::operator*=(T scalar)
|
|||
{
|
||||
localBox *= scalar;
|
||||
|
||||
for (unsigned int i = 0; i <= nzCorner_Max; ++i)
|
||||
m_corners[i].Set(localBox.GetCorner(static_cast<nzCorner>(i)));
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,9 +63,13 @@ class NzRect
|
|||
|
||||
NzRect operator*(T scalar) const;
|
||||
NzRect operator*(const NzVector2<T>& vec) const;
|
||||
NzRect operator/(T scalar) const;
|
||||
NzRect operator/(const NzVector2<T>& vec) const;
|
||||
|
||||
NzRect& operator*=(T scalar);
|
||||
NzRect& operator*=(const NzVector2<T>& vec);
|
||||
NzRect& operator/=(T scalar);
|
||||
NzRect& operator/=(const NzVector2<T>& vec);
|
||||
|
||||
bool operator==(const NzRect& rect) const;
|
||||
bool operator!=(const NzRect& rect) const;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Mathematics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
|
|
@ -106,7 +106,7 @@ NzRect<T>& NzRect<T>::ExtendTo(const NzRect& rect)
|
|||
template<typename T>
|
||||
NzVector2<T> NzRect<T>::GetCenter() const
|
||||
{
|
||||
return GetPosition() + F(0.5)*GetLengths();
|
||||
return GetPosition() + GetLengths() / F(2.0);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
|
@ -336,11 +336,24 @@ NzRect<T> NzRect<T>::operator*(const NzVector2<T>& vec) const
|
|||
return NzRect(x, y, width*vec.x, height*vec.y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzRect<T> NzRect<T>::operator/(T scalar) const
|
||||
{
|
||||
return NzRect(x, y, width/scalar, height/scalar);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzRect<T> NzRect<T>::operator/(const NzVector2<T>& vec) const
|
||||
{
|
||||
return NzRect(x, y, width/vec.x, height/vec.y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzRect<T>& NzRect<T>::operator*=(T scalar)
|
||||
{
|
||||
width *= scalar;
|
||||
height *= scalar;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
|
@ -348,6 +361,25 @@ NzRect<T>& NzRect<T>::operator*=(const NzVector2<T>& vec)
|
|||
{
|
||||
width *= vec.x;
|
||||
height *= vec.y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzRect<T>& NzRect<T>::operator/=(T scalar)
|
||||
{
|
||||
width /= scalar;
|
||||
height /= scalar;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzRect<T>& NzRect<T>::operator/=(const NzVector2<T>& vec)
|
||||
{
|
||||
width /= vec.x;
|
||||
height /= vec.y;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
|
|
|||
|
|
@ -8,8 +8,12 @@
|
|||
#define NAZARA_SPHERE_HPP
|
||||
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Box.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
|
||||
template<typename T>
|
||||
class NzBox;
|
||||
|
||||
template<typename T>
|
||||
class NzSphere
|
||||
{
|
||||
|
|
@ -24,7 +28,7 @@ class NzSphere
|
|||
~NzSphere() = default;
|
||||
|
||||
bool Contains(T X, T Y, T Z) const;
|
||||
//bool Contains(const NzBox<T>& box) const;
|
||||
bool Contains(const NzBox<T>& box) const;
|
||||
bool Contains(const NzVector3<T>& point) const;
|
||||
|
||||
T Distance(T X, T Y, T Z) const;
|
||||
|
|
@ -37,7 +41,7 @@ class NzSphere
|
|||
NzVector3<T> GetPosition() const;
|
||||
NzVector3<T> GetPositiveVertex(const NzVector3<T>& normal) const;
|
||||
|
||||
//bool Intersect(const NzBox<T>& box) const;
|
||||
bool Intersect(const NzBox<T>& box) const;
|
||||
bool Intersect(const NzSphere& sphere) const;
|
||||
|
||||
bool IsValid() const;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ NzSphere<T>::NzSphere(const NzVector3<T>& center, T Radius)
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
NzSphere<T>::NzSphere(const T sphere[6])
|
||||
NzSphere<T>::NzSphere(const T sphere[4])
|
||||
{
|
||||
Set(sphere);
|
||||
}
|
||||
|
|
@ -46,12 +46,18 @@ bool NzSphere<T>::Contains(T X, T Y, T Z) const
|
|||
{
|
||||
return SquaredDistance(X, Y, Z) <= radius*radius;
|
||||
}
|
||||
/*
|
||||
|
||||
template<typename T>
|
||||
bool NzSphere<T>::Contains(const NzBox<T>& box) const
|
||||
{
|
||||
if (box.GetMinimum().SquaredDistance(GetPosition()) <= radius * radius)
|
||||
{
|
||||
if (box.GetMaximum().SquaredDistance(GetPosition()) <= radius * radius)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
template<typename T>
|
||||
bool NzSphere<T>::Contains(const NzVector3<T>& point) const
|
||||
{
|
||||
|
|
@ -85,7 +91,7 @@ NzSphere<T>& NzSphere<T>::ExtendTo(T X, T Y, T Z)
|
|||
template<typename T>
|
||||
NzSphere<T>& NzSphere<T>::ExtendTo(const NzVector3<T>& point)
|
||||
{
|
||||
return ExtendTo(point);
|
||||
return ExtendTo(point.x, point.y, point.z);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
|
@ -111,18 +117,35 @@ NzVector3<T> NzSphere<T>::GetPositiveVertex(const NzVector3<T>& normal) const
|
|||
|
||||
return pos;
|
||||
}
|
||||
/*
|
||||
template<typename T>
|
||||
bool NzSphere<T>::Intersect(const NzBox<T>& 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));
|
||||
|
||||
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 (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 (dmin <= radius * radius)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
bool NzSphere<T>::Intersect(const NzSphere& sphere) const
|
||||
{
|
||||
return SquaredDistance(sphere.x, sphere.y, sphere.z) - radius*radius <= sphere.radius*sphere.radius;
|
||||
return std::abs(SquaredDistance(sphere.x, sphere.y, sphere.z) - radius*radius) <= sphere.radius*sphere.radius;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
|
@ -210,7 +233,7 @@ template<typename T>
|
|||
T NzSphere<T>::SquaredDistance(T X, T Y, T Z) const
|
||||
{
|
||||
NzVector3<T> distance(X-x, Y-y, Z-z);
|
||||
return distance.SquaredLength();
|
||||
return distance.GetSquaredLength();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ T NzVector2<T>::GetSquaredLength() const
|
|||
template<typename T>
|
||||
NzVector2<T>& NzVector2<T>::MakeUnitX()
|
||||
{
|
||||
Set(F(1.0), F(0.0));
|
||||
return Set(F(1.0), F(0.0));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
|
|
|||
|
|
@ -4,9 +4,10 @@
|
|||
|
||||
#include <Nazara/Core/Win32/TaskSchedulerImpl.hpp>
|
||||
#include <Nazara/Core/Config.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <process.h>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <cstdlib>
|
||||
#include <process.h>
|
||||
|
||||
bool NzTaskSchedulerImpl::Initialize(unsigned int workerCount)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue