Handling aspect
This commit is contained in:
@@ -99,6 +99,7 @@ grow_job_queue::grow_job_queue(
|
||||
grid_e.world().entity(et).path().c_str());
|
||||
}
|
||||
}
|
||||
/* Unlimited growth for squares */
|
||||
void grow_job_queue::job_initial(struct grow_job *job)
|
||||
{
|
||||
int i, j;
|
||||
@@ -110,9 +111,6 @@ void grow_job_queue::job_initial(struct grow_job *job)
|
||||
RegionRect2i clip_rect(1, 1, grid_size - 2, grid_size - 2);
|
||||
const List<Pair<flecs::entity, float> > &subregions = job->subregions;
|
||||
List<struct region> initial_regions;
|
||||
#if 0
|
||||
assert(g->regions.size() == 0);
|
||||
#endif
|
||||
if (subregions.size() == 0) {
|
||||
flecs::log::err("nothing to do");
|
||||
return;
|
||||
@@ -131,7 +129,7 @@ void grow_job_queue::job_initial(struct grow_job *job)
|
||||
assert(rtree->check(grid_floor_e));
|
||||
grid_floor_e.modified<region_tree>();
|
||||
grid_floor_e.get<region_tree>()->dump(grid_floor_e);
|
||||
grid_floor_e.get_mut<region_tree>()->grow(grid_floor_e);
|
||||
grid_floor_e.get_mut<region_tree>()->grow(grid_floor_e, true);
|
||||
grid_floor_e.modified<region_tree>();
|
||||
grid_floor_e.get<region_tree>()->dump(grid_floor_e);
|
||||
// grid_floor_e.get<region_tree>()->place(grid_floor_e);
|
||||
@@ -162,109 +160,6 @@ void grow_job_queue::job_initial(struct grow_job *job)
|
||||
e = e->next();
|
||||
}
|
||||
|
||||
#if 0
|
||||
while (fe) {
|
||||
flecs::entity ce = fe->get().first;
|
||||
float area = fe->get().second;
|
||||
flecs::log::warn("generating positions for: %s",
|
||||
ce.path().c_str());
|
||||
job->grid.filter_candidates(ce, area, clip_rect);
|
||||
fe = fe->next();
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
job->grid.place_regions(grid_floor_e);
|
||||
|
||||
flecs::log::dbg("Running grow...");
|
||||
queries.get_qr().each(
|
||||
[this](flecs::entity grid_floor_e,
|
||||
WorldEditor::components::buildings_layout_grid_floor &fl,
|
||||
growth_regions &g) {
|
||||
struct grid_misc grd;
|
||||
if (g.complete)
|
||||
return;
|
||||
grd.grow_region_rects(grid_floor_e, fl, g);
|
||||
grd.place_region_cells(grid_floor_e, fl, g);
|
||||
});
|
||||
queries.get_qr().each(
|
||||
[](flecs::entity grid_floor_e,
|
||||
WorldEditor::components::buildings_layout_grid_floor &fl,
|
||||
growth_regions &g) {
|
||||
int i;
|
||||
for (i = 0; i < (int)g.regions.size(); i++)
|
||||
g.regions.write[i].complete = true;
|
||||
g.complete = true;
|
||||
});
|
||||
grid_e.world()
|
||||
.system(grid_e.world().lookup(
|
||||
(module_name + "::GrowCommitQueue").ascii().ptr()))
|
||||
.run();
|
||||
queries.get_mark_cells().each([](flecs::entity e,
|
||||
const WorldEditor::components::
|
||||
buildings_layout_grid_cell
|
||||
&cell) {
|
||||
int grid_size =
|
||||
e.parent()
|
||||
.get<WorldEditor::components::
|
||||
buildings_layout_grid_floor>()
|
||||
->grid_size;
|
||||
int i;
|
||||
Vector2i position(cell.index % grid_size,
|
||||
cell.index / grid_size);
|
||||
Vector2 west(position.x - 1, position.y);
|
||||
Vector2 north(position.x, position.y - 1);
|
||||
Vector2 east(position.x + 1, position.y);
|
||||
Vector2 south(position.x, position.y + 1);
|
||||
int west_id = west.x + grid_size * west.y;
|
||||
int north_id = north.x + grid_size * north.y;
|
||||
int east_id = east.x + grid_size * east.y;
|
||||
int south_id = south.x + grid_size * south.y;
|
||||
std::vector<int> neighbors = { west_id, north_id, east_id,
|
||||
south_id };
|
||||
bool outside = false;
|
||||
bool border = false;
|
||||
for (i = 0; i < (int)neighbors.size(); i++) {
|
||||
int id = neighbors[i];
|
||||
print_line("id=" + itos(id));
|
||||
if (!e.parent()
|
||||
.get<WorldEditor::components::
|
||||
buildings_layout_grid_floor>()
|
||||
->cells.has(id)) {
|
||||
outside = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < (int)neighbors.size(); i++) {
|
||||
int id = neighbors[i];
|
||||
print_line("id=" + itos(id));
|
||||
String neighbor_name = "cell_" + itos(id);
|
||||
flecs::entity neighbor_e =
|
||||
e.parent().lookup(neighbor_name.ascii().ptr());
|
||||
if (!neighbor_e.is_valid())
|
||||
continue;
|
||||
const WorldEditor::components::buildings_layout_grid_cell
|
||||
*neighbor_cell = neighbor_e.get<
|
||||
WorldEditor::components::
|
||||
buildings_layout_grid_cell>();
|
||||
if (cell.type != neighbor_cell->type) {
|
||||
border = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (outside)
|
||||
e.add<WorldEditor::components::outside_wall>();
|
||||
else
|
||||
e.add<WorldEditor::components::final_cell>();
|
||||
if (border)
|
||||
e.add<WorldEditor::components::border>();
|
||||
print_line("outside: " + itos(outside));
|
||||
print_line("position: " + (position.operator String()));
|
||||
print_line("grid size: " + itos(grid_size));
|
||||
print_line("tile index: " + itos(cell.index));
|
||||
});
|
||||
flecs::log::dbg("initial: region count: %d", g->regions.size());
|
||||
assert(g->regions.size() > 0);
|
||||
#endif
|
||||
assert(rtree->check(grid_floor_e));
|
||||
}
|
||||
void grow_job_queue::job_common(struct grow_job *job)
|
||||
|
||||
Reference in New Issue
Block a user