From de7dbadc475e5f57f21e17cd27b3d7f6785caf5a Mon Sep 17 00:00:00 2001 From: Hirek193 Date: Sun, 15 Mar 2026 00:44:52 +0100 Subject: [PATCH] Add a draft for node for Entity Component System --- simulation/simulationstateserializer.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/simulation/simulationstateserializer.cpp b/simulation/simulationstateserializer.cpp index cbd7dd53..0a694336 100644 --- a/simulation/simulationstateserializer.cpp +++ b/simulation/simulationstateserializer.cpp @@ -25,6 +25,8 @@ http://mozilla.org/MPL/2.0/. #include "rendering/lightarray.h" #include "world/TractionPower.h" #include "application/application.h" +#include "entitysystem/ecs.h" +#include "entitysystem/components/RenderComponents.h" #include "rendering/renderer.h" #include "utilities/Logs.h" @@ -426,7 +428,27 @@ state_serializer::deserialize_node( cParser &Input, scene::scratch_data &Scratch >> nodedata.range_min >> nodedata.name >> nodedata.type; - if( nodedata.name == "none" ) { nodedata.name.clear(); } + + // Add node to ComponentSystem + entt::entity CSEntity = CS.CreateObject(); + + auto nodeTransform = CS.GetComponent(CSEntity); + nodeTransform.Position = Scratchpad.location.offset.empty() ? glm::dvec3(0.0) : Scratchpad.location.offset.top(); + nodeTransform.Rotation = Scratchpad.location.rotation; + //nodeTransform.Scale = Scratchpad.location.scale; + + auto lodController = CS.AddComponent(CSEntity); + lodController.RangeMax = nodedata.range_max; + lodController.RangeMin = nodedata.range_min; + + if( nodedata.name == "none" ) + { + nodedata.name.clear(); + } + else + { + CS.GetComponent(CSEntity).Name = nodedata.name; + } // type-based deserialization. not elegant but it'll do if( nodedata.type == "dynamic" ) {