some educated guesses for unknown view manager names (#1106)

* some educated guesses for unknown view manager names

* Formatting

* Pin pylint version

* Use snake case for consistency (limited to this class)

---------

Co-authored-by: Christian Semmler <mail@csemmler.com>
This commit is contained in:
Cameron 2024-09-20 18:17:24 +01:00 committed by GitHub
parent a942325b29
commit 4878727393
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 82 additions and 80 deletions

View file

@ -28,7 +28,7 @@ jobs:
- name: Install python libraries - name: Install python libraries
shell: bash shell: bash
run: | run: |
pip install black==23.* pylint==3.* pytest==7.* -r tools/requirements.txt pip install black==23.* pylint==3.2.7 pytest==7.* -r tools/requirements.txt
- name: Run pylint and black - name: Run pylint and black
shell: bash shell: bash

View file

@ -1566,7 +1566,7 @@ MxU16 LegoAnimationManager::FUN_10062110(
LegoPathActor* actor = (LegoPathActor*) p_roi->GetEntity(); LegoPathActor* actor = (LegoPathActor*) p_roi->GetEntity();
if (actor != NULL && actor->GetBoundary() == p_boundary && actor->GetState() == 0) { if (actor != NULL && actor->GetBoundary() == p_boundary && actor->GetState() == 0) {
if (GetViewManager()->FUN_100a6150(p_roi->GetWorldBoundingBox())) { if (GetViewManager()->IsBoundingBoxInFrustum(p_roi->GetWorldBoundingBox())) {
Mx3DPointFloat direction(p_roi->GetWorldDirection()); Mx3DPointFloat direction(p_roi->GetWorldDirection());
if (direction.Dot(&direction, &p_direction) > 0.707) { if (direction.Dot(&direction, &p_direction) > 0.707) {
@ -1814,7 +1814,7 @@ void LegoAnimationManager::PurgeExtra(MxBool p_und)
if ((p_und && !maOrPa) || if ((p_und && !maOrPa) ||
(g_characters[m_extras[i].m_characterId].m_unk0x10 >= 0 && time - m_extras[i].m_unk0x08 > und && (g_characters[m_extras[i].m_characterId].m_unk0x10 >= 0 && time - m_extras[i].m_unk0x08 > und &&
CharacterManager()->GetRefCount(roi) == 1 && CharacterManager()->GetRefCount(roi) == 1 &&
!viewManager->FUN_100a6150(roi->GetWorldBoundingBox()))) { !viewManager->IsBoundingBoxInFrustum(roi->GetWorldBoundingBox()))) {
m_unk0x414--; m_unk0x414--;
LegoPathActor* actor = CharacterManager()->GetExtraActor(roi->GetName()); LegoPathActor* actor = CharacterManager()->GetExtraActor(roi->GetName());
@ -2469,7 +2469,7 @@ MxBool LegoAnimationManager::FUN_10064010(LegoPathBoundary* p_boundary, LegoUnkn
boundingBox.Min().Sub(vec); boundingBox.Min().Sub(vec);
boundingBox.Max() = p1; boundingBox.Max() = p1;
boundingBox.Max().Add(vec); boundingBox.Max().Add(vec);
return GetViewManager()->FUN_100a6150(boundingBox) == FALSE; return GetViewManager()->IsBoundingBoxInFrustum(boundingBox) == FALSE;
} }
// FUNCTION: LEGO1 0x10064120 // FUNCTION: LEGO1 0x10064120

View file

@ -9,19 +9,20 @@
DECOMP_SIZE_ASSERT(ViewManager, 0x1bc) DECOMP_SIZE_ASSERT(ViewManager, 0x1bc)
// GLOBAL: LEGO1 0x100dbc78 // GLOBAL: LEGO1 0x100dbc78
int g_unk0x100dbc78[8][3] = {{0, 0, 0}, {0, 0, 1}, {0, 1, 0}, {1, 0, 0}, {0, 1, 1}, {1, 0, 1}, {1, 1, 0}, {1, 1, 1}}; int g_boundingBoxCornerMap[8][3] =
{{0, 0, 0}, {0, 0, 1}, {0, 1, 0}, {1, 0, 0}, {0, 1, 1}, {1, 0, 1}, {1, 1, 0}, {1, 1, 1}};
// GLOBAL: LEGO1 0x100dbcd8 // GLOBAL: LEGO1 0x100dbcd8
int g_unk0x100dbcd8[18] = {0, 1, 5, 6, 2, 3, 3, 0, 4, 1, 2, 6, 0, 3, 2, 4, 5, 6}; int g_planePointIndexMap[18] = {0, 1, 5, 6, 2, 3, 3, 0, 4, 1, 2, 6, 0, 3, 2, 4, 5, 6};
// GLOBAL: LEGO1 0x10101050 // GLOBAL: LEGO1 0x10101050
float g_unk0x10101050 = 4.0F; float g_LODScaleFactor = 4.0F;
// GLOBAL: LEGO1 0x10101054 // GLOBAL: LEGO1 0x10101054
float g_unk0x10101054 = 0.00097656297; float g_minLODThreshold = 0.00097656297;
// GLOBAL: LEGO1 0x10101058 // GLOBAL: LEGO1 0x10101058
int g_unk0x10101058 = 6; int g_maxLODLevels = 6;
// GLOBAL: LEGO1 0x1010105c // GLOBAL: LEGO1 0x1010105c
float g_unk0x1010105c = 0.000125F; float g_unk0x1010105c = 0.000125F;
@ -38,7 +39,7 @@ ViewManager::ViewManager(Tgl::Renderer* pRenderer, Tgl::Group* scene, const Orie
: scene(scene), flags(c_bit1 | c_bit2 | c_bit3 | c_bit4) : scene(scene), flags(c_bit1 | c_bit2 | c_bit3 | c_bit4)
{ {
SetPOVSource(point_of_view); SetPOVSource(point_of_view);
unk0x28 = 0.09; prev_render_time = 0.09;
GetD3DRM(d3drm, pRenderer); GetD3DRM(d3drm, pRenderer);
GetFrame(frame, scene); GetFrame(frame, scene);
width = 0.0; width = 0.0;
@ -48,7 +49,7 @@ ViewManager::ViewManager(Tgl::Renderer* pRenderer, Tgl::Group* scene, const Orie
front = 0.0; front = 0.0;
back = 0.0; back = 0.0;
memset(unk0xf0, 0, sizeof(unk0xf0)); memset(transformed_points, 0, sizeof(transformed_points));
seconds_allowed = 1.0; seconds_allowed = 1.0;
} }
@ -60,7 +61,7 @@ ViewManager::~ViewManager()
// FUNCTION: LEGO1 0x100a6150 // FUNCTION: LEGO1 0x100a6150
// FUNCTION: BETA10 0x10172164 // FUNCTION: BETA10 0x10172164
unsigned int ViewManager::FUN_100a6150(const BoundingBox& p_bounding_box) unsigned int ViewManager::IsBoundingBoxInFrustum(const BoundingBox& p_bounding_box)
{ {
const Vector3* box[] = {&p_bounding_box.Min(), &p_bounding_box.Max()}; const Vector3* box[] = {&p_bounding_box.Min(), &p_bounding_box.Max()};
@ -69,13 +70,14 @@ unsigned int ViewManager::FUN_100a6150(const BoundingBox& p_bounding_box)
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
for (j = 0; j < 3; j++) { for (j = 0; j < 3; j++) {
und[i][j] = box[g_unk0x100dbc78[i][j]]->operator[](j); und[i][j] = box[g_boundingBoxCornerMap[i][j]]->operator[](j);
} }
} }
for (i = 0; i < 6; i++) { for (i = 0; i < 6; i++) {
for (k = 0; k < 8; k++) { for (k = 0; k < 8; k++) {
if (unk0x150[i][0] * und[k][0] + unk0x150[i][2] * und[k][2] + unk0x150[i][1] * und[k][1] + unk0x150[i][3] >= if (frustum_planes[i][0] * und[k][0] + frustum_planes[i][2] * und[k][2] + frustum_planes[i][1] * und[k][1] +
frustum_planes[i][3] >=
0.0f) { 0.0f) {
break; break;
} }
@ -239,7 +241,7 @@ inline void ViewManager::ManageVisibilityAndDetailRecursively(ViewROI* p_roi, in
return; return;
} }
p_und = Unknown2(und, RealtimeView::GetUserMaxLodPower() * seconds_allowed, p_roi); p_und = CalculateLODLevel(und, RealtimeView::GetUserMaxLodPower() * seconds_allowed, p_roi);
} }
} }
@ -277,11 +279,11 @@ void ViewManager::Update(float p_previousRenderTime, float)
MxStopWatch stopWatch; MxStopWatch stopWatch;
stopWatch.Start(); stopWatch.Start();
unk0x28 = p_previousRenderTime; prev_render_time = p_previousRenderTime;
flags |= c_bit1; flags |= c_bit1;
if (flags & c_bit3) { if (flags & c_bit3) {
Unknown(); CalculateFrustumTransformations();
} }
else if (flags & c_bit2) { else if (flags & c_bit2) {
UpdateViewTransformations(); UpdateViewTransformations();
@ -295,7 +297,7 @@ void ViewManager::Update(float p_previousRenderTime, float)
g_elapsedSeconds = stopWatch.ElapsedSeconds(); g_elapsedSeconds = stopWatch.ElapsedSeconds();
} }
inline int ViewManager::Unknown() inline int ViewManager::CalculateFrustumTransformations()
{ {
flags &= ~c_bit3; flags &= ~c_bit3;
@ -314,33 +316,33 @@ inline int ViewManager::Unknown()
float fVar5 = fVar4 * fVar1; float fVar5 = fVar4 * fVar1;
fVar4 = fVar4 * fVar2; fVar4 = fVar4 * fVar2;
float* unk0x90 = (float*) this->unk0x90; float* frustumVertices = (float*) this->frustum_vertices;
// clang-format off // clang-format off
*unk0x90 = fVar2; unk0x90++; *frustumVertices = fVar2; frustumVertices++;
*unk0x90 = fVar1; unk0x90++; *frustumVertices = fVar1; frustumVertices++;
*unk0x90 = uVar6; unk0x90++; *frustumVertices = uVar6; frustumVertices++;
*unk0x90 = fVar2; unk0x90++; *frustumVertices = fVar2; frustumVertices++;
*unk0x90 = -fVar1; unk0x90++; *frustumVertices = -fVar1; frustumVertices++;
*unk0x90 = uVar6; unk0x90++; *frustumVertices = uVar6; frustumVertices++;
*unk0x90 = -fVar2; unk0x90++; *frustumVertices = -fVar2; frustumVertices++;
*unk0x90 = -fVar1; unk0x90++; *frustumVertices = -fVar1; frustumVertices++;
*unk0x90 = uVar6; unk0x90++; *frustumVertices = uVar6; frustumVertices++;
*unk0x90 = -fVar2; unk0x90++; *frustumVertices = -fVar2; frustumVertices++;
*unk0x90 = fVar1; unk0x90++; *frustumVertices = fVar1; frustumVertices++;
*unk0x90 = uVar6; unk0x90++; *frustumVertices = uVar6; frustumVertices++;
*unk0x90 = fVar4; unk0x90++; *frustumVertices = fVar4; frustumVertices++;
*unk0x90 = fVar5; unk0x90++; *frustumVertices = fVar5; frustumVertices++;
*unk0x90 = fVar3; unk0x90++; *frustumVertices = fVar3; frustumVertices++;
*unk0x90 = fVar4; unk0x90++; *frustumVertices = fVar4; frustumVertices++;
*unk0x90 = -fVar5; unk0x90++; *frustumVertices = -fVar5; frustumVertices++;
*unk0x90 = fVar3; unk0x90++; *frustumVertices = fVar3; frustumVertices++;
*unk0x90 = -fVar4; unk0x90++; *frustumVertices = -fVar4; frustumVertices++;
*unk0x90 = -fVar5; unk0x90++; *frustumVertices = -fVar5; frustumVertices++;
*unk0x90 = fVar3; unk0x90++; *frustumVertices = fVar3; frustumVertices++;
*unk0x90 = -fVar4; unk0x90++; *frustumVertices = -fVar4; frustumVertices++;
*unk0x90 = fVar5; unk0x90++; *frustumVertices = fVar5; frustumVertices++;
*unk0x90 = fVar3; *frustumVertices = fVar3;
// clang-format on // clang-format on
UpdateViewTransformations(); UpdateViewTransformations();
@ -348,13 +350,13 @@ inline int ViewManager::Unknown()
} }
} }
inline int ViewManager::Unknown2(float p_und1, float p_und2, ViewROI* p_roi) inline int ViewManager::CalculateLODLevel(float p_und1, float p_und2, ViewROI* p_roi)
{ {
int result; int result;
float i; float i;
if (Unknown3(p_roi) != 0) { if (IsROIVisibleAtLOD(p_roi) != 0) {
if (p_und1 < g_unk0x10101054) { if (p_und1 < g_minLODThreshold) {
return 0; return 0;
} }
@ -364,14 +366,14 @@ inline int ViewManager::Unknown2(float p_und1, float p_und2, ViewROI* p_roi)
result = 0; result = 0;
} }
for (i = p_und2; result < g_unk0x10101058 && p_und1 >= i; i *= g_unk0x10101050) { for (i = p_und2; result < g_maxLODLevels && p_und1 >= i; i *= g_LODScaleFactor) {
result++; result++;
} }
return result; return result;
} }
inline int ViewManager::Unknown3(ViewROI* p_roi) inline int ViewManager::IsROIVisibleAtLOD(ViewROI* p_roi)
{ {
const LODListBase* lods = p_roi->GetLODs(); const LODListBase* lods = p_roi->GetLODs();
@ -411,21 +413,21 @@ void ViewManager::UpdateViewTransformations()
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
for (j = 0; j < 3; j++) { for (j = 0; j < 3; j++) {
unk0xf0[i][j] = pov[3][j]; transformed_points[i][j] = pov[3][j];
for (k = 0; k < 3; k++) { for (k = 0; k < 3; k++) {
unk0xf0[i][j] += pov[k][j] * unk0x90[i][k]; transformed_points[i][j] += pov[k][j] * frustum_vertices[i][k];
} }
} }
} }
for (i = 0; i < 6; i++) { for (i = 0; i < 6; i++) {
Vector3 a(unk0xf0[g_unk0x100dbcd8[i * 3]]); Vector3 a(transformed_points[g_planePointIndexMap[i * 3]]);
Vector3 b(unk0xf0[g_unk0x100dbcd8[i * 3 + 1]]); Vector3 b(transformed_points[g_planePointIndexMap[i * 3 + 1]]);
Vector3 c(unk0xf0[g_unk0x100dbcd8[i * 3 + 2]]); Vector3 c(transformed_points[g_planePointIndexMap[i * 3 + 2]]);
Mx3DPointFloat x; Mx3DPointFloat x;
Mx3DPointFloat y; Mx3DPointFloat y;
Vector3 u(unk0x150[i]); Vector3 normal(frustum_planes[i]);
x = c; x = c;
((Vector3&) x).Sub(b); // TODO: Fix call ((Vector3&) x).Sub(b); // TODO: Fix call
@ -433,10 +435,10 @@ void ViewManager::UpdateViewTransformations()
y = a; y = a;
((Vector3&) y).Sub(b); // TODO: Fix call ((Vector3&) y).Sub(b); // TODO: Fix call
u.EqualsCross(&x, &y); normal.EqualsCross(&x, &y);
u.Unitize(); normal.Unitize();
unk0x150[i][3] = -u.Dot(&u, &a); frustum_planes[i][3] = -normal.Dot(&normal, &a);
} }
flags |= c_bit4; flags |= c_bit4;

View file

@ -23,7 +23,7 @@ class ViewManager {
void Remove(ViewROI* p_roi); void Remove(ViewROI* p_roi);
void RemoveAll(ViewROI* p_roi); void RemoveAll(ViewROI* p_roi);
unsigned int FUN_100a6150(const BoundingBox& p_bounding_box); unsigned int IsBoundingBoxInFrustum(const BoundingBox& p_bounding_box);
void UpdateROIDetailBasedOnLOD(ViewROI* p_roi, int p_und); void UpdateROIDetailBasedOnLOD(ViewROI* p_roi, int p_und);
void RemoveROIDetailFromScene(ViewROI* p_roi); void RemoveROIDetailFromScene(ViewROI* p_roi);
void SetPOVSource(const OrientableROI* point_of_view); void SetPOVSource(const OrientableROI* point_of_view);
@ -33,11 +33,11 @@ class ViewManager {
void SetFrustrum(float fov, float front, float back); void SetFrustrum(float fov, float front, float back);
inline void ManageVisibilityAndDetailRecursively(ViewROI* p_roi, int p_und); inline void ManageVisibilityAndDetailRecursively(ViewROI* p_roi, int p_und);
void Update(float p_previousRenderTime, float); void Update(float p_previousRenderTime, float);
inline int Unknown(); inline int CalculateFrustumTransformations();
void UpdateViewTransformations(); void UpdateViewTransformations();
inline static int Unknown2(float p_und1, float p_und2, ViewROI* p_roi); inline static int CalculateLODLevel(float p_und1, float p_und2, ViewROI* p_roi);
inline static int Unknown3(ViewROI* p_roi); inline static int IsROIVisibleAtLOD(ViewROI* p_roi);
const CompoundObject& GetROIs() { return rois; } const CompoundObject& GetROIs() { return rois; }
void Add(ViewROI* p_roi) { rois.push_back(p_roi); } void Add(ViewROI* p_roi) { rois.push_back(p_roi); }
@ -50,7 +50,7 @@ class ViewManager {
CompoundObject rois; // 0x08 CompoundObject rois; // 0x08
RealtimeView rt_view; // 0x14 RealtimeView rt_view; // 0x14
ROIList visible_rois; // 0x18 ROIList visible_rois; // 0x18
float unk0x28; // 0x28 float prev_render_time; // 0x28
float view_area_at_one; // 0x2c float view_area_at_one; // 0x2c
unsigned int flags; // 0x30 unsigned int flags; // 0x30
float width; // 0x34 float width; // 0x34
@ -59,9 +59,9 @@ class ViewManager {
MxMatrix pov; // 0x40 MxMatrix pov; // 0x40
float front; // 0x88 float front; // 0x88
float back; // 0x8c float back; // 0x8c
float unk0x90[8][3]; // 0x90 float frustum_vertices[8][3]; // 0x90
float unk0xf0[8][3]; // 0xf0 float transformed_points[8][3]; // 0xf0
float unk0x150[6][4]; // 0x150 float frustum_planes[6][4]; // 0x150
IDirect3DRM2* d3drm; // 0x1b0 IDirect3DRM2* d3drm; // 0x1b0
IDirect3DRMFrame2* frame; // 0x1b4 IDirect3DRMFrame2* frame; // 0x1b4
float seconds_allowed; // 0x1b8 float seconds_allowed; // 0x1b8