Copyright | Plow Technologies LLC |
---|---|
License | MIT License |
Maintainer | Scott Murphy |
Safe Haskell | None |
Language | Haskell2010 |
Normal collision detection proceeds by checking one model against another, one at a time.
If you are dealing with a discretized grid you can simulataneously check collissions against all models simultaneously by projecting your models into a Binary grid. Then by looking for an empty intersection set, collissions are avoided and a new world is returned.
Algorithmic complexity is determined by the grid size only.
the theory is to create a Shadow model, that is a rectangular projection into bits.
Then you position that projection onto a World, which is a 2d bit array.
|
- addModelToWorld :: Int -> Int -> ShadowModel -> World -> Either String World
- newtype ShadowModel = ShadowModel {
- _unshadowModel :: BitArray (Int, Int)
- showShadowBoxModel :: ShadowModel -> String
- shadowRect :: Int -> Int -> ShadowModel
- showWorld :: World -> String
- newtype World = World {
- _unWorldShadow :: BitArray (Int, Int)
- (!?) :: World -> (Int, Int) -> Maybe Bool
- emptyWorld :: Int -> Int -> World
- data Patchable = Patchable {}
- makePatchable :: Int -> Int -> ShadowModel -> World -> Either String Patchable
- addPatchToWorld :: Patchable -> World
- trueIdx :: (Int, Int)
- falseIdx :: (Int, Int)
- twobitArray :: BitArray (Int, Int)
Documentation
addModelToWorld :: Int -> Int -> ShadowModel -> World -> Either String World Source
Primary use Function addModelToWorld can be used with a model to create a world that can have more models consistently added to it
newtype ShadowModel Source
Shadow Models are the shapes that are inserted into a world at an origin
ShadowModel | |
|
showShadowBoxModel :: ShadowModel -> String Source
Pretty Print a ShadowBox
shadowRect :: Int -> Int -> ShadowModel Source
Build a rectangle shadow of a given width and height Enter the width and height in bits
World shadows are either created empty or are built up by inserting shadows into them. They are correct by construction because these are the only way to build them
World | |
|
emptyWorld :: Int -> Int -> World Source
Build a world with no shadows The width and height are in pixel length
overlapping if any bit is 1 inff both worlds, an intersection is reported as true
makePatchable :: Int -> Int -> ShadowModel -> World -> Either String Patchable Source
Make a patchable world, grouping world and model together This runs all the boundary tests so that patches can be applied quickly
addPatchToWorld :: Patchable -> World Source
place a shadow model at a given position, assumes the model is represented in a square matrix the matrix that is projected is actually just [0,1], it uses it as an intermediate while reading values out of sm. This allows us to control a true or false value without having to convert to a list
twobitArray :: BitArray (Int, Int) Source
The index mapping in bit array makes fora common pattern to convert from one array into another using an intermediate structure and exploiting the fact that each array can only be True or false. ixmap can be used to project one array onto another.