Cleanup pass

This commit is contained in:
Lynix
2017-04-22 15:08:05 +02:00
parent ec310b9577
commit 06038a4d81
25 changed files with 124 additions and 206 deletions

View File

@@ -74,8 +74,8 @@ namespace Nz
Box& Transform(const Matrix4<T>& matrix, bool applyTranslation = true);
Box& Translate(const Vector3<T>& translation);
T& operator[](unsigned int i);
T operator[](unsigned int i) const;
T& operator[](std::size_t i);
T operator[](std::size_t i) const;
Box operator*(T scalar) const;
Box operator*(const Vector3<T>& vec) const;

View File

@@ -735,24 +735,15 @@ namespace Nz
* \brief Returns the ith element of the box
* \return A reference to the ith element of the box
*
* \remark Access to index greather than 6 is undefined behavior
* \remark Produce a NazaraError if you try to acces to index greather than 6 with NAZARA_MATH_SAFE defined
* \remark Access to index greater than 6 is undefined behavior
* \remark Produce a NazaraError if you try to access to index greater than 6 with NAZARA_MATH_SAFE defined
* \throw std::domain_error if NAZARA_MATH_SAFE is defined and one of you try to acces to index greather than 6
*/
template<typename T>
T& Box<T>::operator[](unsigned int i)
T& Box<T>::operator[](std::size_t i)
{
#if NAZARA_MATH_SAFE
if (i >= 6)
{
StringStream ss;
ss << "Index out of range: (" << i << " >= 6)";
NazaraError(ss);
throw std::domain_error(ss.ToString());
}
#endif
NazaraAssert(i < 6, "Index out of range");
return *(&x+i);
}
@@ -761,24 +752,15 @@ namespace Nz
* \brief Returns the ith element of the box
* \return A value to the ith element of the box
*
* \remark Access to index greather than 6 is undefined behavior
* \remark Produce a NazaraError if you try to acces to index greather than 6 with NAZARA_MATH_SAFE defined
* \remark Access to index greater than 6 is undefined behavior
* \remark Produce a NazaraError if you try to access to index greater than 6 with NAZARA_MATH_SAFE defined
* \throw std::domain_error if NAZARA_MATH_SAFE is defined and one of you try to acces to index greather than 6
*/
template<typename T>
T Box<T>::operator[](unsigned int i) const
T Box<T>::operator[](std::size_t i) const
{
#if NAZARA_MATH_SAFE
if (i >= 6)
{
StringStream ss;
ss << "Index out of range: (" << i << " >= 6)";
NazaraError(ss);
throw std::domain_error(ss.ToString());
}
#endif
NazaraAssert(i < 6, "Index out of range");
return *(&x+i);
}

View File

@@ -64,8 +64,8 @@ namespace Nz
Rect& Translate(const Vector2<T>& translation);
T& operator[](unsigned int i);
T operator[](unsigned int i) const;
T& operator[](std::size_t i);
T operator[](std::size_t i) const;
Rect operator*(T scalar) const;
Rect operator*(const Vector2<T>& vec) const;

View File

@@ -578,23 +578,14 @@ namespace Nz
* \return A reference to the ith element of the rectangle
*
* \remark Access to index greather than 4 is undefined behavior
* \remark Produce a NazaraError if you try to acces to index greather than 4 with NAZARA_MATH_SAFE defined
* \remark Produce a NazaraError if you try to access to index greater than 4 with NAZARA_MATH_SAFE defined
* \throw std::domain_error if NAZARA_MATH_SAFE is defined and one of you try to acces to index greather than 4
*/
template<typename T>
T& Rect<T>::operator[](unsigned int i)
T& Rect<T>::operator[](std::size_t i)
{
#if NAZARA_MATH_SAFE
if (i >= 4)
{
StringStream ss;
ss << "Index out of range: (" << i << " >= 4)";
NazaraError(ss);
throw std::domain_error(ss.ToString());
}
#endif
NazaraAssert(i < 4, "Index out of range");
return *(&x+i);
}
@@ -603,24 +594,15 @@ namespace Nz
* \brief Returns the ith element of the rectangle
* \return A value to the ith element of the rectangle
*
* \remark Access to index greather than 4 is undefined behavior
* \remark Produce a NazaraError if you try to acces to index greather than 4 with NAZARA_MATH_SAFE defined
* \remark Access to index greater than 4 is undefined behavior
* \remark Produce a NazaraError if you try to access to index greater than 4 with NAZARA_MATH_SAFE defined
* \throw std::domain_error if NAZARA_MATH_SAFE is defined and one of you try to acces to index greather than 4
*/
template<typename T>
T Rect<T>::operator[](unsigned int i) const
T Rect<T>::operator[](std::size_t i) const
{
#if NAZARA_MATH_SAFE
if (i >= 4)
{
StringStream ss;
ss << "Index out of range: (" << i << " >= 4)";
NazaraError(ss);
throw std::domain_error(ss.ToString());
}
#endif
NazaraAssert(i < 4, "Index out of range");
return *(&x+i);
}

View File

@@ -60,8 +60,8 @@ namespace Nz
String ToString() const;
T& operator[](unsigned int i);
T operator[](unsigned int i) const;
T& operator[](std::size_t i);
T operator[](std::size_t i) const;
Sphere operator*(T scalar) const;
Sphere& operator=(const Sphere& other) = default;

View File

@@ -466,24 +466,15 @@ namespace Nz
* \brief Returns the ith element of the sphere
* \return A reference to the ith element of the sphere
*
* \remark Access to index greather than 4 is undefined behavior
* \remark Produce a NazaraError if you try to acces to index greather than 4 with NAZARA_MATH_SAFE defined
* \remark Access to index greater than 4 is undefined behavior
* \remark Produce a NazaraError if you try to access to index greater than 4 with NAZARA_MATH_SAFE defined
* \throw std::domain_error if NAZARA_MATH_SAFE is defined and one of you try to acces to index greather than 4
*/
template<typename T>
T& Sphere<T>::operator[](unsigned int i)
T& Sphere<T>::operator[](std::size_t i)
{
#if NAZARA_MATH_SAFE
if (i >= 4)
{
StringStream ss;
ss << "Index out of range: (" << i << " >= 4)";
NazaraError(ss);
throw std::domain_error(ss.ToString());
}
#endif
NazaraAssert(i < 4, "Index out of range");
return *(&x+i);
}
@@ -492,24 +483,15 @@ namespace Nz
* \brief Returns the ith element of the sphere
* \return A value to the ith element of the sphere
*
* \remark Access to index greather than 4 is undefined behavior
* \remark Produce a NazaraError if you try to acces to index greather than 4 with NAZARA_MATH_SAFE defined
* \remark Access to index greater than 4 is undefined behavior
* \remark Produce a NazaraError if you try to access to index greater than 4 with NAZARA_MATH_SAFE defined
* \throw std::domain_error if NAZARA_MATH_SAFE is defined and one of you try to acces to index greather than 4
*/
template<typename T>
T Sphere<T>::operator[](unsigned int i) const
T Sphere<T>::operator[](std::size_t i) const
{
#if NAZARA_MATH_SAFE
if (i >= 4)
{
StringStream ss;
ss << "Index out of range: (" << i << " >= 4)";
NazaraError(ss);
throw std::domain_error(ss.ToString());
}
#endif
NazaraAssert(i < 4, "Index out of range");
return *(&x+i);
}

View File

@@ -26,15 +26,15 @@ namespace Nz
Reference operator*() const;
Reference operator[](unsigned int index) const;
Reference operator[](std::size_t index) const;
IndexIterator& operator=(const IndexIterator& iterator);
IndexIterator operator+(unsigned int indexCount) const;
IndexIterator operator-(unsigned int indexCount) const;
IndexIterator operator+(std::size_t indexCount) const;
IndexIterator operator-(std::size_t indexCount) const;
IndexIterator& operator+=(unsigned int indexCount);
IndexIterator& operator-=(unsigned int indexCount);
IndexIterator& operator+=(std::size_t indexCount);
IndexIterator& operator-=(std::size_t indexCount);
IndexIterator& operator++();
IndexIterator operator++(int);
@@ -50,10 +50,10 @@ namespace Nz
friend bool operator>=(const IndexIterator& lhs, const IndexIterator& rhs);
private:
IndexIterator(IndexMapper* mapper, unsigned int index);
IndexIterator(IndexMapper* mapper, std::size_t index);
IndexMapper* m_mapper;
unsigned int m_index;
std::size_t m_index;
};
class IndexIterator::Reference
@@ -70,10 +70,10 @@ namespace Nz
operator UInt32() const;
private:
Reference(IndexMapper* mapper, unsigned int index);
Reference(IndexMapper* mapper, std::size_t index);
IndexMapper* m_mapper;
unsigned int m_index;
std::size_t m_index;
};
}

View File

@@ -20,7 +20,7 @@ namespace Nz
{
}
inline IndexIterator::IndexIterator(IndexMapper* mapper, unsigned int index) :
inline IndexIterator::IndexIterator(IndexMapper* mapper, std::size_t index) :
m_mapper(mapper),
m_index(index)
{
@@ -31,7 +31,7 @@ namespace Nz
return Reference(m_mapper, m_index);
}
inline IndexIterator::Reference IndexIterator::operator[](unsigned int index) const
inline IndexIterator::Reference IndexIterator::operator[](std::size_t index) const
{
return Reference(m_mapper, m_index+index);
}
@@ -44,24 +44,24 @@ namespace Nz
return *this;
}
inline IndexIterator IndexIterator::operator+(unsigned int indexCount) const
inline IndexIterator IndexIterator::operator+(std::size_t indexCount) const
{
return IndexIterator(m_mapper, m_index + indexCount);
}
inline IndexIterator IndexIterator::operator-(unsigned int indexCount) const
inline IndexIterator IndexIterator::operator-(std::size_t indexCount) const
{
return IndexIterator(m_mapper, m_index - indexCount);
}
inline IndexIterator& IndexIterator::operator+=(unsigned int indexCount)
inline IndexIterator& IndexIterator::operator+=(std::size_t indexCount)
{
m_index += indexCount;
return *this;
}
inline IndexIterator& IndexIterator::operator-=(unsigned int indexCount)
inline IndexIterator& IndexIterator::operator-=(std::size_t indexCount)
{
m_index += indexCount;
@@ -133,7 +133,7 @@ namespace Nz
/**************************IndexIterator::Reference*************************/
inline IndexIterator::Reference::Reference(IndexMapper* mapper, unsigned int index) :
inline IndexIterator::Reference::Reference(IndexMapper* mapper, std::size_t index) :
m_mapper(mapper),
m_index(index)
{
@@ -148,7 +148,7 @@ namespace Nz
inline IndexIterator::Reference& IndexIterator::Reference::operator=(const IndexIterator::Reference& reference)
{
m_mapper->Set(m_index, reference); // Conversion implicite en UInt32
m_mapper->Set(m_index, reference); // Implicit conversion to UInt32
return *this;
}

View File

@@ -17,9 +17,6 @@ namespace Nz
class IndexIterator;
class SubMesh;
using IndexMapperGetter = UInt32 (*)(const void* buffer, unsigned int i);
using IndexMapperSetter = void (*)(void* buffer, unsigned int i, UInt32 value);
class NAZARA_UTILITY_API IndexMapper
{
public:
@@ -29,11 +26,11 @@ namespace Nz
IndexMapper(const SubMesh* subMesh, BufferAccess access = BufferAccess_ReadOnly);
~IndexMapper() = default;
UInt32 Get(unsigned int i) const;
UInt32 Get(std::size_t i) const;
const IndexBuffer* GetBuffer() const;
unsigned int GetIndexCount() const;
std::size_t GetIndexCount() const;
void Set(unsigned int i, UInt32 value);
void Set(std::size_t i, UInt32 value);
void Unmap();
@@ -45,10 +42,13 @@ namespace Nz
// Méthodes STD
private:
using Getter = UInt32(*)(const void* buffer, std::size_t i);
using Setter = void(*)(void* buffer, std::size_t i, UInt32 value);
BufferMapper<IndexBuffer> m_mapper;
IndexMapperGetter m_getter;
IndexMapperSetter m_setter;
unsigned int m_indexCount;
Getter m_getter;
Setter m_setter;
std::size_t m_indexCount;
};
}

View File

@@ -24,7 +24,7 @@ namespace Nz
bool Advance();
UInt32 operator[](unsigned int i) const;
UInt32 operator[](std::size_t i) const;
void Unmap();
@@ -32,8 +32,8 @@ namespace Nz
PrimitiveMode m_primitiveMode;
UInt32 m_triangleIndices[3];
IndexMapper m_indexMapper;
unsigned int m_currentIndex;
unsigned int m_indexCount;
std::size_t m_currentIndex;
std::size_t m_indexCount;
};
}