mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 08:09:19 +02:00
Add a draft for node for Entity Component System
This commit is contained in:
@@ -25,6 +25,8 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
#include "rendering/lightarray.h"
|
#include "rendering/lightarray.h"
|
||||||
#include "world/TractionPower.h"
|
#include "world/TractionPower.h"
|
||||||
#include "application/application.h"
|
#include "application/application.h"
|
||||||
|
#include "entitysystem/ecs.h"
|
||||||
|
#include "entitysystem/components/RenderComponents.h"
|
||||||
#include "rendering/renderer.h"
|
#include "rendering/renderer.h"
|
||||||
#include "utilities/Logs.h"
|
#include "utilities/Logs.h"
|
||||||
|
|
||||||
@@ -426,7 +428,27 @@ state_serializer::deserialize_node( cParser &Input, scene::scratch_data &Scratch
|
|||||||
>> nodedata.range_min
|
>> nodedata.range_min
|
||||||
>> nodedata.name
|
>> nodedata.name
|
||||||
>> nodedata.type;
|
>> nodedata.type;
|
||||||
if( nodedata.name == "none" ) { nodedata.name.clear(); }
|
|
||||||
|
// Add node to ComponentSystem
|
||||||
|
entt::entity CSEntity = CS.CreateObject();
|
||||||
|
|
||||||
|
auto nodeTransform = CS.GetComponent<ECSComponent::Transform>(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<ECSComponent::LODController>(CSEntity);
|
||||||
|
lodController.RangeMax = nodedata.range_max;
|
||||||
|
lodController.RangeMin = nodedata.range_min;
|
||||||
|
|
||||||
|
if( nodedata.name == "none" )
|
||||||
|
{
|
||||||
|
nodedata.name.clear();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CS.GetComponent<ECSComponent::Identification>(CSEntity).Name = nodedata.name;
|
||||||
|
}
|
||||||
// type-based deserialization. not elegant but it'll do
|
// type-based deserialization. not elegant but it'll do
|
||||||
if( nodedata.type == "dynamic" ) {
|
if( nodedata.type == "dynamic" ) {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user