Skip to content

Commit 117759a

Browse files
authored
editor: Fix for misaligned bounding box (#638)
1 parent 04e9040 commit 117759a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

[editor]/editor_main/client/gridlines.lua

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,22 @@ local function renderGridlines()
3434
local camX,camY,camZ = getCameraMatrix()
3535
--Work out our line thickness
3636
local thickness = (100/getDistanceBetweenPoints3D(camX,camY,camZ,x,y,z)) * MAX_THICKNESS
37+
38+
--Apply the adjustment for non-centered bounding box according to c++ implementaion
39+
--https://github.com/multitheftauto/mtasa-blue/blob/88d303c0bbcc0ed4fee958df2d16ace562ce0108/Client/mods/deathmatch/logic/CClientStreamElement.cpp#L224
40+
41+
local halfCenterX = (minX + maxX) * 0.25
42+
local halfCenterY = (minY + maxY) * 0.25
43+
local halfCenterZ = (minZ + maxZ) * 0.25
44+
45+
--subtracting half center
46+
minX = minX - halfCenterX
47+
minY = minY - halfCenterY
48+
minZ = minZ - halfCenterZ
49+
maxX = maxX - halfCenterX
50+
maxY = maxY - halfCenterY
51+
maxZ = maxZ - halfCenterZ
52+
3753
--
3854
local elementMatrix = (getElementMatrix(attachedToElement) and not ignoreMatrix[getElementType(attachedToElement)])
3955
and matrix(getElementMatrix(attachedToElement))

0 commit comments

Comments
 (0)