Files
NazaraEngine/include/Nazara/Utility/VertexMapper.inl
Lynix 68d67cc9da Utility: First code cleaning pass
Former-commit-id: a73d38ce2db2e780ad5b02cdae1c590606081650 [formerly 3d21c0fa44481bf91418a15012fa187a210fc9ad] [formerly b80263df8e91b85f3fd091724c54dec7f05bc535 [formerly 7dcaabaabf74fbdf840289bfc435fdd8e88969d7]]
Former-commit-id: a669a933edd2364d9ee487c7d1bb38e28ad87a2d [formerly b8c5c09df10ce2f831635f460393216799d44056]
Former-commit-id: 6bbd5af22e30cc7fd4b4478162ae89e69b3d274e
2016-09-04 20:39:34 +02:00

36 lines
1.0 KiB
C++

// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Utility module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Utility/VertexDeclaration.hpp>
#include <Nazara/Utility/Debug.hpp>
namespace Nz
{
template <typename T>
SparsePtr<T> VertexMapper::GetComponentPtr(VertexComponent component)
{
// On récupère la déclaration depuis le buffer
const VertexDeclaration* declaration = m_mapper.GetBuffer()->GetVertexDeclaration();
// Ensuite le composant qui nous intéresse
bool enabled;
ComponentType type;
std::size_t offset;
declaration->GetComponent(component, &enabled, &type, &offset);
if (enabled)
{
///TODO: Vérifier le rapport entre le type de l'attribut et le type template ?
return SparsePtr<T>(static_cast<UInt8*>(m_mapper.GetPointer()) + offset, declaration->GetStride());
}
else
{
NazaraError("Attribute 0x" + String::Number(component, 16) + " is not enabled");
return SparsePtr<T>();
}
}
}
#include <Nazara/Utility/DebugOff.hpp>