Restore MT 5.4 compatibility

This commit is contained in:
MrRar 2024-02-19 20:17:38 -06:00
parent 725d199191
commit a191d24125
3 changed files with 11 additions and 11 deletions

View File

@ -4,9 +4,9 @@
-- using Bresenham's Algorithm -- using Bresenham's Algorithm
-- Converted from the original to Lua -- Converted from the original to Lua
function edit.calculate_line_points(p1, p2) function edit.calculate_line_points(p1, p2)
p1 = vector.copy(p1) p1 = table.copy(p1)
p2 = vector.copy(p2) p2 = table.copy(p2)
local output = {vector.copy(p1)} local output = {table.copy(p1)}
local d = vector.apply(vector.subtract(p1, p2), math.abs) local d = vector.apply(vector.subtract(p1, p2), math.abs)
local s = vector.new( local s = vector.new(
p2.x > p1.x and 1 or -1, p2.x > p1.x and 1 or -1,
@ -30,7 +30,7 @@ function edit.calculate_line_points(p1, p2)
end end
n1 = n1 + 2 * d.y n1 = n1 + 2 * d.y
n2 = n2 + 2 * d.z n2 = n2 + 2 * d.z
table.insert(output, vector.copy(p1)) table.insert(output, table.copy(p1))
end end
-- Driving axis is Y-axis -- Driving axis is Y-axis
@ -49,7 +49,7 @@ function edit.calculate_line_points(p1, p2)
end end
n1 = n1 + 2 * d.x n1 = n1 + 2 * d.x
n2 = n2 + 2 * d.z n2 = n2 + 2 * d.z
table.insert(output, vector.copy(p1)) table.insert(output, table.copy(p1))
end end
-- Driving axis is Z-axis -- Driving axis is Z-axis
@ -68,7 +68,7 @@ function edit.calculate_line_points(p1, p2)
end end
n1 = n1 + 2 * d.y n1 = n1 + 2 * d.y
n2 = n2 + 2 * d.x n2 = n2 + 2 * d.x
table.insert(output, vector.copy(p1)) table.insert(output, table.copy(p1))
end end
end end
return output return output

View File

@ -34,8 +34,8 @@ local function ray_intersects_triangle(ray_origin, ray_vector, vertex_a, vertex_
end end
function edit.calculate_triangle_points(a, b, c) function edit.calculate_triangle_points(a, b, c)
local bounding_box_min = vector.copy(a) local bounding_box_min = table.copy(a)
local bounding_box_max = vector.copy(a) local bounding_box_max = table.copy(a)
for index, axis in pairs({"x", "y", "z"}) do for index, axis in pairs({"x", "y", "z"}) do
bounding_box_min[axis] = math.min(a[axis], b[axis], c[axis]) bounding_box_min[axis] = math.min(a[axis], b[axis], c[axis])
bounding_box_max[axis] = math.max(a[axis], b[axis], c[axis]) bounding_box_max[axis] = math.max(a[axis], b[axis], c[axis])
@ -63,7 +63,7 @@ function edit.calculate_triangle_points(a, b, c)
-- Switch from local to global coordinate system. -- Switch from local to global coordinate system.
-- Also works the same to convert local to global coordinate system. -- Also works the same to convert local to global coordinate system.
local function swap_coord_sys(v) local function swap_coord_sys(v)
v = vector.copy(v) v = table.copy(v)
local old_selected = v[selected_axis] local old_selected = v[selected_axis]
v[selected_axis] = v.y v[selected_axis] = v.y
v.y = old_selected v.y = old_selected

View File

@ -165,8 +165,8 @@ local function update_polygon_preview(player, marker_pos_list, show_polygon_hud)
local player_data = edit.player_data[player] local player_data = edit.player_data[player]
local show_full_preview = true local show_full_preview = true
local bounding_box_min = vector.copy(marker_pos_list[1]) local bounding_box_min = table.copy(marker_pos_list[1])
local bounding_box_max = vector.copy(marker_pos_list[1]) local bounding_box_max = table.copy(marker_pos_list[1])
for index, axis in pairs({"x", "y", "z"}) do for index, axis in pairs({"x", "y", "z"}) do
for i, pos in ipairs(marker_pos_list) do for i, pos in ipairs(marker_pos_list) do
bounding_box_min[axis] = math.min(bounding_box_min[axis], pos[axis]) bounding_box_min[axis] = math.min(bounding_box_min[axis], pos[axis])