Improve pipeline building
This commit is contained in:
@@ -53,7 +53,7 @@ namespace Nz
|
||||
VertexDeclaration& operator=(const VertexDeclaration&) = delete;
|
||||
VertexDeclaration& operator=(VertexDeclaration&&) noexcept = default;
|
||||
|
||||
static const VertexDeclarationRef& Get(VertexLayout layout);
|
||||
static inline const VertexDeclarationRef& Get(VertexLayout layout);
|
||||
static bool IsTypeSupported(ComponentType type);
|
||||
template<typename... Args> static VertexDeclarationRef New(Args&&... args);
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace Nz
|
||||
return GetComponentByType<T>(vertexComponent, componentIndex) != nullptr;
|
||||
}
|
||||
|
||||
const VertexDeclarationRef& VertexDeclaration::Get(VertexLayout layout)
|
||||
inline const VertexDeclarationRef& VertexDeclaration::Get(VertexLayout layout)
|
||||
{
|
||||
NazaraAssert(layout <= VertexLayout_Max, "Vertex layout out of enum");
|
||||
|
||||
@@ -84,4 +84,19 @@ namespace Nz
|
||||
}
|
||||
}
|
||||
|
||||
namespace std
|
||||
{
|
||||
inline const Nz::VertexDeclaration::Component* begin(const Nz::VertexDeclaration& declaration)
|
||||
{
|
||||
assert(declaration.GetComponentCount() != 0);
|
||||
return &declaration.GetComponent(0);
|
||||
}
|
||||
|
||||
inline const Nz::VertexDeclaration::Component* end(const Nz::VertexDeclaration& declaration)
|
||||
{
|
||||
assert(declaration.GetComponentCount() != 0);
|
||||
return (&declaration.GetComponent(declaration.GetComponentCount() - 1) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/DebugOff.hpp>
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Nz
|
||||
VertexMapper(const VertexBuffer* vertexBuffer, BufferAccess access = BufferAccess_ReadOnly);
|
||||
~VertexMapper();
|
||||
|
||||
template<typename T> SparsePtr<T> GetComponentPtr(VertexComponent component);
|
||||
template<typename T> SparsePtr<T> GetComponentPtr(VertexComponent component, std::size_t componentIndex = 0);
|
||||
inline const VertexBuffer* GetVertexBuffer() const;
|
||||
inline std::size_t GetVertexCount() const;
|
||||
|
||||
|
||||
@@ -10,19 +10,13 @@
|
||||
namespace Nz
|
||||
{
|
||||
template <typename T>
|
||||
SparsePtr<T> VertexMapper::GetComponentPtr(VertexComponent component)
|
||||
SparsePtr<T> VertexMapper::GetComponentPtr(VertexComponent component, std::size_t componentIndex)
|
||||
{
|
||||
// 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 && GetComponentTypeOf<T>() == type)
|
||||
return SparsePtr<T>(static_cast<UInt8*>(m_mapper.GetPointer()) + offset, declaration->GetStride());
|
||||
if (const auto* componentData = declaration->GetComponentByType<T>(component, componentIndex))
|
||||
return SparsePtr<T>(static_cast<UInt8*>(m_mapper.GetPointer()) + componentData->offset, declaration->GetStride());
|
||||
else
|
||||
return SparsePtr<T>();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user