Fixed iteration finish code
This commit is contained in:
@@ -473,22 +473,14 @@ void grow_job_queue::iterate()
|
||||
{
|
||||
assert(grid_e.is_valid());
|
||||
assert(this);
|
||||
/* once for each grid floor */
|
||||
flecs::query<growth_regions> q =
|
||||
grid_e.world().query_builder<growth_regions>().build();
|
||||
#if 0
|
||||
flecs::query<region_tree> qm =
|
||||
grid_e.world().query_builder<region_tree>().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<region_tree>();
|
||||
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<region_tree>();
|
||||
g.job_list.clear();
|
||||
flecs::query<region_tree> qm =
|
||||
grid_e.world().query_builder<region_tree>().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);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void grow_job_queue::finalize()
|
||||
{
|
||||
flecs::query<growth_regions> q =
|
||||
grid_e.world().query_builder<growth_regions>().build();
|
||||
q.each([this](flecs::entity e, growth_regions &g) {});
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
growth_module::growth_module(flecs::world &ecs)
|
||||
{
|
||||
grow_count = 0;
|
||||
ecs.module<growth_module>();
|
||||
ecs.component<growth_regions>();
|
||||
ecs.component<region_tree>();
|
||||
@@ -44,7 +45,9 @@ growth_module::growth_module(flecs::world &ecs)
|
||||
.write<growth_regions>()
|
||||
.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++;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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_);
|
||||
|
||||
Reference in New Issue
Block a user