mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-23 07:40:14 +00:00
Overhaul WMO collision: precompute normals, fix floor selection, optimize queries
- Precompute triangle normals in buildCollisionGrid, eliminating per-query cross+normalize in getFloorHeight, checkWallCollision, and raycastBoundingBoxes - Fix floor selection: remove redundant allowAbove (callers already elevate probeZ by stepUpBudget), preventing upper-story snap at doorway transitions - Align wall classification threshold (absNz < 0.35) with runtime skip check, eliminating ~30% wasted wall triangle fetches - Replace O(n log n) sort+unique dedup in range queries with O(n) visited bitset - Rename wallTriScratch to triScratch_, fix stale threshold comments
This commit is contained in:
parent
35384b2c52
commit
64879b8aab
2 changed files with 117 additions and 74 deletions
|
|
@ -390,13 +390,19 @@ private:
|
|||
std::vector<std::vector<uint32_t>> cellTriangles;
|
||||
|
||||
// Pre-classified triangle lists per cell (built at load time)
|
||||
std::vector<std::vector<uint32_t>> cellFloorTriangles; // abs(normal.z) >= 0.45
|
||||
std::vector<std::vector<uint32_t>> cellWallTriangles; // abs(normal.z) < 0.55
|
||||
std::vector<std::vector<uint32_t>> cellFloorTriangles; // abs(normal.z) >= 0.35
|
||||
std::vector<std::vector<uint32_t>> cellWallTriangles; // abs(normal.z) < 0.35
|
||||
|
||||
// Pre-computed per-triangle Z bounds for fast vertical reject
|
||||
struct TriBounds { float minZ; float maxZ; };
|
||||
std::vector<TriBounds> triBounds; // indexed by triStart/3
|
||||
|
||||
// Pre-computed per-triangle normals (unit length, indexed by triStart/3)
|
||||
std::vector<glm::vec3> triNormals;
|
||||
|
||||
// Scratch bitset for deduplicating triangle queries (sized to numTriangles)
|
||||
mutable std::vector<uint8_t> triVisited;
|
||||
|
||||
// Build the spatial grid from collision geometry
|
||||
void buildCollisionGrid();
|
||||
|
||||
|
|
@ -675,7 +681,7 @@ private:
|
|||
std::unordered_map<GridCell, std::vector<uint32_t>, GridCellHash> spatialGrid;
|
||||
std::unordered_map<uint32_t, size_t> instanceIndexById;
|
||||
mutable std::vector<size_t> candidateScratch;
|
||||
mutable std::vector<uint32_t> wallTriScratch; // Scratch for wall collision grid queries
|
||||
mutable std::vector<uint32_t> triScratch_; // Scratch for collision grid queries
|
||||
mutable std::unordered_set<uint32_t> candidateIdScratch;
|
||||
|
||||
// Parallel visibility culling
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue