Redesign of animation queue for unreal, add get_tangibles_near to drivenengine

This commit is contained in:
2023-07-24 17:19:25 -04:00
parent 4da86e6f89
commit 87aa47b96d
19 changed files with 1406 additions and 980 deletions

View File

@@ -224,13 +224,12 @@ public:
using NodeID = uint64_t;
using ChildBits = uint64_t;
using IdVector = util::IdVector;
// The PlaneMap that this tree is a part of.
PlaneMap *planemap_;
// The name of this plane.
eng::string plane_;
std::string plane_;
// Internal nodes in the tree just have bits indicating
// which children exist.
@@ -440,7 +439,7 @@ public:
(*os) << "| ";
print_node_id(node, os);
(*os) << " ";
util::IdVector ids;
IdVector ids;
collect_planeitem_ids(first, &ids);
std::sort(ids.begin(), ids.end());
util::print_id_vector(ids, os);
@@ -667,7 +666,7 @@ public:
}
// Construct a PlaneTree.
PlaneTree(PlaneMap *pmap, const eng::string &plane) {
PlaneTree(PlaneMap *pmap, std::string_view plane) {
planemap_ = pmap;
plane_ = plane;
total_count_ = 0;
@@ -779,30 +778,29 @@ PlaneMap::PlaneMap() : default_radius_(32768.0) {}
PlaneMap::~PlaneMap() {}
IdVector PlaneMap::scan(const PlaneScan &sc) const {
IdVector result;
void PlaneMap::scan(const PlaneScan &sc, util::IdVector *into) const {
into->clear();
int startpos = 0;
if (sc.near_ != 0) {
if (sc.include_near_) {
result.push_back(sc.near_);
into->push_back(sc.near_);
startpos = 1;
}
}
if (sc.omit_nowhere_ && (sc.plane_ == "nowhere")) {
return result;
return;
}
auto piter = planes_.find(sc.plane_);
auto piter = planes_.find(std::string_view(sc.plane_));
if (piter != planes_.end()) {
const std::unique_ptr<PlaneTree> &tree = piter->second;
tree->scan(sc, &result, nullptr);
tree->scan(sc, into, nullptr);
}
if (sc.sorted_) {
std::sort(result.begin() + startpos, result.end());
std::sort(into->begin() + startpos, into->end());
}
return result;
}
eng::string PlaneMap::tree_debug_string(const eng::string &plane) {
@@ -814,11 +812,11 @@ eng::string PlaneMap::outliers_debug_string(const eng::string &plane) {
}
eng::string PlaneMap::search_bboxes_debug_string(const PlaneScan &scan) {
return PlaneTree::get(this, scan.plane_)->search_bboxes_debug_string(scan);
return PlaneTree::get(this, eng::string(scan.plane_))->search_bboxes_debug_string(scan);
}
eng::string PlaneMap::scan_steps_debug_string(const PlaneScan &scan) {
return PlaneTree::get(this, scan.plane_)->scan_steps_debug_string(scan);
return PlaneTree::get(this, eng::string(scan.plane_))->scan_steps_debug_string(scan);
}
void PlaneMap::untrack_all() {
@@ -1161,7 +1159,7 @@ LuaDefine(unittests_planemap, "", "some unit tests") {
// The two corners are deliberately not in low-high order.
scan.clear();
scan.set_plane("p");
scan.set_bbox_given_center_radius(util::XYZ(0x23, 0x97, 0x103), 2.0f);
scan.set_center_and_radius(util::XYZ(0x23, 0x97, 0x103), 2.0f);
LuaAssertStrEq(L, pm.search_bboxes_debug_string(scan),
"|Level 8 0,0,0 - 0,0,0"
"|Level 6 8,8,8 - 8,8,8"
@@ -1181,7 +1179,7 @@ LuaDefine(unittests_planemap, "", "some unit tests") {
// sure they only include the one cell.
scan.clear();
scan.set_plane("p");
scan.set_bbox_given_center_radius(util::XYZ(0x12, 0x34, 0x45), 0.0);
scan.set_center_and_radius(util::XYZ(0x12, 0x34, 0x45), 0.0);
LuaAssertStrEq(L, pm.search_bboxes_debug_string(scan),
"|Level 8 0,0,0 - 0,0,0"
"|Level 6 8,8,8 - 8,8,8"
@@ -1207,7 +1205,7 @@ LuaDefine(unittests_planemap, "", "some unit tests") {
// from one cell to the next.
scan.clear();
scan.set_plane("p");
scan.set_bbox_given_center_radius(util::XYZ(0x12 + 0.5, 0x34, 0x45), 0.0);
scan.set_center_and_radius(util::XYZ(0x12 + 0.5, 0x34, 0x45), 0.0);
LuaAssertStrEq(L, pm.search_bboxes_debug_string(scan),
"|Level 8 0,0,0 - 0,0,0"
"|Level 6 8,8,8 - 8,8,8"
@@ -1235,7 +1233,7 @@ LuaDefine(unittests_planemap, "", "some unit tests") {
// to make sure they cover the entire PlaneTree.
scan.clear();
scan.set_plane("p");
scan.set_bbox_given_center_radius(util::XYZ(0x12, 0x34, 0x45), 100000.0);
scan.set_center_and_radius(util::XYZ(0x12, 0x34, 0x45), 100000.0);
LuaAssertStrEq(L, pm.search_bboxes_debug_string(scan),
"|Level 8 0,0,0 - 0,0,0"
"|Level 6 0,0,0 - f,f,f"
@@ -1292,7 +1290,7 @@ LuaDefine(unittests_planemap, "", "some unit tests") {
scan.clear();
scan.set_plane("p");
scan.set_shape(PlaneScan::SPHERE);
scan.set_bbox_given_center_radius(util::XYZ(0x12 + 0.1, 0x34, 0x45), 0.0);
scan.set_center_and_radius(util::XYZ(0x12 + 0.1, 0x34, 0x45), 0.0);
LuaAssertStrEq(L, pm.scan_steps_debug_string(scan),
"|L8:root"
"| L7:2,2,2"
@@ -1350,7 +1348,7 @@ LuaDefine(unittests_planemap, "", "some unit tests") {
// because the radius is nonzero.
scan.clear();
scan.set_plane("p");
scan.set_bbox_given_center_radius(util::XYZ(0x100000, 0x16, 0x23), 0.2);
scan.set_center_and_radius(util::XYZ(0x100000, 0x16, 0x23), 0.2);
LuaAssertStrEq(L, pm.search_bboxes_debug_string(scan),
"|Level 8 0,0,0 - 0,0,0"
"|Level 6 f,8,8 - f,8,8"