Skip to content

Commit

Permalink
refactor(zones): global Zones
Browse files Browse the repository at this point in the history
  • Loading branch information
thelindat committed May 7, 2022
1 parent ce3f916 commit 55bfa7c
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions imports/zones/client.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local glm = require 'glm'
local zones = {}
Zones = {}

local function getTriangles(polygon)
local extremes = { polygon.projectToAxis(polygon, vec(1, 0, 0)) }
Expand Down Expand Up @@ -202,7 +202,7 @@ local function getTriangles(polygon)
end

local function removeZone(self)
zones[self.id] = nil
Zones[self.id] = nil
end

local inside = {}
Expand All @@ -216,7 +216,7 @@ CreateThread(function()
table.wipe(inside)
insideCount = 0

for _, zone in pairs(zones) do
for _, zone in pairs(Zones) do
local contains = zone:contains(coords)

if contains then
Expand Down Expand Up @@ -327,7 +327,7 @@ end

return {
poly = function(data)
data.id = #zones + 1
data.id = #Zones + 1
data.thickness = data.thickness or 2
data.polygon = glm.polygon.new(data.points)
data.coords = data.polygon:centroid()
Expand All @@ -339,12 +339,12 @@ return {
data.debug = debugPoly
end

zones[data.id] = data
Zones[data.id] = data
return data
end,

box = function(data)
data.id = #zones + 1
data.id = #Zones + 1
data.thickness = data.size.z or 2
data.rotation = quat(data.rotation or 0, vec3(0, 0, 1))
data.polygon = (data.rotation * glm.polygon.new({
Expand All @@ -361,12 +361,12 @@ return {
data.debug = debugBox
end

zones[data.id] = data
Zones[data.id] = data
return data
end,

sphere = function(data)
data.id = #zones + 1
data.id = #Zones + 1
data.radius = (data.radius or 2) + 0.0
data.remove = removeZone
data.contains = insideSphere
Expand All @@ -375,7 +375,7 @@ return {
data.debug = debugSphere
end

zones[data.id] = data
Zones[data.id] = data
return data
end,
}

0 comments on commit 55bfa7c

Please sign in to comment.