Skip to content

Commit 781c465

Browse files
committed
removed collision zones
1 parent 5cd5e2c commit 781c465

File tree

1 file changed

+0
-69
lines changed

1 file changed

+0
-69
lines changed

g3d/collisions.lua

-69
Original file line numberDiff line numberDiff line change
@@ -440,75 +440,6 @@ function collisions:capsuleIntersection(tip_x, tip_y, tip_z, base_x, base_y, bas
440440
)
441441
end
442442

443-
function collisions:createCollisionZones(zoneSize)
444-
local aabb = self:generateAABB()
445-
446-
local min_1 = math.floor(aabb.min[1]/zoneSize)*zoneSize
447-
local min_2 = math.floor(aabb.min[2]/zoneSize)*zoneSize
448-
local min_3 = math.floor(aabb.min[3]/zoneSize)*zoneSize
449-
450-
local max_1 = math.floor(aabb.max[1]/zoneSize)*zoneSize
451-
local max_2 = math.floor(aabb.max[2]/zoneSize)*zoneSize
452-
local max_3 = math.floor(aabb.max[3]/zoneSize)*zoneSize
453-
454-
local translation_x = self.translation[1]
455-
local translation_y = self.translation[2]
456-
local translation_z = self.translation[3]
457-
local scale_x = self.scale[1]
458-
local scale_y = self.scale[2]
459-
local scale_z = self.scale[3]
460-
local verts = self.verts
461-
462-
local zones = {}
463-
for x=min_1, max_1, zoneSize do
464-
for y=min_2, max_2, zoneSize do
465-
for z=min_3, max_3, zoneSize do
466-
local hash = x .. ", " .. y .. ", " .. z
467-
468-
for v=1, #verts, 3 do
469-
local n_x, n_y, n_z = vectorNormalize(
470-
verts[v][6]*scale_x,
471-
verts[v][7]*scale_x,
472-
verts[v][8]*scale_x
473-
)
474-
475-
local inside = triangleAABB(
476-
verts[v][1]*scale_x + translation_x,
477-
verts[v][2]*scale_y + translation_y,
478-
verts[v][3]*scale_z + translation_z,
479-
verts[v+1][1]*scale_x + translation_x,
480-
verts[v+1][2]*scale_y + translation_y,
481-
verts[v+1][3]*scale_z + translation_z,
482-
verts[v+2][1]*scale_x + translation_x,
483-
verts[v+2][2]*scale_y + translation_y,
484-
verts[v+2][3]*scale_z + translation_z,
485-
n_x, n_y, n_z,
486-
x,y,z,
487-
x+zoneSize,y+zoneSize,z+zoneSize
488-
)
489-
490-
if inside then
491-
if not zones[hash] then
492-
zones[hash] = {}
493-
end
494-
495-
table.insert(zones[hash], verts[v])
496-
table.insert(zones[hash], verts[v+1])
497-
table.insert(zones[hash], verts[v+2])
498-
end
499-
end
500-
501-
if zones[hash] then
502-
print(hash, #zones[hash])
503-
end
504-
end
505-
end
506-
end
507-
508-
self.zones = zones
509-
return zones
510-
end
511-
512443
----------------------------------------------------------------------------------------------------
513444
-- AABB functions
514445
----------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)