mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-21 20:08:40 +03:00
Serialization of bsp hulls and deserialization
This commit is contained in:
@@ -35,9 +35,18 @@ namespace Nuake {
|
||||
{
|
||||
BEGIN_SERIALIZE();
|
||||
|
||||
for (uint32_t i = 0; i < Meshes.size(); i++)
|
||||
for (uint32_t i = 0; i < Hulls.size() - 1; i++)
|
||||
{
|
||||
j["Meshes"][i] = Meshes[i]->Serialize();
|
||||
json hullPointsJson;
|
||||
|
||||
const size_t hullSize = Hulls[i].size() - 1;
|
||||
for (uint32_t j = 0; j < hullSize; j++)
|
||||
{
|
||||
hullPointsJson[j]["x"] = Hulls[i][j].x;
|
||||
hullPointsJson[j]["y"] = Hulls[i][j].y;
|
||||
hullPointsJson[j]["z"] = Hulls[i][j].z;
|
||||
}
|
||||
j["Hulls"][i] = hullPointsJson;
|
||||
}
|
||||
|
||||
j["IsSolid"] = IsSolid;
|
||||
@@ -53,6 +62,23 @@ namespace Nuake {
|
||||
IsSolid = j["IsSolid"];
|
||||
}
|
||||
|
||||
if (j.contains("Hulls"))
|
||||
{
|
||||
for (auto& h : j["Hulls"])
|
||||
{
|
||||
std::vector<Vector3> hull;
|
||||
hull.reserve(h.size());
|
||||
for (auto& point : h)
|
||||
{
|
||||
Vector3 pointPos;
|
||||
DESERIALIZE_VEC3(point, pointPos);
|
||||
hull.push_back(std::move(pointPos));
|
||||
}
|
||||
|
||||
Hulls.push_back(hull);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -83,6 +83,7 @@ namespace Nuake
|
||||
DESERIALIZE_COMPONENT(MeshColliderComponent);
|
||||
DESERIALIZE_COMPONENT(SphereColliderComponent);
|
||||
DESERIALIZE_COMPONENT(RigidBodyComponent);
|
||||
DESERIALIZE_COMPONENT(BSPBrushComponent);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user