Optimized VertexDeclaration::GetElement

Former-commit-id: a56498837ae2f6101e0641aab23b2d1d0f9130f3
This commit is contained in:
Lynix 2012-10-29 10:00:57 +01:00
parent 8132812c23
commit 93a1738c55
1 changed files with 24 additions and 20 deletions

View File

@ -244,7 +244,6 @@ const NzVertexElement* NzVertexDeclaration::GetElement(nzElementStream stream, n
#endif
int elementPos = m_sharedImpl->elementPos[stream][usage];
#if NAZARA_UTILITY_SAFE
if (elementPos == -1)
{
@ -253,27 +252,32 @@ const NzVertexElement* NzVertexDeclaration::GetElement(nzElementStream stream, n
}
#endif
elementPos += usageIndex;
#if NAZARA_UTILITY_SAFE
if (static_cast<unsigned int>(elementPos) >= m_sharedImpl->elements.size())
if (usageIndex == 0) // Si l'usage index vaut zéro, alors nous sommes certains d'être sur le bon élément (Majorité des cas)
return &m_sharedImpl->elements[elementPos];
else
{
NazaraError("Element not found");
return nullptr;
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;
}
#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;
}
unsigned int NzVertexDeclaration::GetElementCount() const