Maintenance: Make CView a real polymorphic class instead of a void* vtable field set to 0x011598E8. vt_01610 has 5 slots: scalar dele

Batch #9484 by ragnarok-clanker: forced by an admin (2 lower score(s), 5 changed function(s)); checked with 87 compiled unit(s), including every includer of Source/Contents/Camera/Camera.h, Source/Contents/Camera/CameraFrame.h, Source/Contents/Camera/CameraState.h.
This commit is contained in:
ragnarok-clanker 2026-11-01 14:21:24 +00:00
commit 0440a63dcd
7 changed files with 76 additions and 58 deletions

View file

@ -1,6 +1,16 @@
#include "ActorPickNode.h"
#include "Contents/Camera/Camera.h"
#include "Contents/TerrainPathSearch.h"
#include "Client/Mode/CGameMode.h"
#include "Client/Mode/ModeMgr.h"
#include "Contents/Actors/Pc.h"
#include "Contents/Configuration/ServiceOptions.h"
#include "Contents/World/SkyBox.h"
#include "Contents/World/World.h"
#include "Render/Projection/RendererViewport.h"
#include "Render/Renderer.h"
#include "Render/SpriteGeometry.h"
#include "Resource/World/TerrainResource.h"
#include <map>
#include <string>
@ -167,10 +177,15 @@ void CActorPickNode::MakeQuardTree(int depth, ActorPickBounds bounds) {
}
}
// GLOBAL: gl_24536
float g_projectionScale = 0.16f;
// GLOBAL: gl_24775
int g_worldViewDrawn;
// OFFSET: 0x00ADAC70
// FUNCTION: fn_17912
CView::CView() {
this->vtable = reinterpret_cast<void*>(0x011598E8);
this->camera.target[0] = 0.0f;
this->camera.target[1] = 0.0f;
this->camera.target[2] = 0.0f;
@ -190,8 +205,44 @@ CView::CView() {
this->frame.up[1] = 0.0f;
this->frame.up[2] = 0.0f;
this->camera.yaw = 0.0f;
this->unknown_0014 = 0;
this->shake.enabled = 0;
this->unknown_01B4 = nullptr;
this->unknown_0018 = 0;
this->unknown_0010 = 0;
this->shake.start = 0;
*reinterpret_cast<unsigned char*>(&this->shake.unknown_0010) = 0;
}
// OFFSET: 0x00ADAEA0
CView::~CView() {
if (this->unknown_01B4) {
delete this->unknown_01B4;
}
}
// OFFSET: 0x00ADC150
// FUNCTION: fn_17928
void CView::Reset() {
this->camera.Reset();
this->frame.up[0] = 0;
this->frame.up[1] = 1;
this->frame.up[2] = 0;
}
// OFFSET: 0x00ADC1D0
// FUNCTION: fn_17929
void CView::Slot2() {
}
// OFFSET: 0x00ADBF60
// FUNCTION: fn_17927
void CView::Update() {
const vector3d& position = this->scene->player->render.position;
this->camera.desiredTarget[0] = position.x;
this->camera.desiredTarget[1] = position.y;
this->camera.desiredTarget[2] = position.z;
const float rendererScale = g_renderer->UiScaleY();
CameraProjectionOutputs outputs{g_tangent, g_cotangent, g_cameraScaleY, g_cameraScaleX};
this->camera.Smooth(g_serviceOptions, rendererScale, g_projectionScale, g_cameraBaseDistance, outputs);
this->shake.Apply(this->camera, g_worldViewDrawn);
const TerrainHeight terrain = static_cast<CGameMode*>(g_modeMgr.GetGameMode())->scene->terrain->Grid();
this->frame.Refresh(this->camera, terrain, *g_renderer);
}

View file

@ -2748,9 +2748,8 @@ void CGameMode::End() {
}
if (this->camera) {
void** vtable = static_cast<void**>(this->camera->vtable);
reinterpret_cast<void(__thiscall*)(CView*)>(vtable[2])(this->camera);
reinterpret_cast<void(__thiscall*)(CView*, int)>(static_cast<void**>(this->camera->vtable)[0])(this->camera, 1);
this->camera->Slot2();
delete this->camera;
}
g_actorPickNode.Clear();

View file

@ -8,6 +8,7 @@
#include <cstddef>
struct CWorld;
class CSkyBox;
extern float g_cameraDistance;
extern float g_cameraMinDistance;
@ -18,17 +19,17 @@ extern float g_indoorCameraDistance;
extern float g_outdoorCameraPitch;
extern float g_outdoorCameraDistance;
// VTABLE: vt_01610
class CView {
public:
CView();
virtual ~CView();
virtual void Reset();
virtual void Slot2();
virtual void Render();
virtual void Update();
/* 0000 */ void* vtable;
/* 0004 */ unsigned char unknown_0004[0xC];
/* 0010 */ unsigned char unknown_0010;
/* 0011 */ unsigned char unknown_0011[3];
/* 0014 */ int unknown_0014;
/* 0018 */ int unknown_0018;
/* 001C */ unsigned char unknown_001C[4];
/* 0004 */ CameraShake shake;
/* 0020 */ CameraState camera;
/* 0050 */ float unknown_0050[3];
/* 005C */ unsigned char unknown_005C[0xC];
@ -37,7 +38,7 @@ public:
/* 0080 */ CameraFrame frame;
/* 00F8 */ WorldViewSpatial spatial;
/* 01B0 */ CWorld* scene;
/* 01B4 */ void* unknown_01B4;
/* 01B4 */ CSkyBox* unknown_01B4;
};
#if defined(_WIN32) && !defined(_WIN64)

View file

@ -2,15 +2,6 @@
#include "Contents/Ground/TerrainHeight.h"
#include "Render/Renderer.h"
// OFFSET: 0x00ADC150
// FUNCTION: fn_17928
void ResetCamera(CameraState& camera, CameraFrame& frame) {
camera.Reset();
frame.up[0] = 0;
frame.up[1] = 1;
frame.up[2] = 0;
}
// INLINED
void CameraFrame::Build(const CameraState& camera, const TerrainHeight& terrain) {
constexpr float pi = 3.141592f;
@ -39,18 +30,3 @@ void CameraFrame::Refresh(const CameraState& camera, const TerrainHeight& terrai
this->Build(camera, terrain);
renderer.SetCamera(this->eye, camera.target, this->up);
}
// OFFSET: 0x00ADBF60
// FUNCTION: fn_17927
void UpdateCameraFrame(
CameraState& camera, CameraShake& shake, int& frameLatch, const float* desiredTarget, const ServiceOptions& options, const float& rendererScale,
const float& projectionScale, const float& baseDistance, CameraProjectionOutputs& outputs, const TerrainHeight& terrain, CameraFrame& frame,
CRenderer& renderer
) {
camera.desiredTarget[0] = desiredTarget[0];
camera.desiredTarget[1] = desiredTarget[1];
camera.desiredTarget[2] = desiredTarget[2];
camera.Smooth(options, rendererScale, projectionScale, baseDistance, outputs);
shake.Apply(camera, frameLatch);
frame.Refresh(camera, terrain, renderer);
}

View file

@ -21,13 +21,6 @@ struct CameraFrame {
void AlternateView(const CameraState& camera, float yaw, const TerrainHeight& terrain, matrix& output) const;
};
void ResetCamera(CameraState& camera, CameraFrame& frame);
void UpdateCameraFrame(
CameraState& camera, CameraShake& shake, int& frameLatch, const float* desiredTarget, const ServiceOptions& options, const float& rendererScale,
const float& projectionScale, const float& baseDistance, CameraProjectionOutputs& outputs, const TerrainHeight& terrain, CameraFrame& frame,
CRenderer& renderer
);
static_assert(sizeof(CameraFrame) == 120);

View file

@ -3,17 +3,6 @@
#include "Utility/Math/AffineMatrix.h"
#include "Utility/Math/ScalarConversion.h"
// INLINED
void CameraState::Reset() {
this->yaw = this->desiredYaw = 0;
this->distance = this->desiredDistance = 300;
this->pitch = this->desiredPitch = -45;
for (unsigned axis = 0; axis < 3; ++axis) {
this->target[axis] = this->desiredTarget[axis] = 0;
}
}
// OFFSET: 0x00ADB070
// FUNCTION: fn_17916
void CameraState::AddDistance(float delta) {

View file

@ -13,7 +13,16 @@ struct CameraState {
/* 0048 */ float desiredYaw;
/* 004C */ float desiredDistance;
void Reset();
// INLINED
void Reset() {
this->yaw = this->desiredYaw = 0;
this->distance = this->desiredDistance = 300;
this->pitch = this->desiredPitch = -45;
for (unsigned axis = 0; axis < 3; ++axis) {
this->target[axis] = this->desiredTarget[axis] = 0;
}
}
void AddDistance(float delta);
void AddPitch(float delta);
void AddYaw(float delta);