preparation for functorising quad tree
This commit is contained in:
@@ -87,6 +87,11 @@ end
|
||||
|
||||
structure CollisionTree =
|
||||
struct
|
||||
(* ignoreData = any data we find in grid but which doesn't concern us
|
||||
* so we omit from tree, to reduce number of items in tree,
|
||||
* and therefore decrease the constant in O(n) *)
|
||||
val ignoreData = 0
|
||||
|
||||
local
|
||||
fun loopYAxis (x, y, eX, eY, yAxis, col) =
|
||||
if y > eY orelse y >= Vector.length yAxis then
|
||||
@@ -129,12 +134,18 @@ struct
|
||||
let
|
||||
val yAxis = Vector.sub (grid, x)
|
||||
val data = Vector.sub (yAxis, y)
|
||||
in
|
||||
if data = ignoreData then
|
||||
bintree
|
||||
else
|
||||
let
|
||||
val ex = x + size
|
||||
val ey = y + size
|
||||
val item = {x = x, y = y, ex = ex, ey = ey, data = data}
|
||||
in
|
||||
BinTree.insert (item, bintree)
|
||||
end
|
||||
end
|
||||
else
|
||||
let
|
||||
(* handles odd-number divisions.
|
||||
@@ -164,9 +175,6 @@ struct
|
||||
, xClickPoints
|
||||
, yClickPoints
|
||||
) ({x, ex, y, ey, data}, acc) =
|
||||
if data = 0 then
|
||||
acc
|
||||
else
|
||||
let
|
||||
val ex = if ex = x then x + 1 else ex
|
||||
val ey = if ey = y then y + 1 else ey
|
||||
|
||||
Reference in New Issue
Block a user