progress with refactoring

This commit is contained in:
2025-07-06 03:21:18 +01:00
parent df5f326e36
commit ed64b464c8
2 changed files with 57 additions and 2 deletions

View File

@@ -225,8 +225,15 @@ struct
foldWithDuplicates (f, br, acc)
end
fun insertItemIntoTree (item, acc) =
BinTree.insert (item, acc)
fun insertItemIntoTree ignoreData (item, acc) =
if #data item = 0 then
(* ignore specific data by not inserting it into tree.
* May later functorise this quad tree,
* and allow different types of data
* to be ignored/stored in #data field. *)
acc
else
BinTree.insert (item, acc)
fun toList qtree =
let
@@ -234,4 +241,19 @@ struct
in
BinTree.toList (tree, [])
end
fun toTriangles (windowWidth, windowHeight, squares, acc) =
case squares of
{x, y, ex, ey, data = _} :: tl =>
let
val startX = Ndc.fromPixelX (x, windowWidth, windowHeight)
val endX = Ndc.fromPixelX (ex, 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
in
toTriangles (windowWidth, windowHeight, tl, acc)
end
| [] => Vector.concat acc
end