diff --git a/core/include/cubos/core/ecs/table/sparse_relation/registry.hpp b/core/include/cubos/core/ecs/table/sparse_relation/registry.hpp index 6e1511b85..cbf1c94e8 100644 --- a/core/include/cubos/core/ecs/table/sparse_relation/registry.hpp +++ b/core/include/cubos/core/ecs/table/sparse_relation/registry.hpp @@ -23,7 +23,34 @@ namespace cubos::core::ecs SparseRelationTableRegistry(); /// @brief Stores the ids of tables of a given type. - class TypeIndex; + class TypeIndex + { + public: + /// @brief Inserts a new table identifier into the index. + /// @param id Table identifier. + void insert(SparseRelationTableId id); + + /// @brief Returns a reference to a map which maps archetypes to the tables where it is the 'from' + /// archetype. + /// @return Map from archetypes to vectors of table identifiers. + const auto& from() const + { + return mSparseRelationTableIdsByFrom; + } + + /// @brief Returns a reference to a map which maps archetypes to the tables where it is the 'to' archetype. + /// @return Map from archetypes to vectors of table identifiers. + const auto& to() const + { + return mSparseRelationTableIdsByTo; + } + + private: + std::unordered_map, ArchetypeIdHash> + mSparseRelationTableIdsByFrom; + std::unordered_map, ArchetypeIdHash> + mSparseRelationTableIdsByTo; + }; /// @brief Checks if there's a table with the given identifier. /// @param id Identifier. @@ -104,32 +131,4 @@ namespace cubos::core::ecs std::vector mIds; TypeIndex* mEmptyTypeIndex; ///< Used as a placeholder when a type hasn't been registered yet. }; - - class SparseRelationTableRegistry::TypeIndex - { - public: - /// @brief Inserts a new table identifier into the index. - /// @param id Table identifier. - void insert(SparseRelationTableId id); - - /// @brief Returns a reference to a map which maps archetypes to the tables where it is the 'from' archetype. - /// @return Map from archetypes to vectors of table identifiers. - const auto& from() const - { - return mSparseRelationTableIdsByFrom; - } - - /// @brief Returns a reference to a map which maps archetypes to the tables where it is the 'to' archetype. - /// @return Map from archetypes to vectors of table identifiers. - const auto& to() const - { - return mSparseRelationTableIdsByTo; - } - - private: - std::unordered_map, ArchetypeIdHash> - mSparseRelationTableIdsByFrom; - std::unordered_map, ArchetypeIdHash> - mSparseRelationTableIdsByTo; - }; } // namespace cubos::core::ecs diff --git a/engine/src/cubos/engine/transform/position.cpp b/engine/src/cubos/engine/transform/position.cpp index dc5e64b9c..ae1458a85 100644 --- a/engine/src/cubos/engine/transform/position.cpp +++ b/engine/src/cubos/engine/transform/position.cpp @@ -5,7 +5,5 @@ CUBOS_REFLECT_IMPL(cubos::engine::Position) { - return core::ecs::TypeBuilder("cubos::engine::Position") - .withField("vec", &Position::vec) - .build(); + return core::ecs::TypeBuilder("cubos::engine::Position").withField("vec", &Position::vec).build(); } diff --git a/engine/src/cubos/engine/transform/rotation.cpp b/engine/src/cubos/engine/transform/rotation.cpp index 31daabca3..8dd1b62c8 100644 --- a/engine/src/cubos/engine/transform/rotation.cpp +++ b/engine/src/cubos/engine/transform/rotation.cpp @@ -5,7 +5,5 @@ CUBOS_REFLECT_IMPL(cubos::engine::Rotation) { - return core::ecs::TypeBuilder("cubos::engine::Rotation") - .withField("quat", &Rotation::quat) - .build(); + return core::ecs::TypeBuilder("cubos::engine::Rotation").withField("quat", &Rotation::quat).build(); }