mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-18 15:36:02 +01:00
refactor(zones): global Zones
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
local glm = require 'glm'
|
local glm = require 'glm'
|
||||||
local zones = {}
|
Zones = {}
|
||||||
|
|
||||||
local function getTriangles(polygon)
|
local function getTriangles(polygon)
|
||||||
local extremes = { polygon.projectToAxis(polygon, vec(1, 0, 0)) }
|
local extremes = { polygon.projectToAxis(polygon, vec(1, 0, 0)) }
|
||||||
@@ -202,7 +202,7 @@ local function getTriangles(polygon)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function removeZone(self)
|
local function removeZone(self)
|
||||||
zones[self.id] = nil
|
Zones[self.id] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
local inside = {}
|
local inside = {}
|
||||||
@@ -216,7 +216,7 @@ CreateThread(function()
|
|||||||
table.wipe(inside)
|
table.wipe(inside)
|
||||||
insideCount = 0
|
insideCount = 0
|
||||||
|
|
||||||
for _, zone in pairs(zones) do
|
for _, zone in pairs(Zones) do
|
||||||
local contains = zone:contains(coords)
|
local contains = zone:contains(coords)
|
||||||
|
|
||||||
if contains then
|
if contains then
|
||||||
@@ -327,7 +327,7 @@ end
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
poly = function(data)
|
poly = function(data)
|
||||||
data.id = #zones + 1
|
data.id = #Zones + 1
|
||||||
data.thickness = data.thickness or 2
|
data.thickness = data.thickness or 2
|
||||||
data.polygon = glm.polygon.new(data.points)
|
data.polygon = glm.polygon.new(data.points)
|
||||||
data.coords = data.polygon:centroid()
|
data.coords = data.polygon:centroid()
|
||||||
@@ -339,12 +339,12 @@ return {
|
|||||||
data.debug = debugPoly
|
data.debug = debugPoly
|
||||||
end
|
end
|
||||||
|
|
||||||
zones[data.id] = data
|
Zones[data.id] = data
|
||||||
return data
|
return data
|
||||||
end,
|
end,
|
||||||
|
|
||||||
box = function(data)
|
box = function(data)
|
||||||
data.id = #zones + 1
|
data.id = #Zones + 1
|
||||||
data.thickness = data.size.z or 2
|
data.thickness = data.size.z or 2
|
||||||
data.rotation = quat(data.rotation or 0, vec3(0, 0, 1))
|
data.rotation = quat(data.rotation or 0, vec3(0, 0, 1))
|
||||||
data.polygon = (data.rotation * glm.polygon.new({
|
data.polygon = (data.rotation * glm.polygon.new({
|
||||||
@@ -361,12 +361,12 @@ return {
|
|||||||
data.debug = debugBox
|
data.debug = debugBox
|
||||||
end
|
end
|
||||||
|
|
||||||
zones[data.id] = data
|
Zones[data.id] = data
|
||||||
return data
|
return data
|
||||||
end,
|
end,
|
||||||
|
|
||||||
sphere = function(data)
|
sphere = function(data)
|
||||||
data.id = #zones + 1
|
data.id = #Zones + 1
|
||||||
data.radius = (data.radius or 2) + 0.0
|
data.radius = (data.radius or 2) + 0.0
|
||||||
data.remove = removeZone
|
data.remove = removeZone
|
||||||
data.contains = insideSphere
|
data.contains = insideSphere
|
||||||
@@ -375,7 +375,7 @@ return {
|
|||||||
data.debug = debugSphere
|
data.debug = debugSphere
|
||||||
end
|
end
|
||||||
|
|
||||||
zones[data.id] = data
|
Zones[data.id] = data
|
||||||
return data
|
return data
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user