@@ -13,7 +13,7 @@ local glm = require 'glm'
13
13
--- @field __type ' poly' | ' sphere' | ' box'
14
14
--- @field remove fun ( self : self )
15
15
--- @field setDebug fun ( self : CZone , enable ?: boolean , colour ?: vector )
16
- --- @field contains fun ( self : CZone , coords ?: vector3 ): boolean
16
+ --- @field contains fun ( self : CZone , coords ?: vector3 , updateDistance ?: boolean ): boolean
17
17
18
18
--- @type table<number , CZone>
19
19
local Zones = {}
@@ -132,7 +132,7 @@ CreateThread(function()
132
132
local zone = nearbyZones [i ]
133
133
134
134
if zone .insideZone then
135
- local contains = zone . thickness and glm_polygon_contains ( zone . polygon , coords , zone . thickness / 4 ) or # ( zone . coords - coords ) < zone . radius
135
+ local contains = zone : contains ( coords , true )
136
136
137
137
if not contains then
138
138
zone .insideZone = false
@@ -148,14 +148,7 @@ CreateThread(function()
148
148
149
149
for i = 1 , # zones do
150
150
local zone = zones [i ]
151
- local radius , contains = zone .radius , nil
152
- zone .distance = # (zone .coords - coords )
153
-
154
- if radius then
155
- contains = zone .distance < radius
156
- else
157
- contains = glm_polygon_contains (zone .polygon , coords , zone .thickness / 4 )
158
- end
151
+ local contains = zone :contains (coords , true )
159
152
160
153
if contains then
161
154
if not zone .insideZone then
@@ -273,8 +266,12 @@ local function contains(self, coords)
273
266
return glm_polygon_contains (self .polygon , coords , self .thickness / 4 )
274
267
end
275
268
276
- local function insideSphere (self , coords )
277
- return # (self .coords - coords ) < self .radius
269
+ local function insideSphere (self , coords , updateDistance )
270
+ local distance = # (self .coords - coords ) < self .radius
271
+
272
+ if updateDistance then self .distance = distance end
273
+
274
+ return distance
278
275
end
279
276
280
277
local function convertToVector (coords )
0 commit comments