diff --git a/Source/Contents/World/WorldRayQuery.cpp b/Source/Contents/World/WorldRayQuery.cpp index 14c3e200..ea63566f 100644 --- a/Source/Contents/World/WorldRayQuery.cpp +++ b/Source/Contents/World/WorldRayQuery.cpp @@ -3,6 +3,17 @@ #include +// OFFSET: 0x00AC6450 +// FUNCTION: fn_17650 +WorldRayQuery::WorldRayQuery() { + this->origin[0] = 0.0f; + this->origin[1] = 0.0f; + this->origin[2] = 0.0f; + this->direction[0] = 0.0f; + this->direction[1] = 0.0f; + this->direction[2] = 0.0f; +} + // OFFSET: 0x00AC7C50 // FUNCTION: fn_17661 bool WorldRayQuery::Intersects(const float* bounds) const { diff --git a/Source/Contents/World/WorldRayQuery.h b/Source/Contents/World/WorldRayQuery.h index 98141434..23d7ce0f 100644 --- a/Source/Contents/World/WorldRayQuery.h +++ b/Source/Contents/World/WorldRayQuery.h @@ -12,6 +12,7 @@ struct WorldRayQuery { /* 0014 */ float direction[3]; /* 0020 */ float limit; + WorldRayQuery(); bool Intersects(const float* bounds) const; void Collect(const float* ray, WorldSpatialTree* root); void CollectNode(WorldSpatialTree* node, int depth); diff --git a/Source/Contents/World/WorldTerrainPicking.cpp b/Source/Contents/World/WorldTerrainPicking.cpp index 757922d1..0d60fdbe 100644 --- a/Source/Contents/World/WorldTerrainPicking.cpp +++ b/Source/Contents/World/WorldTerrainPicking.cpp @@ -4,11 +4,17 @@ #include "Render/Projection/RenderProjection.h" #include "Resource/World/TerrainResource.h" -// INLINED -bool PickTerrainRay(const float* ray, WorldSpatialTree& root, int& column, int& row) { +// 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 +) { WorldRayQuery query; + float ray[6]{}; + projection.Ray(x, y, origin, cameraMatrix, ray); query.Collect(ray, &root); float nearest = 999999.0f; + float result = nearest; for (WorldSpatialTree* node : query.nodes) { C3dAttr* terrain = node->terrain; @@ -26,6 +32,7 @@ bool PickTerrainRay(const float* ray, WorldSpatialTree& root, int& column, int& row = candidateRow; } + result = nearest; candidateColumn = candidateColumn + 1; } @@ -33,15 +40,5 @@ bool PickTerrainRay(const float* ray, WorldSpatialTree& root, int& column, int& } } - 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); + return result < 999999.0f; }