rodecomp/Source/Contents/World/WorldOcclusion.cpp
ragnarok-clanker 750f35b3dd Maintenance: [forced, user-approved] Family W5 (resubmission of 10276 without the STATIC lines; replaces agent 2's 10270, returned by
Batch #10277 by ragnarok-clanker: forced by an admin (17 lower score(s), 63 changed function(s)); checked with 414 compiled unit(s), including every includer of Source/Contents/Effects/RagEffect.h, Source/Contents/Models/ModelActor.h, Source/Contents/Models/ModelNode.h, Source/Contents/Models/ModelRendering.h, Source/Contents/World/WorldModelView.h, Source/Contents/World/WorldOcclusion.h, Source/Contents/World/WorldTerrainPicking.h, Source/Render/Projection/RendererViewport.h, Source/Render/Projection/RenderProjection.h.
Deletes: Source/Render/Projection/RenderProjection.h
2026-11-03 15:49:14 +00:00

55 lines
1.7 KiB
C++

#include "Contents/Ground/GroundGeometry.h"
#include "Contents/Models/ModelActor.h"
#include "Contents/World/WorldOcclusion.h"
#include "Contents/World/WorldRayQuery.h"
#include "Contents/World/WorldSpatialTree.h"
#include "Render/Renderer.h"
#include "Utility/Math/ScalarConversion.h"
#include <cstring>
// INLINED
void MarkWorldOcclusionRay(const float* ray, float actorLimit, float groundLimit, WorldSpatialTree& root, GroundGeometry& ground, bool markGround) {
float actorRay[7];
std::memcpy(actorRay, ray, 6 * sizeof(float));
actorRay[6] = actorLimit;
WorldRayQuery query;
query.Collect(ray, &root);
for (WorldSpatialTree* node : query.nodes) {
for (C3dActor* model : node->objects) {
model->MarkOccluded(actorRay);
}
}
if (markGround) {
for (WorldSpatialTree* node : query.nodes) {
int row = node->groundCells[1];
while (row <= node->groundCells[3]) {
int column = node->groundCells[0];
while (column <= node->groundCells[2]) {
ground.MarkRay(ray, column, row, groundLimit);
++column;
}
++row;
}
}
}
}
// OFFSET: 0x00CD5AD0
// FUNCTION: fn_21286
void MarkScreenWorldOcclusion(
int screenX, int screenY, float rendererScale, const float* origin, const float* cameraMatrix, float playerHeight,
float cameraHeight, WorldSpatialTree& root, GroundGeometry& ground, bool markGround
) {
const float shifted = static_cast<float>(screenY) - rendererScale * 23.0f;
const int y = TruncateToInt(shifted);
float ray[6]{};
g_renderer->viewport.Ray(screenX, y, origin, cameraMatrix, ray);
const float limit = (playerHeight + cameraHeight) - 16.0f;
MarkWorldOcclusionRay(ray, limit, limit, root, ground, markGround);
}