WIP (VertexDeclaration)

This commit is contained in:
Lynix
2020-03-03 01:04:24 +01:00
parent 287be5d9b6
commit d5c75926c6
12 changed files with 304 additions and 255 deletions

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2017 Jérôme Leclercq
// Copyright (C) 2017 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
@@ -11,7 +11,7 @@
#include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp>
#include <Nazara/Core/Signal.hpp>
#include <Nazara/Core/SparsePtr.hpp>
#include <Nazara/Utility/Config.hpp>
#include <Nazara/Utility/Enums.hpp>
#include <array>
@@ -30,52 +30,57 @@ namespace Nz
friend class Utility;
public:
VertexDeclaration();
VertexDeclaration(const VertexDeclaration& declaration);
~VertexDeclaration();
struct Component;
struct ComponentEntry;
void DisableComponent(VertexComponent component);
void EnableComponent(VertexComponent component, ComponentType type, std::size_t offset);
VertexDeclaration(VertexInputRate inputRate, std::initializer_list<ComponentEntry> components);
VertexDeclaration(const VertexDeclaration&) = delete;
VertexDeclaration(VertexDeclaration&&) noexcept = default;
~VertexDeclaration() = default;
void GetComponent(VertexComponent component, bool* enabled, ComponentType* type, std::size_t* offset) const;
bool HasComponent(VertexComponent component) const;
template<typename T> bool HasComponentOfType(VertexComponent component) const;
std::size_t GetStride() const;
inline const Component* FindComponent(VertexComponent vertexComponent, std::size_t componentIndex) const;
void SetStride(std::size_t stride);
template<typename T> const Component* GetComponentByType(VertexComponent vertexComponent, std::size_t componentIndex = 0) const;
VertexDeclaration& operator=(const VertexDeclaration& declaration);
inline const Component& GetComponent(std::size_t componentIndex) const;
inline std::size_t GetComponentCount() const;
inline VertexInputRate GetInputRate() const;
inline std::size_t GetStride() const;
static VertexDeclaration* Get(VertexLayout layout);
inline bool HasComponent(VertexComponent component, std::size_t componentIndex = 0) const;
template<typename T> bool HasComponentOfType(VertexComponent vertexComponent, std::size_t componentIndex = 0) const;
VertexDeclaration& operator=(const VertexDeclaration&) = delete;
VertexDeclaration& operator=(VertexDeclaration&&) noexcept = default;
static const VertexDeclarationRef& Get(VertexLayout layout);
static bool IsTypeSupported(ComponentType type);
template<typename... Args> static VertexDeclarationRef New(Args&&... args);
// Signals:
NazaraSignal(OnVertexDeclarationRelease, const VertexDeclaration* /*vertexDeclaration*/);
struct Component
{
ComponentType type;
VertexComponent component;
std::size_t componentIndex;
std::size_t offset;
};
struct ComponentEntry
{
VertexComponent component;
ComponentType type;
std::size_t componentIndex;
};
private:
static bool Initialize();
static void Uninitialize();
struct Component
{
ComponentType type; // Le type de donnée
bool enabled = false; // Ce composant est-il activé ?/
std::size_t offset; // La position, en octets, de la première donnée
/*
** -Lynix:
** Il serait aussi possible de préciser le stride de façon indépendante, ce que je ne permets pas
** pour décomplexifier l'interface en enlevant quelque chose que je juge inutile.
** Si vous pensez que ça peut être utile, n'hésitez pas à me le faire savoir !
** PS: Même cas pour le diviseur (instancing)
*/
};
std::array<Component, VertexComponent_Max + 1> m_components;
std::vector<Component> m_components;
std::size_t m_stride;
VertexInputRate m_inputRate;
static std::array<VertexDeclaration, VertexLayout_Max + 1> s_declarations;
static std::array<VertexDeclarationRef, VertexLayout_Max + 1> s_declarations;
static VertexDeclarationLibrary::LibraryMap s_library;
};
}