From 0620e83125703d2728e7bdebfe997d431eb90280 Mon Sep 17 00:00:00 2001 From: Lwmte <3331699+Lwmte@users.noreply.github.com> Date: Sat, 21 Dec 2024 12:40:24 +0100 Subject: [PATCH 1/2] Don't give LDoc warning on compile --- Scripts/Engine/Util.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/Scripts/Engine/Util.lua b/Scripts/Engine/Util.lua index ad6c0a9d9..0f4c711b2 100644 --- a/Scripts/Engine/Util.lua +++ b/Scripts/Engine/Util.lua @@ -1,3 +1,4 @@ +-- ldignore local Util = {} Util.ShortenTENCalls = function() From 04b659b4101e62cf09fdfbff20c4be9d504fa51f Mon Sep 17 00:00:00 2001 From: Lwmte <3331699+Lwmte@users.noreply.github.com> Date: Sat, 21 Dec 2024 19:31:24 +0100 Subject: [PATCH 2/2] Revert joint connection code, fix compass needle --- TombEngine/Game/gui.cpp | 3 +- TombEngine/Renderer/RendererCompatibility.cpp | 47 ++++++++++++------- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/TombEngine/Game/gui.cpp b/TombEngine/Game/gui.cpp index ec338990f..26b9ad59c 100644 --- a/TombEngine/Game/gui.cpp +++ b/TombEngine/Game/gui.cpp @@ -3303,6 +3303,7 @@ namespace TEN::Gui while (g_Synchronizer.Synced()) { TimeInMenu++; + GlobalCounter++; SaveGame::Statistics.Game.TimeTaken++; SaveGame::Statistics.Level.TimeTaken++; @@ -3451,7 +3452,7 @@ namespace TEN::Gui needleOrient.Lerp(EulerAngles(0, item->Pose.Orientation.y, 0), LERP_ALPHA); float wibble = std::sin((float(GlobalCounter & 0x3F) / (float)0x3F) * PI_MUL_2); - CompassNeedleAngle = needleOrient.y + ANGLE(wibble / 2); + CompassNeedleAngle = needleOrient.y + ANGLE(wibble); // HACK: Needle is rotated in the draw function. const auto& invObject = InventoryObjectTable[INV_OBJECT_COMPASS]; diff --git a/TombEngine/Renderer/RendererCompatibility.cpp b/TombEngine/Renderer/RendererCompatibility.cpp index 77d2970d3..e8cc46136 100644 --- a/TombEngine/Renderer/RendererCompatibility.cpp +++ b/TombEngine/Renderer/RendererCompatibility.cpp @@ -671,18 +671,25 @@ namespace TEN::Renderer { auto* skinVertex = &_moveablesVertices[skinBucket->StartVertex + v2]; - auto vertex0 = _moveablesVertices[jointBucket->StartVertex + v1].Position + jointBone->GlobalTranslation; - auto vertex1 = _moveablesVertices[skinBucket->StartVertex + v2].Position + skinBone->GlobalTranslation; + // NOTE: Don't vectorize these coordinates, it breaks the connection in some cases. -- Lwmte, 21.12.24 - if (Vector3::Distance(vertex0, vertex1) > 2) - continue; + int x1 = _moveablesVertices[jointBucket->StartVertex + v1].Position.x + jointBone->GlobalTranslation.x; + int y1 = _moveablesVertices[jointBucket->StartVertex + v1].Position.y + jointBone->GlobalTranslation.y; + int z1 = _moveablesVertices[jointBucket->StartVertex + v1].Position.z + jointBone->GlobalTranslation.z; - jointVertex->Bone = bonesToCheck[k]; - jointVertex->Position = skinVertex->Position; - jointVertex->Normal = skinVertex->Normal; + int x2 = _moveablesVertices[skinBucket->StartVertex + v2].Position.x + skinBone->GlobalTranslation.x; + int y2 = _moveablesVertices[skinBucket->StartVertex + v2].Position.y + skinBone->GlobalTranslation.y; + int z2 = _moveablesVertices[skinBucket->StartVertex + v2].Position.z + skinBone->GlobalTranslation.z; - isDone = true; - break; + if (abs(x1 - x2) < 2 && abs(y1 - y2) < 2 && abs(z1 - z2) < 2) + { + jointVertex->Bone = bonesToCheck[k]; + jointVertex->Position = skinVertex->Position; + jointVertex->Normal = skinVertex->Normal; + + isDone = true; + break; + } } if (isDone) @@ -765,17 +772,23 @@ namespace TEN::Renderer { auto* parentVertex = &_moveablesVertices[parentBucket->StartVertex + v2]; - auto vertex1 = _moveablesVertices[currentBucket.StartVertex + v1].Position + currentBone->GlobalTranslation; - auto vertex2 = _moveablesVertices[parentBucket->StartVertex + v2].Position + parentBone->GlobalTranslation; + int x1 = _moveablesVertices[currentBucket.StartVertex + v1].Position.x + currentBone->GlobalTranslation.x; + int y1 = _moveablesVertices[currentBucket.StartVertex + v1].Position.y + currentBone->GlobalTranslation.y; + int z1 = _moveablesVertices[currentBucket.StartVertex + v1].Position.z + currentBone->GlobalTranslation.z; + + int x2 = _moveablesVertices[parentBucket->StartVertex + v2].Position.x + parentBone->GlobalTranslation.x; + int y2 = _moveablesVertices[parentBucket->StartVertex + v2].Position.y + parentBone->GlobalTranslation.y; + int z2 = _moveablesVertices[parentBucket->StartVertex + v2].Position.z + parentBone->GlobalTranslation.z; // FIXME: If a tolerance is used, a strange bug occurs where certain vertices don't connect. -- Lwmte, 14.12.2024 - if (vertex1 != vertex2) - continue; - currentVertex->Bone = j; - currentVertex->Position = parentVertex->Position; - currentVertex->Normal = parentVertex->Normal; - break; + if (abs(x1 - x2) == 0 && abs(y1 - y2) == 0 && abs(z1 - z2) == 0) + { + currentVertex->Bone = j; + currentVertex->Position = parentVertex->Position; + currentVertex->Normal = parentVertex->Normal; + break; + } } } }