Decompile 2 functions in Source/Contents/Camera/CameraShake.cpp, Source/Contents/Camera/CameraFrame.cpp, ...

Batch #16042 by Yommy: 0 byte-identical, 2 confirmed by peer review.

- fn_17931 CView::Apply: logic confirmed by peer review
- fn_17927 CView::Update: logic confirmed by peer review

Peer-reviewed-by: eAthena, alisonrag
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-10 13:14:54 +00:00
commit e51133debe
3 changed files with 15 additions and 22 deletions

View file

@ -33,7 +33,7 @@ public:
matrix AlternateView(float yaw) const;
void Refresh();
void Apply(CameraState& camera, int& frameLatch);
void Apply();
void Start(int enabled, unsigned duration, float horizontal, float distance, float pitch);
void SetAmplitudes(float horizontal, float distance, float pitch);

View file

@ -39,6 +39,6 @@ void CView::Update() {
this->camera.desiredTarget[1] = position.y;
this->camera.desiredTarget[2] = position.z;
this->camera.Smooth();
this->Apply(this->camera, g_worldViewDrawn);
this->Apply();
this->Refresh();
}

View file

@ -1,7 +1,6 @@
#include "Contents/Camera/Camera.h"
#include "Contents/Camera/CameraState.h"
#include "Utility/Math/AffineMatrix.h"
#include "Utility/Math/ScalarConversion.h"
#include <cstdlib>
#include <windows.h>
@ -48,48 +47,42 @@ void CView::SetAmplitudes(float horizontal, float distance, float pitch) {
// OFFSET: 0x00ADC7A0
// FUNCTION: fn_17931
void CView::Apply(CameraState& camera, int& frameLatch) {
void CView::Apply() {
if (!this->shake.enabled) {
return;
}
if (timeGetTime() >= this->shake.start + this->shake.duration) {
camera.target[0] = camera.desiredTarget[0];
camera.target[1] = camera.desiredTarget[1];
camera.target[2] = camera.desiredTarget[2];
camera.distance = camera.desiredDistance;
this->camera.target[0] = this->camera.desiredTarget[0];
this->camera.target[1] = this->camera.desiredTarget[1];
this->camera.target[2] = this->camera.desiredTarget[2];
this->camera.distance = this->camera.desiredDistance;
this->shake.enabled = 0;
camera.pitch = camera.desiredPitch;
this->camera.pitch = this->camera.desiredPitch;
return;
}
if (!frameLatch) {
if (!g_worldViewDrawn) {
return;
}
frameLatch = 0;
g_worldViewDrawn = 0;
// GLOBAL: gl_24565
static float horizontal = this->shake.horizontal;
const float horizontalX = Jitter(10.0f) + horizontal;
const int yawX = TruncateToInt(camera.yaw);
const float x = static_cast<float>(static_cast<double>(ClientCosine(yawX)) * horizontalX);
camera.target[0] = x + camera.target[0];
const float horizontalZ = Jitter(10.0f) + horizontal;
const int yawZ = TruncateToInt(camera.yaw);
const float sine = -ClientSine(yawZ);
this->camera.target[0] += (Jitter(10.0f) + horizontal) * ClientCosine(static_cast<int>(this->camera.yaw));
const float offsetZ = (Jitter(10.0f) + horizontal) * -ClientSine(static_cast<int>(this->camera.yaw));
horizontal = -horizontal;
camera.target[2] = horizontalZ * sine + camera.target[2];
this->camera.target[2] += offsetZ;
// GLOBAL: gl_24566
static float distance = this->shake.distance;
const float distanceDelta = Jitter(10.0f) + distance;
distance = -distance;
camera.distance = distanceDelta + camera.distance;
this->camera.distance = distanceDelta + this->camera.distance;
// GLOBAL: gl_24567
static float pitch = this->shake.pitch;
const float pitchDelta = Jitter(15.0f) + pitch;
pitch = -pitch;
camera.pitch = pitchDelta + camera.pitch;
this->camera.pitch = pitchDelta + this->camera.pitch;
}