Updated test

This commit is contained in:
2024-11-25 16:20:48 +03:00
parent 40183a44a7
commit c0248e1b11
11 changed files with 249 additions and 1203 deletions

View File

@@ -78,7 +78,6 @@ void region_tree::dump(flecs::entity grid_floor_e) const
void region_tree::grow()
{
#ifndef TESTS
List<struct region_tree *> grow_list;
List<struct region_tree *> queue;
List<struct region_tree *>::Element *e, *e1;
@@ -296,12 +295,10 @@ void region_tree::grow()
break;
}
#endif
#endif
}
void region_tree::place(flecs::entity grid_floor_e) const
{
#ifndef TESTS
int i, j;
List<const struct region_tree *> queue;
int grid_size = grid_floor_e
@@ -340,12 +337,10 @@ void region_tree::place(flecs::entity grid_floor_e) const
queue.push_back(item->children[i]);
}
}
#endif
}
void region_tree::get_rects(List<RegionRect2i> *rect_list) const
{
#ifndef TESTS
List<const struct region_tree *> queue;
queue.push_back(this);
while (!queue.empty()) {
@@ -362,14 +357,12 @@ void region_tree::get_rects(List<RegionRect2i> *rect_list) const
for (i = 0; i < (int)item->children.size(); i++)
queue.push_back(item->children[i]);
}
#endif
}
bool region_tree::check_candidate(int i, const RegionRect2i &candidate) const
{
int j;
bool ok = true;
#ifndef TESTS
if (!region.rect.encloses(candidate))
return false;
for (j = 0; j < children.size(); j++) {
@@ -392,14 +385,12 @@ bool region_tree::check_candidate(int i, const RegionRect2i &candidate) const
break;
}
}
#endif
return ok;
}
bool region_tree::check_candidate(const RegionRect2i &candidate) const
{
bool ok = true;
#ifndef TESTS
if (parent && !parent->region.rect.encloses(candidate))
return false;
if (candidate.intersects(region.rect))
@@ -410,7 +401,6 @@ bool region_tree::check_candidate(const RegionRect2i &candidate) const
ok = false;
if (region.rect.intersects(candidate))
ok = false;
#endif
return ok;
}
@@ -421,7 +411,6 @@ flecs::entity region_tree::update_cell(flecs::entity grid_floor_e,
flecs::entity region_e = grid_floor_e.world().entity(region_et);
flecs::entity parent_e = grid_floor_e.world().entity(parent_et);
flecs::log::dbg("create_cell: %s %d", region_e.path().c_str(), id);
#ifndef TESTS
String pname("cell_" + itos(id));
flecs::entity cell_e = grid_floor_e.lookup(pname.ascii().ptr());
if (!cell_e.is_valid()) {
@@ -459,19 +448,14 @@ flecs::entity region_tree::update_cell(flecs::entity grid_floor_e,
cell_e.add<WorldEditor::components::belongs_room>(
region_e);
}
#else
flecs::entity cell_e;
#endif
return cell_e;
}
void region_tree::update_candidate(const RegionRect2i &candidate)
{
#if 0
int orig_area = region.rect.get_area();
region.rect = candidate;
int new_area = candidate.get_area();
int avalue = MAX(0, new_area - orig_area);
region.remains_area -= avalue;
#endif
}