mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-09 20:08:57 +03:00
Made some serialization async
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user