Merge remote-tracking branch 'origin/master' into Font-Update
Former-commit-id: c62f6317f401e200eff303fcf5b8945302fd89c6
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
///FIXME: Est-ce que SparsePtr est vraiment le meilleur nom pour cette classe ?
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
|
||||
template<typename T>
|
||||
@@ -46,6 +47,7 @@ class NzSparsePtr
|
||||
|
||||
NzSparsePtr operator+(int count) const;
|
||||
NzSparsePtr operator-(int count) const;
|
||||
std::ptrdiff_t operator-(const NzSparsePtr& ptr) const;
|
||||
|
||||
NzSparsePtr& operator+=(int count);
|
||||
NzSparsePtr& operator-=(int count);
|
||||
|
||||
@@ -133,6 +133,12 @@ NzSparsePtr<T> NzSparsePtr<T>::operator-(int count) const
|
||||
return NzSparsePtr(m_ptr - count*m_stride, m_stride);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::ptrdiff_t NzSparsePtr<T>::operator-(const NzSparsePtr& ptr) const
|
||||
{
|
||||
return (m_ptr - ptr.m_ptr)/m_stride;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzSparsePtr<T>& NzSparsePtr<T>::operator+=(int count)
|
||||
{
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <iostream>
|
||||
#include <Nazara/Core/MemoryHelper.hpp>
|
||||
#include <Nazara/Lua/Debug.hpp>
|
||||
|
||||
|
||||
@@ -247,27 +247,30 @@ bool NzBox<T>::Intersect(const NzBox& box, NzBox* intersection) const
|
||||
{
|
||||
T left = std::max(x, box.x);
|
||||
T right = std::min(x + width, box.x + box.width);
|
||||
if (left >= right)
|
||||
return false;
|
||||
|
||||
T top = std::max(y, box.y);
|
||||
T bottom = std::min(y + height, box.y + box.height);
|
||||
if (top >= bottom)
|
||||
return false;
|
||||
|
||||
T up = std::max(z, box.z);
|
||||
T down = std::min(z + depth, box.z + box.depth);
|
||||
|
||||
if (left < right && top < bottom && up < down)
|
||||
{
|
||||
if (intersection)
|
||||
{
|
||||
intersection->x = left;
|
||||
intersection->y = top;
|
||||
intersection->z = up;
|
||||
intersection->width = right - left;
|
||||
intersection->height = bottom - top;
|
||||
intersection->depth = down - up;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
if (up >= down)
|
||||
return false;
|
||||
|
||||
if (intersection)
|
||||
{
|
||||
intersection->x = left;
|
||||
intersection->y = top;
|
||||
intersection->z = up;
|
||||
intersection->width = right - left;
|
||||
intersection->height = bottom - top;
|
||||
intersection->depth = down - up;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
||||
@@ -166,24 +166,24 @@ template<typename T>
|
||||
bool NzRect<T>::Intersect(const NzRect& rect, NzRect* intersection) const
|
||||
{
|
||||
T left = std::max(x, rect.x);
|
||||
T right = std::min(x+width, rect.x+rect.width);
|
||||
T top = std::max(y, rect.y);
|
||||
T bottom = std::min(y+height, rect.y+rect.height);
|
||||
|
||||
if (left < right && top < bottom)
|
||||
{
|
||||
if (intersection)
|
||||
{
|
||||
intersection->x = left;
|
||||
intersection->y = top;
|
||||
intersection->width = right-left;
|
||||
intersection->height = bottom-top;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
T right = std::min(x + width, rect.x + rect.width);
|
||||
if (left >= right)
|
||||
return false;
|
||||
|
||||
T top = std::max(y, rect.y);
|
||||
T bottom = std::min(y + height, rect.y + rect.height);
|
||||
if (top >= bottom)
|
||||
return false;
|
||||
|
||||
if (intersection)
|
||||
{
|
||||
intersection->x = left;
|
||||
intersection->y = top;
|
||||
intersection->width = right - left;
|
||||
intersection->height = bottom - top;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
||||
Reference in New Issue
Block a user