Former-commit-id: 834097e149f393c278e47ff31c8c4d12b0628d2b [formerly 5eb47a1c307a874555e07106b0d484ecc0958345] [formerly fab49feb40dbc3bfdc959659ff74a6d3a2b59606 [formerly a2be53055f8fb8123035e145ea2edb0043d780e2]] Former-commit-id: d44f84cccad74434dc02a97a2a9b7a72dca49f5c [formerly d21b193e02096275d145af82ca4468f67ce1f74c] Former-commit-id: 618d73318ca6c9ad86b091312858b38024b3a5e0
36 lines
1.0 KiB
C++
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>
|