Refactor Mesh serialization and model system.

This commit is contained in:
antopilo
2022-06-28 19:56:16 -04:00
parent 6b827e9db7
commit 407ff89df7
21 changed files with 612 additions and 287 deletions

View File

@@ -23,6 +23,7 @@ extern "C" {
#include "src/Resource/FGD/FGDClass.h"
#include "src/Scene/Components/WrenScriptComponent.h"
#include "src/Scene/Components/PrefabComponent.h"
#include "src/Scene/Components/MeshComponent.h"
#include <vector>
#include <map>
@@ -498,6 +499,7 @@ namespace Nuake {
TransformComponent& transformComponent = brushEntity.GetComponent<TransformComponent>();
BSPBrushComponent& bsp = brushEntity.AddComponent<BSPBrushComponent>();
bsp.IsSolid = true;
bsp.IsTransparent = false;
bsp.IsFunc = false;
@@ -580,6 +582,8 @@ namespace Nuake {
}
}
Ref<Model> model = CreateRef<Model>();
// Batching process
for (auto& mat : m_StaticWorld)
{
@@ -601,8 +605,12 @@ namespace Nuake {
mesh->AddSurface(batchedVertices, batchedIndices);
mesh->SetMaterial(mat.first);
bsp.Meshes.push_back(mesh);
model->AddMesh(mesh);
//bsp.Meshes.push_back(mesh);
}
MeshComponent& modelComponent = brushEntity.AddComponent<MeshComponent>();
modelComponent.ModelResource = model;
}
isEntity = false;