Added VertexDeclaration::HasElement
Former-commit-id: 30dccfba56bba0e56c08da79c3fde3bdf94119cb
This commit is contained in:
parent
7bab3d9443
commit
10fc386865
|
|
@ -2,6 +2,8 @@
|
|||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_VERTEXDECLARATION_HPP
|
||||
#define NAZARA_VERTEXDECLARATION_HPP
|
||||
|
||||
|
|
@ -39,6 +41,9 @@ class NAZARA_API NzVertexDeclaration : public NzResource
|
|||
unsigned int GetElementCount(nzElementStream stream) const;
|
||||
unsigned int GetStride(nzElementStream stream) const;
|
||||
|
||||
bool HasElement(unsigned int i) const;
|
||||
bool HasElement(nzElementStream stream, unsigned int i) const;
|
||||
bool HasElement(nzElementStream stream, nzElementUsage usage, unsigned int usageIndex = 0) const;
|
||||
bool HasStream(nzElementStream stream) const;
|
||||
|
||||
bool IsValid() const;
|
||||
|
|
|
|||
|
|
@ -244,16 +244,34 @@ const NzVertexElement* NzVertexDeclaration::GetElement(nzElementStream stream, n
|
|||
#endif
|
||||
|
||||
int elementPos = m_sharedImpl->elementPos[stream][usage];
|
||||
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (elementPos == -1)
|
||||
{
|
||||
NazaraError("Element not found");
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
elementPos += usageIndex;
|
||||
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (static_cast<unsigned int>(elementPos) >= m_sharedImpl->elements.size())
|
||||
{
|
||||
NazaraError("Element not found");
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
NzVertexElement& element = m_sharedImpl->elements[elementPos];
|
||||
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (element.stream != stream || element.usage != usage || element.usageIndex != usageIndex)
|
||||
{
|
||||
NazaraError("Element not found");
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
return &element;
|
||||
}
|
||||
|
|
@ -318,6 +336,33 @@ unsigned int NzVertexDeclaration::GetStride(nzElementStream stream) const
|
|||
return m_sharedImpl->stride[stream];
|
||||
}
|
||||
|
||||
bool NzVertexDeclaration::HasElement(unsigned int i) const
|
||||
{
|
||||
return i < m_sharedImpl->elements.size();
|
||||
}
|
||||
|
||||
bool NzVertexDeclaration::HasElement(nzElementStream stream, unsigned int i) const
|
||||
{
|
||||
return i < GetElementCount(stream);
|
||||
}
|
||||
|
||||
bool NzVertexDeclaration::HasElement(nzElementStream stream, nzElementUsage usage, unsigned int usageIndex) const
|
||||
{
|
||||
int elementPos = m_sharedImpl->elementPos[stream][usage];
|
||||
if (elementPos == -1)
|
||||
return false;
|
||||
|
||||
elementPos += usageIndex;
|
||||
if (static_cast<unsigned int>(elementPos) >= m_sharedImpl->elements.size())
|
||||
return false;
|
||||
|
||||
NzVertexElement& element = m_sharedImpl->elements[elementPos];
|
||||
if (element.stream != stream || element.usage != usage || element.usageIndex != usageIndex)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NzVertexDeclaration::HasStream(nzElementStream stream) const
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
|
|
|
|||
Loading…
Reference in New Issue