Made some serialization async

This commit is contained in:
Antoine Pilote
2023-08-03 18:20:03 -04:00
parent f5b000adc5
commit df24ab3259
2 changed files with 27 additions and 18 deletions

View File

@@ -10,6 +10,8 @@
#include "src/Rendering/Buffers/VertexArray.h"
#include "src/Rendering/Buffers/VertexBufferLayout.h"
#include <future>
namespace Nuake
{
Mesh::Mesh() {}
@@ -163,24 +165,26 @@ namespace Nuake
}
std::vector<Vertex> vertices;
for (auto& v : j["Vertices"])
{
Vertex vertex;
try {
DESERIALIZE_VEC2(v["UV"], vertex.uv)
std::async(std::launch::async, [&]()
{
for (auto& v : j["Vertices"])
{
Vertex vertex;
try {
DESERIALIZE_VEC2(v["UV"], vertex.uv)
}
catch (std::exception& e) {
vertex.uv = { 0.0, 0.0 };
}
DESERIALIZE_VEC3(v["Position"], vertex.position)
DESERIALIZE_VEC3(v["Normal"], vertex.normal)
DESERIALIZE_VEC3(v["Tangent"], vertex.tangent)
DESERIALIZE_VEC3(v["Bitangent"], vertex.bitangent)
vertices.push_back(vertex);
}
}
catch(std::exception& e) {
vertex.uv = { 0.0, 0.0 };
}
DESERIALIZE_VEC3(v["Position"], vertex.position)
DESERIALIZE_VEC3(v["Normal"], vertex.normal)
DESERIALIZE_VEC3(v["Tangent"], vertex.tangent)
DESERIALIZE_VEC3(v["Bitangent"], vertex.bitangent)
vertices.push_back(vertex);
}
);
m_Vertices = vertices;

View File

@@ -26,6 +26,7 @@
#include "src/Scene/Components/InterfaceComponent.h"
#include <fstream>
#include <future>
#include <streambuf>
#include <chrono>
#include "src/Core/OS.h"
@@ -379,7 +380,11 @@ namespace Nuake {
std::vector<json> entities = std::vector<json>();
for (Entity e : GetAllEntities())
entities.push_back(e.Serialize());
{
std::async(std::launch::async, [&]() {
entities.push_back(e.Serialize());
});
}
SERIALIZE_VAL_LBL("Entities", entities);
SERIALIZE_OBJECT(m_EditorCamera);