when generating collision string, map 'squares' vector to a new vector which treats all visible (non-transparent) colours the same. This allows us to ignore colour differences when generating the collision string, which is good because the colour of a pixel doesn't make a difference to collision detection.
This commit is contained in:
@@ -629,8 +629,9 @@ struct
|
||||
fun mapItem (item as {r, g, b, a}) =
|
||||
if shouldIgnoreData item then item else {r = 1, g = 1, b = 1, a = 1}
|
||||
|
||||
fun mapGrid grid =
|
||||
Vector.map (fn yAxis => Vector.map (fn item => mapItem item) yAxis) grid
|
||||
fun mapYAxis yAxis = Vector.map mapItem yAxis
|
||||
|
||||
fun mapGrid grid = Vector.map mapYAxis grid
|
||||
|
||||
fun toCollisionStringFolder (scale, maxWidth, maxHeight) ({x, ex, y, ey, data = _}, acc) =
|
||||
let
|
||||
@@ -664,6 +665,7 @@ struct
|
||||
|
||||
fun toCollisionString (squares, canvasWidth, canvasHeight, scale) =
|
||||
let
|
||||
val squares = mapGrid squares
|
||||
val scale = if scale = 0 then 1 else scale
|
||||
val size = Int.max (canvasWidth, canvasHeight)
|
||||
val qtree = buildTree (0, 0, size, squares)
|
||||
|
||||
Reference in New Issue
Block a user