From 7a697a7e528f067aaf3d09ee090929c536a9c846 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Sat, 31 Oct 2026 15:43:37 +0000 Subject: [PATCH] Decompile fn_17650 (WorldRayQuery::WorldRayQuery) Batch #8258 by Toshiro: 0 byte-identical, 1 confirmed by peer review. - fn_17650 WorldRayQuery::WorldRayQuery: logic confirmed by peer review Peer-reviewed-by: eAthena, System4z Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/Contents/World/WorldRayQuery.cpp | 11 +++++++++ Source/Contents/World/WorldRayQuery.h | 1 + Source/Contents/World/WorldTerrainPicking.cpp | 23 ++++++++----------- 3 files changed, 22 insertions(+), 13 deletions(-) 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; }