It finally imports somewhat
This commit is contained in:
@@ -26,10 +26,10 @@ float4 fragmentMain(in FragmentParameter params) : SV_Target
|
|||||||
{
|
{
|
||||||
result += pLightEnv.directionalLights[i].illuminate(lightingParams, brdf);
|
result += pLightEnv.directionalLights[i].illuminate(lightingParams, brdf);
|
||||||
}
|
}
|
||||||
for(uint i = 0; i < pLightEnv.numPointLights; ++i)
|
for(uint i = 0; i < lightCount; ++i)
|
||||||
{
|
{
|
||||||
//uint lightIndex = pLightCullingData.lightIndexList[startOffset + i];
|
uint lightIndex = pLightCullingData.lightIndexList[startOffset + i];
|
||||||
result += pLightEnv.pointLights[i].illuminate(lightingParams, brdf);
|
result += pLightEnv.pointLights[lightIndex].illuminate(lightingParams, brdf);
|
||||||
}
|
}
|
||||||
return float4(result, 1.0f);
|
return float4(result, 1.0f);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ struct BlinnPhong : IBRDF
|
|||||||
float3 baseColor;
|
float3 baseColor;
|
||||||
float metallic;
|
float metallic;
|
||||||
float3 normal;
|
float3 normal;
|
||||||
float3 specular;
|
|
||||||
float roughness;
|
float roughness;
|
||||||
float sheen;
|
float sheen;
|
||||||
|
|
||||||
@@ -18,7 +17,6 @@ struct BlinnPhong : IBRDF
|
|||||||
{
|
{
|
||||||
metallic = 0;
|
metallic = 0;
|
||||||
normal = float3(0, 0, 1);
|
normal = float3(0, 0, 1);
|
||||||
specular = 0.5;
|
|
||||||
roughness = 0.5;
|
roughness = 0.5;
|
||||||
sheen = 1;
|
sheen = 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
import Common;
|
import Common;
|
||||||
|
|
||||||
#define MAX_NUM_TEXCOORDS 8
|
|
||||||
|
|
||||||
struct MaterialParameter
|
struct MaterialParameter
|
||||||
{
|
{
|
||||||
float3 position_WS;
|
float3 position_WS;
|
||||||
float2 texCoords[MAX_NUM_TEXCOORDS];
|
float2 texCoords[1];
|
||||||
float3 vertexColor;
|
float3 vertexColor;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -27,16 +25,13 @@ struct FragmentParameter
|
|||||||
float3 biTangent_WS : TANGENT1;
|
float3 biTangent_WS : TANGENT1;
|
||||||
float3 position_WS : POSITION2;
|
float3 position_WS : POSITION2;
|
||||||
float3 vertexColor : COLOR0;
|
float3 vertexColor : COLOR0;
|
||||||
float2 texCoords[MAX_NUM_TEXCOORDS] : TEXCOORD0;
|
float2 texCoords : TEXCOORD0;
|
||||||
MaterialParameter getMaterialParameter()
|
MaterialParameter getMaterialParameter()
|
||||||
{
|
{
|
||||||
MaterialParameter result;
|
MaterialParameter result;
|
||||||
result.position_WS = position_WS;
|
result.position_WS = position_WS;
|
||||||
result.vertexColor = vertexColor;
|
result.vertexColor = vertexColor;
|
||||||
for(int i = 0; i < MAX_NUM_TEXCOORDS; ++i)
|
result.texCoords[0] = texCoords;
|
||||||
{
|
|
||||||
result.texCoords[i] = texCoords[i];
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
LightingParameter getLightingParameter()
|
LightingParameter getLightingParameter()
|
||||||
@@ -57,7 +52,7 @@ struct VertexAttributes
|
|||||||
float3 tangent_MS;
|
float3 tangent_MS;
|
||||||
float3 biTangent_MS;
|
float3 biTangent_MS;
|
||||||
float3 vertexColor;
|
float3 vertexColor;
|
||||||
float2 texCoords[MAX_NUM_TEXCOORDS];
|
float2 texCoords;
|
||||||
FragmentParameter getParameter(float4x4 transformMatrix)
|
FragmentParameter getParameter(float4x4 transformMatrix)
|
||||||
{
|
{
|
||||||
float4 modelPos = float4(position_MS, 1);
|
float4 modelPos = float4(position_MS, 1);
|
||||||
@@ -75,10 +70,7 @@ struct VertexAttributes
|
|||||||
result.position_WS = worldPos.xyz;
|
result.position_WS = worldPos.xyz;
|
||||||
result.position_CS = clipPos;
|
result.position_CS = clipPos;
|
||||||
result.vertexColor = vertexColor;
|
result.vertexColor = vertexColor;
|
||||||
for(int i = 0; i < MAX_NUM_TEXCOORDS; ++i)
|
result.texCoords = texCoords;
|
||||||
{
|
|
||||||
result.texCoords[i] = texCoords[i];
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ struct StaticMeshVertexData : IVertexData
|
|||||||
attributes.normal_MS = float3(normals[3 * index + 0], normals[3 * index + 1], normals[3 * index + 2]);
|
attributes.normal_MS = float3(normals[3 * index + 0], normals[3 * index + 1], normals[3 * index + 2]);
|
||||||
attributes.tangent_MS = float3(tangents[3 * index + 0], tangents[3 * index + 1], tangents[3 * index + 2]);
|
attributes.tangent_MS = float3(tangents[3 * index + 0], tangents[3 * index + 1], tangents[3 * index + 2]);
|
||||||
attributes.biTangent_MS = float3(biTangents[3 * index + 0], biTangents[3 * index + 1], biTangents[3 * index + 2]);
|
attributes.biTangent_MS = float3(biTangents[3 * index + 0], biTangents[3 * index + 1], biTangents[3 * index + 2]);
|
||||||
attributes.texCoords[0] = float2(texCoords[2 * index + 0], texCoords[2 * index + 1]);
|
attributes.texCoords = float2(texCoords[2 * index + 0], texCoords[2 * index + 1]);
|
||||||
attributes.vertexColor = float3(color[3 * index + 0], color[3 * index + 1], color[3 * index + 2]);
|
attributes.vertexColor = float3(color[3 * index + 0], color[3 * index + 1], color[3 * index + 2]);
|
||||||
return attributes;
|
return attributes;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -378,8 +378,8 @@ void MeshLoader::loadMaterials(const aiScene* scene, const Map<std::string, PTex
|
|||||||
std::string subKey = "NormalSub";
|
std::string subKey = "NormalSub";
|
||||||
expressions.add(new SubExpression());
|
expressions.add(new SubExpression());
|
||||||
expressions.back()->key = subKey;
|
expressions.back()->key = subKey;
|
||||||
expressions.back()->inputs["lhs"].source = "1";
|
expressions.back()->inputs["lhs"].source = mulKey;
|
||||||
expressions.back()->inputs["rhs"].source = mulKey;
|
expressions.back()->inputs["rhs"].source = "float3(1,1,1)";
|
||||||
|
|
||||||
outputNormal = subKey;
|
outputNormal = subKey;
|
||||||
}
|
}
|
||||||
@@ -388,7 +388,7 @@ void MeshLoader::loadMaterials(const aiScene* scene, const Map<std::string, PTex
|
|||||||
MaterialNode brdf;
|
MaterialNode brdf;
|
||||||
brdf.profile = "BlinnPhong";
|
brdf.profile = "BlinnPhong";
|
||||||
brdf.variables["baseColor"] = outputDiffuse;
|
brdf.variables["baseColor"] = outputDiffuse;
|
||||||
brdf.variables["specular"] = outputSpecular;
|
//brdf.variables["specular"] = outputSpecular;
|
||||||
if (!outputNormal.empty())
|
if (!outputNormal.empty())
|
||||||
{
|
{
|
||||||
brdf.variables["normal"] = outputNormal;
|
brdf.variables["normal"] = outputNormal;
|
||||||
@@ -491,7 +491,7 @@ void MeshLoader::loadGlobalMeshes(const aiScene* scene, const Array<PMaterialIns
|
|||||||
|
|
||||||
Array<uint32> indices(mesh->mNumFaces * 3);
|
Array<uint32> indices(mesh->mNumFaces * 3);
|
||||||
//#pragma omp parallel for
|
//#pragma omp parallel for
|
||||||
for (int32 faceIndex = 0; faceIndex < mesh->mNumFaces; ++faceIndex)
|
for (size_t faceIndex = 0; faceIndex < mesh->mNumFaces; ++faceIndex)
|
||||||
{
|
{
|
||||||
indices[faceIndex * 3 + 0] = mesh->mFaces[faceIndex].mIndices[0];
|
indices[faceIndex * 3 + 0] = mesh->mFaces[faceIndex].mIndices[0];
|
||||||
indices[faceIndex * 3 + 1] = mesh->mFaces[faceIndex].mIndices[1];
|
indices[faceIndex * 3 + 1] = mesh->mFaces[faceIndex].mIndices[1];
|
||||||
@@ -503,7 +503,7 @@ void MeshLoader::loadGlobalMeshes(const aiScene* scene, const Array<PMaterialIns
|
|||||||
Meshlet::build(positions, indices, meshlets);
|
Meshlet::build(positions, indices, meshlets);
|
||||||
vertexData->loadMesh(id, indices, meshlets);
|
vertexData->loadMesh(id, indices, meshlets);
|
||||||
|
|
||||||
collider.physicsMesh.addCollider(positions, indices, Matrix4(1.0f));
|
//collider.physicsMesh.addCollider(positions, indices, Matrix4(1.0f));
|
||||||
|
|
||||||
globalMeshes[meshIndex] = new Mesh();
|
globalMeshes[meshIndex] = new Mesh();
|
||||||
globalMeshes[meshIndex]->vertexData = vertexData;
|
globalMeshes[meshIndex]->vertexData = vertexData;
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ private:
|
|||||||
|
|
||||||
RenderGraph renderGraph;
|
RenderGraph renderGraph;
|
||||||
|
|
||||||
ThreadPool pool;
|
|
||||||
ViewportControl cameraSystem;
|
ViewportControl cameraSystem;
|
||||||
|
|
||||||
virtual void keyCallback(KeyCode code, InputAction action, KeyModifier modifier) override;
|
virtual void keyCallback(KeyCode code, InputAction action, KeyModifier modifier) override;
|
||||||
|
|||||||
@@ -632,13 +632,14 @@ private:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
allocated = calculateGrowth(newSize);
|
||||||
// The array is not big enough, so we make a new one
|
// The array is not big enough, so we make a new one
|
||||||
T *newData = allocateArray(newSize);
|
T *newData = allocateArray(allocated);
|
||||||
|
|
||||||
if constexpr (std::is_integral_v<T> || std::is_floating_point_v<T>)
|
if constexpr (std::is_integral_v<T> || std::is_floating_point_v<T>)
|
||||||
{
|
{
|
||||||
std::memcpy(newData, _data, sizeof(T) * arraySize);
|
std::memcpy(newData, _data, sizeof(T) * arraySize);
|
||||||
std::memset(&newData[arraySize], 0, sizeof(T) * (newSize - arraySize));
|
std::memset(&newData[arraySize], 0, sizeof(T) * (allocated - arraySize));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -648,14 +649,13 @@ private:
|
|||||||
newData[i] = std::forward<Type>(_data[i]);
|
newData[i] = std::forward<Type>(_data[i]);
|
||||||
}
|
}
|
||||||
// As well as default initialize the others
|
// As well as default initialize the others
|
||||||
for (size_type i = arraySize; i < newSize; ++i)
|
for (size_type i = arraySize; i < allocated; ++i)
|
||||||
{
|
{
|
||||||
std::allocator_traits<allocator_type>::construct(allocator, &newData[i], value);
|
std::allocator_traits<allocator_type>::construct(allocator, &newData[i], value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
deallocateArray(_data, allocated);
|
deallocateArray(_data, allocated);
|
||||||
arraySize = newSize;
|
arraySize = newSize;
|
||||||
allocated = newSize;
|
|
||||||
_data = newData;
|
_data = newData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "Shader.h"
|
#include "Shader.h"
|
||||||
|
#include "ThreadPool.h"
|
||||||
#include "Graphics/Initializer.h"
|
#include "Graphics/Initializer.h"
|
||||||
#include "Graphics/RenderPass/DepthPrepass.h"
|
#include "Graphics/RenderPass/DepthPrepass.h"
|
||||||
#include "Graphics/RenderPass/BasePass.h"
|
#include "Graphics/RenderPass/BasePass.h"
|
||||||
@@ -51,8 +52,16 @@ void ShaderCompiler::registerRenderPass(Gfx::PPipelineLayout layout, std::string
|
|||||||
|
|
||||||
void ShaderCompiler::compile()
|
void ShaderCompiler::compile()
|
||||||
{
|
{
|
||||||
|
List<std::function<void()>> work;
|
||||||
for (const auto& [name, pass] : passes)
|
for (const auto& [name, pass] : passes)
|
||||||
{
|
{
|
||||||
|
for (const auto& [vdName, vd] : vertexData)
|
||||||
|
{
|
||||||
|
if (pass.useMaterial)
|
||||||
|
{
|
||||||
|
for (const auto& [matName, mat] : materials)
|
||||||
|
{
|
||||||
|
work.add([=]() {
|
||||||
ShaderPermutation permutation;
|
ShaderPermutation permutation;
|
||||||
if (pass.useMeshShading)
|
if (pass.useMeshShading)
|
||||||
{
|
{
|
||||||
@@ -70,38 +79,56 @@ void ShaderCompiler::compile()
|
|||||||
{
|
{
|
||||||
permutation.setTaskFile(pass.taskFile);
|
permutation.setTaskFile(pass.taskFile);
|
||||||
}
|
}
|
||||||
for (const auto& [vdName, vd] : vertexData)
|
|
||||||
{
|
|
||||||
permutation.setVertexData(vd->getTypeName());
|
permutation.setVertexData(vd->getTypeName());
|
||||||
if (pass.useMaterial)
|
|
||||||
{
|
|
||||||
for (const auto& [matName, mat] : materials)
|
|
||||||
{
|
|
||||||
OPipelineLayout layout = graphics->createPipelineLayout(pass.baseLayout->getName(), pass.baseLayout);
|
OPipelineLayout layout = graphics->createPipelineLayout(pass.baseLayout->getName(), pass.baseLayout);
|
||||||
layout->addDescriptorLayout(vd->getVertexDataLayout());
|
layout->addDescriptorLayout(vd->getVertexDataLayout());
|
||||||
layout->addDescriptorLayout(vd->getInstanceDataLayout());
|
layout->addDescriptorLayout(vd->getInstanceDataLayout());
|
||||||
layout->addDescriptorLayout(mat->getDescriptorLayout());
|
layout->addDescriptorLayout(mat->getDescriptorLayout());
|
||||||
permutation.setMaterial(mat->getName());
|
permutation.setMaterial(mat->getName());
|
||||||
createShaders(permutation, std::move(layout));
|
createShaders(permutation, std::move(layout));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
work.add([=]() {
|
||||||
|
ShaderPermutation permutation;
|
||||||
|
if (pass.useMeshShading)
|
||||||
|
{
|
||||||
|
permutation.setMeshFile(pass.mainFile);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
permutation.setVertexFile(pass.mainFile);
|
||||||
|
}
|
||||||
|
if (pass.hasFragmentShader)
|
||||||
|
{
|
||||||
|
permutation.setFragmentFile(pass.fragmentFile);
|
||||||
|
}
|
||||||
|
if (pass.hasTaskShader)
|
||||||
|
{
|
||||||
|
permutation.setTaskFile(pass.taskFile);
|
||||||
|
}
|
||||||
|
permutation.setVertexData(vd->getTypeName());
|
||||||
OPipelineLayout layout = graphics->createPipelineLayout(pass.baseLayout->getName(), pass.baseLayout);
|
OPipelineLayout layout = graphics->createPipelineLayout(pass.baseLayout->getName(), pass.baseLayout);
|
||||||
layout->addDescriptorLayout(vd->getVertexDataLayout());
|
layout->addDescriptorLayout(vd->getVertexDataLayout());
|
||||||
layout->addDescriptorLayout(vd->getInstanceDataLayout());
|
layout->addDescriptorLayout(vd->getInstanceDataLayout());
|
||||||
createShaders(permutation, std::move(layout));
|
createShaders(permutation, std::move(layout));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
getThreadPool().runAndWait(std::move(work));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderCompiler::createShaders(ShaderPermutation permutation, Gfx::OPipelineLayout layout)
|
void ShaderCompiler::createShaders(ShaderPermutation permutation, Gfx::OPipelineLayout layout)
|
||||||
{
|
{
|
||||||
std::scoped_lock lock(shadersLock);
|
|
||||||
PermutationId perm = PermutationId(permutation);
|
PermutationId perm = PermutationId(permutation);
|
||||||
|
{
|
||||||
|
std::scoped_lock lock(shadersLock);
|
||||||
if (shaders.contains(perm))
|
if (shaders.contains(perm))
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
ShaderCollection collection;
|
ShaderCollection collection;
|
||||||
collection.pipelineLayout = std::move(layout);
|
collection.pipelineLayout = std::move(layout);
|
||||||
|
|
||||||
@@ -142,5 +169,8 @@ void ShaderCompiler::createShaders(ShaderPermutation permutation, Gfx::OPipeline
|
|||||||
collection.fragmentShader = graphics->createFragmentShader(createInfo);
|
collection.fragmentShader = graphics->createFragmentShader(createInfo);
|
||||||
}
|
}
|
||||||
collection.pipelineLayout->create();
|
collection.pipelineLayout->create();
|
||||||
|
{
|
||||||
|
std::scoped_lock lock(shadersLock);
|
||||||
shaders[perm] = std::move(collection);
|
shaders[perm] = std::move(collection);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,10 +58,10 @@ struct ShaderPermutation
|
|||||||
char fragmentFile[32];
|
char fragmentFile[32];
|
||||||
char vertexDataName[32];
|
char vertexDataName[32];
|
||||||
char materialName[64];
|
char materialName[64];
|
||||||
uint8 hasFragment : 1;
|
uint8 hasFragment;
|
||||||
uint8 useMeshShading : 1;
|
uint8 useMeshShading;
|
||||||
uint8 hasTaskShader : 1;
|
uint8 hasTaskShader;
|
||||||
uint8 useMaterial : 1;
|
uint8 useMaterial;
|
||||||
//TODO: lightmapping etc
|
//TODO: lightmapping etc
|
||||||
ShaderPermutation()
|
ShaderPermutation()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -105,12 +105,12 @@ void StaticMeshVertexData::serializeMesh(MeshId id, uint64 numVertices, ArchiveB
|
|||||||
Array<Vector> tan(numVertices);
|
Array<Vector> tan(numVertices);
|
||||||
Array<Vector> bit(numVertices);
|
Array<Vector> bit(numVertices);
|
||||||
Array<Vector> col(numVertices);
|
Array<Vector> col(numVertices);
|
||||||
std::memcpy(positionData.data() + offset, pos.data(), numVertices * sizeof(Vector));
|
std::memcpy(pos.data(), positionData.data() + offset, numVertices * sizeof(Vector));
|
||||||
std::memcpy(texCoordsData.data() + offset, tex.data(), numVertices * sizeof(Vector2));
|
std::memcpy(tex.data(), texCoordsData.data() + offset, numVertices * sizeof(Vector2));
|
||||||
std::memcpy(normalData.data() + offset, nor.data(), numVertices * sizeof(Vector));
|
std::memcpy(nor.data(), normalData.data() + offset, numVertices * sizeof(Vector));
|
||||||
std::memcpy(tangentData.data() + offset, tan.data(), numVertices * sizeof(Vector));
|
std::memcpy(tan.data(), tangentData.data() + offset, numVertices * sizeof(Vector));
|
||||||
std::memcpy(biTangentData.data() + offset, bit.data(), numVertices * sizeof(Vector));
|
std::memcpy(bit.data(), biTangentData.data() + offset, numVertices * sizeof(Vector));
|
||||||
std::memcpy(colorData.data() + offset, col.data(), numVertices * sizeof(Vector));
|
std::memcpy(col.data(), colorData.data() + offset, numVertices * sizeof(Vector));
|
||||||
Serialization::save(buffer, pos);
|
Serialization::save(buffer, pos);
|
||||||
Serialization::save(buffer, tex);
|
Serialization::save(buffer, tex);
|
||||||
Serialization::save(buffer, nor);
|
Serialization::save(buffer, nor);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public:
|
|||||||
return Dependencies<>();
|
return Dependencies<>();
|
||||||
}
|
}
|
||||||
template<typename... Deps>
|
template<typename... Deps>
|
||||||
void setupView(Dependencies<Deps...>, ThreadPool& pool)
|
void setupView(Dependencies<Deps...>)
|
||||||
{
|
{
|
||||||
List<std::function<void()>> work;
|
List<std::function<void()>> work;
|
||||||
registry.view<Components..., Deps...>().each([&](Components&... comp, Deps&... deps){
|
registry.view<Components..., Deps...>().each([&](Components&... comp, Deps&... deps){
|
||||||
@@ -33,12 +33,12 @@ public:
|
|||||||
update(comp...);
|
update(comp...);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
pool.runAndWait(std::move(work));
|
getThreadPool().runAndWait(std::move(work));
|
||||||
}
|
}
|
||||||
virtual void run(ThreadPool& pool, double delta) override
|
virtual void run(double delta) override
|
||||||
{
|
{
|
||||||
SystemBase::run(pool, delta);
|
SystemBase::run(delta);
|
||||||
setupView((getDependencies<Components>() | ...), pool);
|
setupView((getDependencies<Components>() | ...));
|
||||||
}
|
}
|
||||||
virtual void update() override {}
|
virtual void update() override {}
|
||||||
virtual void update(Components&... components) = 0;
|
virtual void update(Components&... components) = 0;
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ class Executor
|
|||||||
public:
|
public:
|
||||||
Executor();
|
Executor();
|
||||||
~Executor();
|
~Executor();
|
||||||
private:
|
|
||||||
ThreadPool pool;
|
|
||||||
};
|
};
|
||||||
} // namespace System
|
} // namespace System
|
||||||
} // namespace Seele
|
} // namespace Seele
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class SystemBase
|
|||||||
public:
|
public:
|
||||||
SystemBase(PScene scene) : registry(scene->registry), scene(scene) {}
|
SystemBase(PScene scene) : registry(scene->registry), scene(scene) {}
|
||||||
virtual ~SystemBase() {}
|
virtual ~SystemBase() {}
|
||||||
virtual void run(ThreadPool&, double delta)
|
virtual void run(double delta)
|
||||||
{
|
{
|
||||||
deltaTime = delta;
|
deltaTime = delta;
|
||||||
update();
|
update();
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ void SystemGraph::addSystem(System::OSystemBase system)
|
|||||||
systems.add(std::move(system));
|
systems.add(std::move(system));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemGraph::run(ThreadPool& threadPool, float deltaTime)
|
void SystemGraph::run(float deltaTime)
|
||||||
{
|
{
|
||||||
for(auto& system : systems) {
|
for(auto& system : systems) {
|
||||||
system->run(threadPool, deltaTime);
|
system->run(deltaTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class SystemGraph
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void addSystem(System::OSystemBase system);
|
void addSystem(System::OSystemBase system);
|
||||||
void run(ThreadPool& threadPool, float deltaTime);
|
void run(float deltaTime);
|
||||||
private:
|
private:
|
||||||
Array<System::OSystemBase> systems;
|
Array<System::OSystemBase> systems;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -61,3 +61,10 @@ void ThreadPool::work()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ThreadPool threadPool;
|
||||||
|
|
||||||
|
ThreadPool& Seele::getThreadPool()
|
||||||
|
{
|
||||||
|
return threadPool;
|
||||||
|
}
|
||||||
|
|||||||
@@ -26,4 +26,5 @@ private:
|
|||||||
Task currentTask;
|
Task currentTask;
|
||||||
bool running = true;
|
bool running = true;
|
||||||
};
|
};
|
||||||
|
ThreadPool& getThreadPool();
|
||||||
}
|
}
|
||||||
@@ -43,7 +43,7 @@ void GameView::update()
|
|||||||
{
|
{
|
||||||
vd->resetMeshData();
|
vd->resetMeshData();
|
||||||
}
|
}
|
||||||
systemGraph->run(threadPool, updateTime);
|
systemGraph->run(updateTime);
|
||||||
scene->update(updateTime);
|
scene->update(updateTime);
|
||||||
for (VertexData* vd : VertexData::getList())
|
for (VertexData* vd : VertexData::getList())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ protected:
|
|||||||
|
|
||||||
PSystemGraph systemGraph;
|
PSystemGraph systemGraph;
|
||||||
System::PKeyboardInput keyboardSystem;
|
System::PKeyboardInput keyboardSystem;
|
||||||
ThreadPool threadPool;
|
|
||||||
float updateTime = 0;
|
float updateTime = 0;
|
||||||
|
|
||||||
virtual void keyCallback(Seele::KeyCode code, Seele::InputAction action, Seele::KeyModifier modifier) override;
|
virtual void keyCallback(Seele::KeyCode code, Seele::InputAction action, Seele::KeyModifier modifier) override;
|
||||||
|
|||||||
Reference in New Issue
Block a user