From 4a516a4d86c989ee7a54031b26b0c4e611bceb61 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Mon, 11 Jan 2016 14:56:53 +0100 Subject: [PATCH] Added ComponentInfo::FieldsInOrder to be able to loop through component fields in a consistent order based on the component XSD definition --- include/Engine/Core/ComponentInfo.h | 1 + src/Engine/Core/EntityFilePreprocessor.cpp | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/Engine/Core/ComponentInfo.h b/include/Engine/Core/ComponentInfo.h index 909224e2..abf4ff15 100644 --- a/include/Engine/Core/ComponentInfo.h +++ b/include/Engine/Core/ComponentInfo.h @@ -21,6 +21,7 @@ struct ComponentInfo std::string Name; std::unordered_map Fields; + std::vector FieldsInOrder; Meta_t Meta; std::shared_ptr Defaults = nullptr; }; diff --git a/src/Engine/Core/EntityFilePreprocessor.cpp b/src/Engine/Core/EntityFilePreprocessor.cpp index 4fd768a1..83e2fe28 100644 --- a/src/Engine/Core/EntityFilePreprocessor.cpp +++ b/src/Engine/Core/EntityFilePreprocessor.cpp @@ -143,9 +143,11 @@ void EntityFilePreprocessor::parseComponentInfo() continue; } - compInfo.Fields[name].Type = type; - compInfo.Fields[name].Offset = fieldOffset; - compInfo.Fields[name].Stride = stride; + auto& field = compInfo.Fields[name]; + field.Type = type; + field.Offset = fieldOffset; + field.Stride = stride; + compInfo.FieldsInOrder.push_back(&field); fieldOffset += stride; }