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).
This commit is contained in:
ragnarok-clanker 2026-11-05 03:40:55 +00:00
commit 514da171b8
3 changed files with 13 additions and 18 deletions

View file

@ -30,6 +30,8 @@ public:
virtual void Render();
virtual void Update();
matrix AlternateView(float yaw) const;
/* 0004 */ CameraShake shake;
/* 0020 */ CameraState camera;
/* 0050 */ float unknown_0050[3];

View file

@ -17,7 +17,6 @@ struct CameraFrame {
void Build(const CameraState& camera);
void Refresh(const CameraState& camera, CRenderer& renderer);
void Forward(const CameraState& camera, float* output) const;
void AlternateView(const CameraState& camera, float yaw, matrix& output) const;
};

View file

@ -1,4 +1,4 @@
#include "Contents/Camera/CameraFrame.h"
#include "Contents/Camera/Camera.h"
#include "Client/Mode/CGameMode.h"
#include "Client/Mode/ModeMgr.h"
#include "Contents/World/World.h"
@ -6,14 +6,6 @@
#include <cmath>
namespace {
// INLINED
float InverseLength(float squared) {
const float root = std::sqrt(squared);
return static_cast<float>(1.0 / static_cast<double>(root));
}
}
// OFFSET: 0x00ADBAC0
// FUNCTION: fn_17924
void CameraFrame::Forward(const CameraState& camera, float* output) const {
@ -24,7 +16,7 @@ void CameraFrame::Forward(const CameraState& camera, float* output) const {
output[1] = y;
output[0] = x;
output[2] = z;
const float inverse = InverseLength((y * y + x * x) + z * 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];
@ -33,21 +25,23 @@ void CameraFrame::Forward(const CameraState& camera, float* output) const {
// OFFSET: 0x00ADBB60
// FUNCTION: fn_17925
void CameraFrame::AlternateView(const CameraState& camera, float yaw, matrix& output) const {
matrix CView::AlternateView(float yaw) const {
constexpr float pi = 3.141592f;
matrix orbit;
orbit.MakeXRotation((camera.pitch / 180.0f) * pi);
orbit.MakeXRotation((this->camera.pitch / 180.0f) * pi);
orbit.AppendYRotation((yaw / 180.0f) * pi);
const float distance = -camera.distance;
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]) + camera.target[0];
eye[1] = (((orbit.values[4] * 0.0f + orbit.values[1] * 0.0f) + distance * orbit.values[7]) + orbit.values[10]) + camera.target[1];
eye[2] = (((orbit.values[5] * 0.0f + orbit.values[2] * 0.0f) + distance * orbit.values[8]) + orbit.values[11]) + camera.target[2];
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;
}
output.LookAt(eye, camera.target, this->up);
matrix output;
output.LookAt(eye, this->camera.target, this->frame.up);
return output;
}