a bit of refactoring for quad tree's 'toTriangles' function
This commit is contained in:
@@ -236,13 +236,12 @@ 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
|
||||||
|
fun loop (windowWidth, windowHeight, squares, acc) =
|
||||||
case squares of
|
case squares of
|
||||||
{x, y, ex, ey, data = _} :: tl =>
|
{x, y, ex, ey, data = _} :: tl =>
|
||||||
let
|
let
|
||||||
@@ -253,7 +252,11 @@ struct
|
|||||||
|
|
||||||
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