From c869107f4aa66f0aadf6d0b1fac0cfe1bb49e006 Mon Sep 17 00:00:00 2001 From: Sorata <39014375+q8X@users.noreply.github.com> Date: Thu, 22 May 2025 00:09:40 +0300 Subject: [PATCH 1/2] fixes #636 --- [editor]/editor_main/client/gridlines.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/[editor]/editor_main/client/gridlines.lua b/[editor]/editor_main/client/gridlines.lua index b6f0ab3b6..4d7d5d68f 100644 --- a/[editor]/editor_main/client/gridlines.lua +++ b/[editor]/editor_main/client/gridlines.lua @@ -34,6 +34,22 @@ local function renderGridlines() local camX,camY,camZ = getCameraMatrix() --Work out our line thickness local thickness = (100/getDistanceBetweenPoints3D(camX,camY,camZ,x,y,z)) * MAX_THICKNESS + + --Apply the adjustment for non-centered bounding box according to c++ implementaion + --https://github.com/multitheftauto/mtasa-blue/blob/88d303c0bbcc0ed4fee958df2d16ace562ce0108/Client/mods/deathmatch/logic/CClientStreamElement.cpp#L224 + + local halfCenterX = (minX + maxX) * 0.25 + local halfCenterY = (minY + maxY) * 0.25 + local halfCenterZ = (minZ + maxZ) * 0.25 + + --subtracting half center + minX = minX - halfCenterX + minY = minY - halfCenterY + minZ = minZ - halfCenterZ + maxX = maxX - halfCenterX + maxY = maxY - halfCenterY + maxZ = maxZ - halfCenterZ + -- local elementMatrix = (getElementMatrix(attachedToElement) and not ignoreMatrix[getElementType(attachedToElement)]) and matrix(getElementMatrix(attachedToElement)) From 157d957ead1bd48c3276e7fca938c8c15df4705f Mon Sep 17 00:00:00 2001 From: Sorata <39014375+q8X@users.noreply.github.com> Date: Thu, 22 May 2025 00:24:31 +0300 Subject: [PATCH 2/2] lint --- [editor]/editor_main/client/gridlines.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/[editor]/editor_main/client/gridlines.lua b/[editor]/editor_main/client/gridlines.lua index 4d7d5d68f..15590b892 100644 --- a/[editor]/editor_main/client/gridlines.lua +++ b/[editor]/editor_main/client/gridlines.lua @@ -34,14 +34,14 @@ local function renderGridlines() local camX,camY,camZ = getCameraMatrix() --Work out our line thickness local thickness = (100/getDistanceBetweenPoints3D(camX,camY,camZ,x,y,z)) * MAX_THICKNESS - + --Apply the adjustment for non-centered bounding box according to c++ implementaion --https://github.com/multitheftauto/mtasa-blue/blob/88d303c0bbcc0ed4fee958df2d16ace562ce0108/Client/mods/deathmatch/logic/CClientStreamElement.cpp#L224 - + local halfCenterX = (minX + maxX) * 0.25 local halfCenterY = (minY + maxY) * 0.25 local halfCenterZ = (minZ + maxZ) * 0.25 - + --subtracting half center minX = minX - halfCenterX minY = minY - halfCenterY @@ -49,7 +49,7 @@ local function renderGridlines() maxX = maxX - halfCenterX maxY = maxY - halfCenterY maxZ = maxZ - halfCenterZ - + -- local elementMatrix = (getElementMatrix(attachedToElement) and not ignoreMatrix[getElementType(attachedToElement)]) and matrix(getElementMatrix(attachedToElement))