a bit of refactoring for quad tree's 'toTriangles' function
This commit is contained in:
@@ -236,24 +236,27 @@ struct
|
|||||||
BinTree.insert (item, acc)
|
BinTree.insert (item, acc)
|
||||||
|
|
||||||
fun toList qtree =
|
fun toList qtree =
|
||||||
let
|
let val tree = foldWithDuplicates (insertItemIntoTree, qtree, BinTree.empty)
|
||||||
val tree = foldWithDuplicates (insertItemIntoTree, qtree, BinTree.empty)
|
in BinTree.toList (tree, [])
|
||||||
in
|
|
||||||
BinTree.toList (tree, [])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
fun toTriangles (windowWidth, windowHeight, squares, acc) =
|
local
|
||||||
case squares of
|
fun loop (windowWidth, windowHeight, squares, acc) =
|
||||||
{x, y, ex, ey, data = _} :: tl =>
|
case squares of
|
||||||
let
|
{x, y, ex, ey, data = _} :: tl =>
|
||||||
val startX = Ndc.fromPixelX (x, windowWidth, windowHeight)
|
let
|
||||||
val endX = Ndc.fromPixelX (ex, windowWidth, windowHeight)
|
val startX = Ndc.fromPixelX (x, windowWidth, windowHeight)
|
||||||
val startY = Ndc.fromPixelY (y, windowWidth, windowHeight)
|
val endX = Ndc.fromPixelX (ex, windowWidth, windowHeight)
|
||||||
val endY = Ndc.fromPixelY (ey, windowWidth, windowHeight)
|
val startY = Ndc.fromPixelY (y, windowWidth, windowHeight)
|
||||||
|
val endY = Ndc.fromPixelY (ey, windowWidth, windowHeight)
|
||||||
|
|
||||||
val acc = Ndc.ltrbToVertex (startX, startY, endX, endY) :: acc
|
val acc = Ndc.ltrbToVertex (startX, startY, endX, endY) :: acc
|
||||||
in
|
in
|
||||||
toTriangles (windowWidth, windowHeight, tl, acc)
|
loop (windowWidth, windowHeight, tl, acc)
|
||||||
end
|
end
|
||||||
| [] => Vector.concat acc
|
| [] => Vector.concat acc
|
||||||
|
in
|
||||||
|
fun toTriangles (windowWidth, windowHeight, squares) =
|
||||||
|
loop (windowWidth, windowHeight, squares, [])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user