From fb998ddd5d1f2c31b7977108edd0335b419ec737 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Tue, 11 Jun 2024 22:11:41 +0300 Subject: [PATCH] add complete entt test function --- src/voxel_engine.cpp | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/src/voxel_engine.cpp b/src/voxel_engine.cpp index 3e36179e..02e4a06a 100644 --- a/src/voxel_engine.cpp +++ b/src/voxel_engine.cpp @@ -8,13 +8,46 @@ #include -#include // workflows test - static debug::Logger logger("main"); +#include + +struct position { + float x; + float y; +}; + +struct velocity { + float dx; + float dy; +}; + +void update(entt::registry ®istry) { + auto view = registry.view(); + + view.each([](const auto &pos, const auto &vel) { + logger.info() << pos.x << "," << pos.y << " - " << vel.dx << ", " << vel.dy; + }); +} + +int entt_test() { + entt::registry registry; + + for(auto i = 0u; i < 10u; ++i) { + const auto entity = registry.create(); + registry.emplace(entity, i * 1.f, i * 1.f); + if(i % 2 == 0) { registry.emplace(entity, i * .1f, i * .1f); } + } + + update(registry); + return EXIT_SUCCESS; +} + int main(int argc, char** argv) { debug::Logger::init("latest.log"); + return entt_test(); + EnginePaths paths; if (!parse_cmdline(argc, argv, paths)) return EXIT_SUCCESS;