Owner-authorized source migration: 31 helper-only translation units were merged into their callers or existing inline headers; both build manifests updated. Includes the preserved source payload, Lua configuration matching wowdecomp, and exact malloca expansion without diagnostic pragmas. 449 native units compiled locally and 449 staged units compiled by the pinned server toolchain. No previously byte-matched function regressed. Compiler mapping diagnostics remain recorded as needs_cleanup, not accepted or peer-confirmed. Existing independent review records are preserved. README.md is intentionally unchanged.
47 lines
1.4 KiB
C++
47 lines
1.4 KiB
C++
#include "Contents/World/WorldRayQuery.h"
|
|
#include "Contents/World/WorldSpatialTree.h"
|
|
#include "Contents/World/WorldTerrainPicking.h"
|
|
#include "Render/Projection/RenderProjection.h"
|
|
#include "Resource/World/TerrainResource.h"
|
|
|
|
// INLINED
|
|
bool PickTerrainRay(const float* ray, WorldSpatialTree& root, int& column, int& row) {
|
|
WorldRayQuery query;
|
|
query.Collect(ray, &root);
|
|
float nearest = 999999.0f;
|
|
|
|
for (WorldSpatialTree* node : query.nodes) {
|
|
C3dAttr* terrain = node->terrain;
|
|
int candidateRow = node->terrainCells[1];
|
|
|
|
while (candidateRow <= node->terrainCells[3]) {
|
|
int candidateColumn = node->terrainCells[0];
|
|
|
|
while (candidateColumn <= node->terrainCells[2]) {
|
|
const float distance = terrain->Grid().RayDistance(ray, candidateColumn, candidateRow);
|
|
|
|
if (nearest > distance) {
|
|
nearest = distance;
|
|
column = candidateColumn;
|
|
row = candidateRow;
|
|
}
|
|
|
|
candidateColumn = candidateColumn + 1;
|
|
}
|
|
|
|
candidateRow = candidateRow + 1;
|
|
}
|
|
}
|
|
|
|
return 999999.0f > nearest;
|
|
}
|
|
|
|
// OFFSET: 0x00CD4060
|
|
// FUNCTION: fn_21274
|
|
bool PickScreenTerrain(
|
|
const RenderProjection& projection, int x, int y, const float* origin, const float* cameraMatrix, WorldSpatialTree& root, int& column, int& row
|
|
) {
|
|
float ray[6]{};
|
|
projection.Ray(x, y, origin, cameraMatrix, ray);
|
|
return PickTerrainRay(ray, root, column, row);
|
|
}
|