rodecomp/Source/Contents/Camera/CameraQueries.cpp
ragnarok-clanker 514da171b8 Decompile 2 functions in Source/Contents/Camera/CameraQueries.cpp, Source/Contents/Camera/Camera.h, ...
Batch #11580 by cremane: 0 byte-identical, 2 confirmed by peer review.

- fn_17924 CameraFrame::Forward: logic confirmed by peer review
- fn_17925 CView::AlternateView: logic confirmed by peer review

Peer-reviewed-by: Yommy, KWDev
Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
2026-11-05 03:40:55 +00:00

47 lines
1.7 KiB
C++

#include "Contents/Camera/Camera.h"
#include "Client/Mode/CGameMode.h"
#include "Client/Mode/ModeMgr.h"
#include "Contents/World/World.h"
#include "Resource/World/TerrainResource.h"
#include <cmath>
// OFFSET: 0x00ADBAC0
// FUNCTION: fn_17924
void CameraFrame::Forward(const CameraState& camera, float* output) const {
const float y = camera.target[1] - this->eye[1];
const float x = camera.target[0] - this->eye[0];
const float z = camera.target[2] - this->eye[2];
output[1] = y;
output[0] = x;
output[2] = z;
const float inverse = 1.0f / SquareRoot((y * y + x * x) + z * z);
output[0] = inverse * output[0];
const float last = inverse * output[2];
output[1] = inverse * output[1];
output[2] = last;
}
// OFFSET: 0x00ADBB60
// FUNCTION: fn_17925
matrix CView::AlternateView(float yaw) const {
constexpr float pi = 3.141592f;
matrix orbit;
orbit.MakeXRotation((this->camera.pitch / 180.0f) * pi);
orbit.AppendYRotation((yaw / 180.0f) * pi);
const float distance = -this->camera.distance;
float eye[3];
eye[0] = (((orbit.values[3] * 0.0f + orbit.values[0] * 0.0f) + distance * orbit.values[6]) + orbit.values[9]) + this->camera.target[0];
eye[1] = (((orbit.values[4] * 0.0f + orbit.values[1] * 0.0f) + distance * orbit.values[7]) + orbit.values[10]) + this->camera.target[1];
eye[2] = (((orbit.values[5] * 0.0f + orbit.values[2] * 0.0f) + distance * orbit.values[8]) + orbit.values[11]) + this->camera.target[2];
const float height = static_cast<CGameMode*>(g_modeMgr.GetGameMode())->scene->terrain->Height(eye[0], eye[2]);
if (eye[1] > height) {
eye[1] = height;
}
matrix output;
output.LookAt(eye, this->camera.target, this->frame.up);
return output;
}