Fix merge problems

Former-commit-id: 899b541adea1719f558c52abfab51458249b6aaf
This commit is contained in:
Lynix 2016-04-17 20:22:29 +02:00
parent b3455e88ca
commit 43c1243b75
7 changed files with 72 additions and 51 deletions

View File

@ -124,6 +124,7 @@ namespace Nz
*
* \param point Position of the point
*/
template<typename T>
bool Sphere<T>::Contains(const Vector3<T>& point) const
{
@ -131,7 +132,7 @@ namespace Nz
}
/*!
* \brief Returns the distance from the center of the sphere to the point
* \brief Returns the distance from the sphere to the point (is negative when the point is inside the sphere)
* \return Distance to the point
*
* \param X X position of the point
@ -148,7 +149,7 @@ namespace Nz
}
/*!
* \brief Returns the distance from the center of the sphere to the point
* \brief Returns the distance from the sphere to the point (is negative when the point is inside the sphere)
* \return Distance to the point
*
* \param point Position of the point
@ -303,7 +304,7 @@ namespace Nz
template<typename T>
bool Sphere<T>::Intersect(const Sphere& sphere) const
{
return SquaredDistance(sphere.x, sphere.y, sphere.z) - radius * radius <= sphere.radius * sphere.radius;
return SquaredDistance(sphere.x, sphere.y, sphere.z) <= sphere.radius * sphere.radius;
}
/*!
@ -392,7 +393,6 @@ namespace Nz
return *this;
}
/*
template<typename T>
Sphere<T>& Sphere<T>::Set(const Circle<T>& circle)
@ -407,11 +407,12 @@ namespace Nz
*/
/*!
* \brief Sets the components of the sphere with center and radius from another sphere
* \brief Sets the components of the sphere with center and radius from another
* \return A reference to this sphere
*
* \param sphere The other sphere
*/
template<typename T>
Sphere<T>& Sphere<T>::Set(const Sphere& sphere)
{
@ -458,7 +459,7 @@ namespace Nz
}
/*!
* \brief Returns the squared distance from the center of the sphere to the point
* \brief Returns the squared distance from the sphere to the point (can be negative if the point is inside the sphere)
* \return Squared distance to the point
*
* \param X X position of the point
@ -467,7 +468,6 @@ namespace Nz
*
* \see Distance
*/
template<typename T>
T Sphere<T>::SquaredDistance(T X, T Y, T Z) const
{
@ -475,14 +475,13 @@ namespace Nz
}
/*!
* \brief Returns the squared distance from the center of the sphere to the point
* \brief Returns the squared distance from the sphere to the point (can be negative if the point is inside the sphere)
* \return Squared distance to the point
*
* \param point Position of the point
*
* \see Distance
*/
template<typename T>
T Sphere<T>::SquaredDistance(const Vector3<T>& point) const
{

View File

@ -102,11 +102,6 @@ namespace Nz
T x, y;
};
template<typename T> std::ostream& operator<<(std::ostream& out, const Vector2<T>& vec);
template<typename T> Vector2<T> operator*(T scale, const Vector2<T>& vec);
template<typename T> Vector2<T> operator/(T scale, const Vector2<T>& vec);
typedef Vector2<double> Vector2d;
typedef Vector2<float> Vector2f;
typedef Vector2<int> Vector2i;
@ -118,6 +113,11 @@ namespace Nz
template<typename T> bool Unserialize(SerializationContext& context, Vector2<T>* vector);
}
template<typename T> std::ostream& operator<<(std::ostream& out, const Nz::Vector2<T>& vec);
template<typename T> Nz::Vector2<T> operator*(T scale, const Nz::Vector2<T>& vec);
template<typename T> Nz::Vector2<T> operator/(T scale, const Nz::Vector2<T>& vec);
#include <Nazara/Math/Vector2.inl>
#endif // NAZARA_VECTOR2_HPP

View File

@ -124,11 +124,6 @@ namespace Nz
T x, y, z;
};
template<typename T> std::ostream& operator<<(std::ostream& out, const Vector3<T>& vec);
template<typename T> Vector3<T> operator*(T scale, const Vector3<T>& vec);
template<typename T> Vector3<T> operator/(T scale, const Vector3<T>& vec);
typedef Vector3<double> Vector3d;
typedef Vector3<float> Vector3f;
typedef Vector3<int> Vector3i;
@ -140,6 +135,11 @@ namespace Nz
template<typename T> bool Unserialize(SerializationContext& context, Vector3<T>* vector);
}
template<typename T> std::ostream& operator<<(std::ostream& out, const Nz::Vector3<T>& vec);
template<typename T> Nz::Vector3<T> operator*(T scale, const Nz::Vector3<T>& vec);
template<typename T> Nz::Vector3<T> operator/(T scale, const Nz::Vector3<T>& vec);
#include <Nazara/Math/Vector3.inl>
#endif // NAZARA_VECTOR3_HPP

View File

@ -1012,10 +1012,15 @@ namespace Nz
}
/*!
* \brief Shorthand for the vector (0, -1, 0)
* \return A vector with components (0, -1, 0)
* \brief Measure the distance between two points
* Shorthand for vec1.Distance(vec2)
*
* \see MakeDown
* param vec1 the first point
* param vec2 the second point
*
* \return The distance between the two vectors
*
* \see SquaredDistance
*/
template<typename T>
T Vector3<T>::Distance(const Vector3& vec1, const Vector3& vec2)
@ -1023,12 +1028,29 @@ namespace Nz
return vec1.Distance(vec2);
}
/*!
* \brief Measure the distance between two points as a float
* Shorthand for vec1.Distancef(vec2)
*
* param vec1 the first point
* param vec2 the second point
*
* \return The distance between the two vectors as a float
*
* \see SquaredDistancef
*/
template<typename T>
float Vector3<T>::Distancef(const Vector3& vec1, const Vector3& vec2)
{
return vec1.Distancef(vec2);
}
/*!
* \brief Shorthand for the vector (0, -1, 0)
* \return A vector with components (0, -1, 0)
*
* \see MakeDown
*/
template<typename T>
Vector3<T> Vector3<T>::Down()
{
@ -1123,10 +1145,13 @@ namespace Nz
}
/*!
* \brief Shorthand for the vector (1, 1, 1)
* \return A vector with components (1, 1, 1)
* \brief Calculates the squared distance between two vectors
* \return The metric distance between two vectors with the squared euclidean norm
*
* \see MakeUnit
* \param vec1 The first point to measure the distance with
* \param vec2 The second point to measure the distance with
*
* \see Distance
*/
template<typename T>
T Vector3<T>::SquaredDistance(const Vector3& vec1, const Vector3& vec2)
@ -1134,6 +1159,12 @@ namespace Nz
return vec1.SquaredDistance(vec2);
}
/*!
* \brief Shorthand for the vector (1, 1, 1)
* \return A vector with components (1, 1, 1)
*
* \see MakeUnit
*/
template<typename T>
Vector3<T> Vector3<T>::Unit()
{
@ -1312,6 +1343,8 @@ Nz::Vector3<T> operator/(T scale, const Nz::Vector3<T>& vec)
throw std::domain_error(error);
}
#endif
return Nz::Vector3<T>(scale / vec.x, scale / vec.y, scale / vec.z);
}
#undef F

View File

@ -100,11 +100,6 @@ namespace Nz
T x, y, z, w;
};
template<typename T> std::ostream& operator<<(std::ostream& out, const Vector4<T>& vec);
template<typename T> Vector4<T> operator*(T scale, const Vector4<T>& vec);
template<typename T> Vector4<T> operator/(T scale, const Vector4<T>& vec);
typedef Vector4<double> Vector4d;
typedef Vector4<float> Vector4f;
typedef Vector4<int> Vector4i;
@ -116,6 +111,11 @@ namespace Nz
template<typename T> bool Unserialize(SerializationContext& context, Vector4<T>* vector);
}
template<typename T> std::ostream& operator<<(std::ostream& out, const Nz::Vector4<T>& vec);
template<typename T> Nz::Vector4<T> operator*(T scale, const Nz::Vector4<T>& vec);
template<typename T> Nz::Vector4<T> operator/(T scale, const Nz::Vector4<T>& vec);
#include <Nazara/Math/Vector4.inl>
#endif // NAZARA_VECTOR4_HPP

View File

@ -1116,6 +1116,8 @@ Nz::Vector4<T> operator/(T scale, const Nz::Vector4<T>& vec)
throw std::domain_error(error);
}
#endif
return Nz::Vector4<T>(scale / vec.x, scale / vec.y, scale / vec.z, scale / vec.w);
}
#undef F

View File

@ -55,8 +55,8 @@ namespace Nz
Renderer::Clear(RendererBuffer_Depth);
// Just in case the background does render depth
if (sceneData.background)
sceneData.background->Draw(sceneData.viewer);
//if (sceneData.background)
// sceneData.background->Draw(sceneData.viewer);
}
bool DepthRenderTechnique::Draw(const SceneData& sceneData) const
@ -121,9 +121,9 @@ namespace Nz
float vertices[2 * 4] = {
-0.5f, -0.5f,
0.5f, -0.5f,
0.5f, -0.5f,
-0.5f, 0.5f,
0.5f, 0.5f,
0.5f, 0.5f,
};
s_quadVertexBuffer.FillRaw(vertices, 0, sizeof(vertices));
@ -157,8 +157,6 @@ namespace Nz
void DepthRenderTechnique::DrawBasicSprites(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const
{
NazaraAssert(sceneData.viewer, "Invalid viewer");
const Shader* lastShader = nullptr;
const ShaderUniforms* shaderUniforms = nullptr;
@ -183,7 +181,7 @@ namespace Nz
if (spriteChainCount > 0)
{
// On commence par appliquer du matériau (et récupérer le shader ainsi activé)
UInt32 flags = ShaderFlags_VertexColor;
UInt32 flags = 0;
if (overlay)
flags |= ShaderFlags_TextureOverlay;
@ -203,12 +201,10 @@ namespace Nz
// Index des uniformes dans le shader
shaderUniforms = GetShaderUniforms(shader);
// Couleur ambiante de la scène
shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor);
// Overlay
shader->SendInteger(shaderUniforms->textureOverlay, overlayUnit);
// Position de la caméra
shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition());
shader->SendVector(shaderUniforms->eyePosition, Renderer::GetMatrix(MatrixType_ViewProj).GetTranslation());
lastShader = shader;
}
@ -263,8 +259,6 @@ namespace Nz
void DepthRenderTechnique::DrawBillboards(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const
{
NazaraAssert(sceneData.viewer, "Invalid viewer");
const Shader* lastShader = nullptr;
const ShaderUniforms* shaderUniforms = nullptr;
@ -293,10 +287,8 @@ namespace Nz
// Index des uniformes dans le shader
shaderUniforms = GetShaderUniforms(shader);
// Couleur ambiante de la scène
shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor);
// Position de la caméra
shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition());
shader->SendVector(shaderUniforms->eyePosition, Renderer::GetMatrix(MatrixType_ViewProj).GetTranslation());
lastShader = shader;
}
@ -342,10 +334,8 @@ namespace Nz
// Index des uniformes dans le shader
shaderUniforms = GetShaderUniforms(shader);
// Couleur ambiante de la scène
shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor);
// Position de la caméra
shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition());
shader->SendVector(shaderUniforms->eyePosition, Renderer::GetMatrix(MatrixType_ViewProj).GetTranslation());
lastShader = shader;
}
@ -408,8 +398,6 @@ namespace Nz
void DepthRenderTechnique::DrawOpaqueModels(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const
{
NazaraAssert(sceneData.viewer, "Invalid viewer");
const Shader* lastShader = nullptr;
const ShaderUniforms* shaderUniforms = nullptr;
@ -531,7 +519,6 @@ namespace Nz
uniforms.shaderUniformInvalidatedSlot.Connect(shader->OnShaderUniformInvalidated, this, &DepthRenderTechnique::OnShaderInvalidated);
uniforms.eyePosition = shader->GetUniformLocation("EyePosition");
uniforms.sceneAmbient = shader->GetUniformLocation("SceneAmbient");
uniforms.textureOverlay = shader->GetUniformLocation("TextureOverlay");
it = m_shaderUniforms.emplace(shader, std::move(uniforms)).first;