diff --git a/src/modules/stream/ui/grow_job.cpp b/src/modules/stream/ui/grow_job.cpp index b94194b..e0904fc 100644 --- a/src/modules/stream/ui/grow_job.cpp +++ b/src/modules/stream/ui/grow_job.cpp @@ -473,22 +473,14 @@ void grow_job_queue::iterate() { assert(grid_e.is_valid()); assert(this); + /* once for each grid floor */ flecs::query q = grid_e.world().query_builder().build(); -#if 0 - flecs::query qm = - grid_e.world().query_builder().build(); -#endif q.each([this](flecs::entity e, growth_regions &g) { flecs::log::warn("pre floor: %s", e.path().c_str()); }); -#if 0 - qm.each([this](flecs::entity em, region_tree &rt) { - rt.dump(em); - assert(rt.check(em)); - }); -#endif q.each([this](flecs::entity e, growth_regions &g) { + struct region_tree *rtree = e.get_mut(); flecs::log::warn("floor: %s", e.path().c_str()); flecs::log::warn("job count: %d", g.job_list.size()); while (!g.job_list.empty()) { @@ -544,17 +536,17 @@ void grow_job_queue::iterate() flecs::log::dbg( "processed jobs (created region initial positions): %d", g.job_list.size()); + assert(rtree->check(e)); + rtree->shrink_rooms(e); + rtree->place(e); + e.modified(); g.job_list.clear(); - flecs::query qm = - grid_e.world().query_builder().build(); - qm.each([this](flecs::entity em, region_tree &rt) { - assert(rt.check(em)); - }); - qm.each([this](flecs::entity em, region_tree &rt) { - rt.shrink_rooms(em); - }); - qm.each([this](flecs::entity em, region_tree &rt) { - rt.place(em); - }); }); -} \ No newline at end of file +} + +void grow_job_queue::finalize() +{ + flecs::query q = + grid_e.world().query_builder().build(); + q.each([this](flecs::entity e, growth_regions &g) {}); +} diff --git a/src/modules/stream/ui/grow_job.h b/src/modules/stream/ui/grow_job.h index a0f3ccb..e50d0fc 100644 --- a/src/modules/stream/ui/grow_job.h +++ b/src/modules/stream/ui/grow_job.h @@ -20,6 +20,7 @@ struct grow_job_queue { const WorldEditor::components::buildings_layout_grid_size &size, const String &module_name); void iterate(); + void finalize(); void job_initial(struct grow_job *job); void job_common(struct grow_job *job); void commit_common_queue(); diff --git a/src/modules/stream/ui/growth_module.cpp b/src/modules/stream/ui/growth_module.cpp index 3ed4b97..60f47bb 100644 --- a/src/modules/stream/ui/growth_module.cpp +++ b/src/modules/stream/ui/growth_module.cpp @@ -9,6 +9,7 @@ growth_module::growth_module(flecs::world &ecs) { + grow_count = 0; ecs.module(); ecs.component(); ecs.component(); @@ -44,7 +45,9 @@ growth_module::growth_module(flecs::world &ecs) .write() .kind(GraphSolve) .run([module_name, this, GraphFilter](flecs::iter &it) { + flecs::log::dbg("RunGrow"); flecs::world &&ecs_ = it.world(); + assert(grow_count == 0); it.world().defer_suspend(); flecs::log::dbg("Assembling skeleton done..."); flecs::entity GraphSolveZones = it.world().lookup( @@ -89,6 +92,7 @@ growth_module::growth_module(flecs::world &ecs) grid_e, subregions, size, module_name); job_queue.iterate(); + job_queue.finalize(); }); commit_growth_queue(it.world()); mark_cells(it.world()); @@ -97,6 +101,7 @@ growth_module::growth_module(flecs::world &ecs) .lookup("::growth_module::GraphFilter") .disable(); it.world().defer_resume(); + grow_count++; }); } diff --git a/src/modules/stream/ui/growth_module.h b/src/modules/stream/ui/growth_module.h index 81813c2..4aba7c5 100644 --- a/src/modules/stream/ui/growth_module.h +++ b/src/modules/stream/ui/growth_module.h @@ -4,6 +4,7 @@ #include "base_data.h" struct growth_module { + int grow_count; void grow_cell(flecs::entity seed_e, int id); void commit_growth_queue(flecs::world &&world); void mark_cells(flecs::world &&ecs_);