Implementing ECS SystemBase and updating slang

This commit is contained in:
Dynamitos
2022-11-15 12:19:11 +01:00
parent 05bc31a2b4
commit f635ee2100
106 changed files with 1083 additions and 1675 deletions
+31 -17
View File
@@ -1,26 +1,26 @@
#pragma once
#include <entt/entt.hpp>
#include "MinimalEngine.h"
#include "Actor/Actor.h"
#include "Graphics/GraphicsResources.h"
#include "Components/PrimitiveComponent.h"
#include "Graphics/MeshBatch.h"
namespace Seele
{
DECLARE_REF(Material)
DECLARE_REF(Entity)
struct DirectionalLight
{
Vector4 color;
Vector4 direction;
Vector4 intensity;
Math::Vector4 color;
Math::Vector4 direction;
Math::Vector4 intensity;
};
struct PointLight
{
Vector4 positionWS;
Math::Vector4 positionWS;
//Vector4 positionVS;
Vector4 colorRange;
Math::Vector4 colorRange;
};
#define MAX_DIRECTIONAL_LIGHTS 4
@@ -41,17 +41,31 @@ public:
void start();
void beginUpdate(double deltaTime);
void commitUpdate();
void addActor(PActor actor);
void addPrimitiveComponent(PPrimitiveComponent comp);
const std::vector<PPrimitiveComponent>& getPrimitives() const { return primitives; }
const std::vector<StaticMeshBatch>& getStaticMeshes() const { return staticMeshes; }
LightEnv& getLightBuffer() { return lightEnv; }
entt::entity createEntity()
{
return registry.create();
}
template<typename Component, typename... Args>
Component& attachComponent(entt::entity entity, Args... args)
{
return registry.emplace<Component>(entity, args...);
}
template<typename Component>
Component& accessComponent(entt::entity entity)
{
return registry.get<Component>(entity);
}
template<typename Component>
const Component& accessComponent(entt::entity entity) const
{
return registry.get<Component>(entity);
}
Array<StaticMeshBatch> getStaticMeshes();
LightEnv getLightBuffer() const;
entt::registry registry;
private:
std::vector<StaticMeshBatch> staticMeshes;
std::vector<PActor> rootActors;
std::vector<PPrimitiveComponent> primitives;
LightEnv lightEnv;
Gfx::PGraphics graphics;
};
DEFINE_REF(Scene)
} // namespace Seele