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
40 lines
1.9 KiB
C++
40 lines
1.9 KiB
C++
#include "Render/Primitives/LightmappedPrimitive.h"
|
|
#include "Render/Primitives/RenderPrimitive.h"
|
|
#include "Render/Projection/RendererViewport.h"
|
|
|
|
#include <bit>
|
|
|
|
// OFFSET: 0x0055D650
|
|
// FUNCTION: fn_02106
|
|
void RendererViewport::Project(const float* position, const float* matrix, RenderVertex& output) const {
|
|
const float inverseDepth = 1.0f / (((matrix[5] * position[1] + matrix[2] * position[0]) + matrix[8] * position[2]) + matrix[11]);
|
|
output.rhw = inverseDepth;
|
|
|
|
// STATIC: 0x010DD22C
|
|
// GLOBAL: gl_13420
|
|
constexpr float depthScale = 1.0067114f;
|
|
const float depth = ((1.0f / inverseDepth - 10.0f) * depthScale) * inverseDepth;
|
|
const float x = ((((matrix[3] * position[1] + position[0] * matrix[0]) + matrix[6] * position[2]) + matrix[9]) * inverseDepth) * this->scaleX;
|
|
output.x = x + static_cast<float>(this->centerX);
|
|
|
|
const float centerY = static_cast<float>(this->centerY);
|
|
const float y = ((((matrix[4] * position[1] + matrix[1] * position[0]) + matrix[7] * position[2]) + matrix[10]) * inverseDepth) * this->scaleY;
|
|
output.z = depth;
|
|
output.y = y + centerY;
|
|
}
|
|
|
|
// OFFSET: 0x0055D750
|
|
// FUNCTION: fn_02107
|
|
void RendererViewport::Project(const float* position, const float* matrix, LightmappedVertex& output) const {
|
|
const float inverseDepth = 1.0f / (((matrix[5] * position[1] + matrix[2] * position[0]) + matrix[8] * position[2]) + matrix[11]);
|
|
output.rhw = inverseDepth;
|
|
|
|
const float depth = ((1.0f / inverseDepth - 10.0f) * 1.0067114f) * inverseDepth;
|
|
const float x = ((((matrix[3] * position[1] + position[0] * matrix[0]) + matrix[6] * position[2]) + matrix[9]) * inverseDepth) * this->scaleX;
|
|
output.x = x + static_cast<float>(this->centerX);
|
|
|
|
const float centerY = static_cast<float>(this->centerY);
|
|
const float y = ((((matrix[4] * position[1] + matrix[1] * position[0]) + matrix[7] * position[2]) + matrix[10]) * inverseDepth) * this->scaleY;
|
|
output.z = depth;
|
|
output.y = y + centerY;
|
|
}
|