74 lines
No EOL
1.3 KiB
C++
74 lines
No EOL
1.3 KiB
C++
#pragma once
|
|
|
|
#include <vector>
|
|
#include <string>
|
|
#include <functional>
|
|
#include <map>
|
|
#include <glm/glm.hpp>
|
|
|
|
#include <mesh.hpp>
|
|
#include <material.hpp>
|
|
|
|
struct DrawCommand
|
|
{
|
|
~DrawCommand()
|
|
{
|
|
geometryData.clear();
|
|
|
|
indices.clear();
|
|
vertices.clear();
|
|
models.clear();
|
|
}
|
|
|
|
struct Data
|
|
{
|
|
int vertexCount;
|
|
int instanceCount;
|
|
int firstVertex;
|
|
int baseVertex;
|
|
int baseInstance;
|
|
};
|
|
|
|
std::vector<Data> geometryData;
|
|
|
|
std::vector<unsigned int> indices;
|
|
std::vector<Vertex> vertices;
|
|
std::vector<glm::mat4> models;
|
|
};
|
|
|
|
struct StaticGeometry
|
|
{
|
|
std::map<Material*, DrawCommand> drawCommands;
|
|
};
|
|
|
|
//reserved for future use
|
|
struct InstancedGeometry {};
|
|
|
|
struct DynamicGeometry
|
|
{
|
|
std::string name;
|
|
Mesh* mesh;
|
|
Material* material;
|
|
glm::mat4 model;
|
|
};
|
|
|
|
class DrawList
|
|
{
|
|
public:
|
|
void RebuildDynamicLists();
|
|
void RebuildStaticLists();
|
|
|
|
static void InvalidateNextFrame();
|
|
|
|
StaticGeometry GetStaticGeometry();
|
|
std::vector<InstancedGeometry> GetInstancedGeometry();
|
|
std::vector<DynamicGeometry*> GetDynamicGeometry();
|
|
|
|
static std::function<void()> onStaticGeometryUpdate;
|
|
|
|
private:
|
|
std::vector<DynamicGeometry*> m_dynamicGeometry;
|
|
StaticGeometry m_staticGeometry;
|
|
|
|
static bool m_frameInvalidated;
|
|
}; |