shapes-0.1.0.0: physics engine and other tools for 2D shapes

Safe HaskellNone
LanguageHaskell2010

Physics.Broadphase.Grid

Synopsis

Documentation

data Grid Source #

The grid is indexed in row-major order:

3 4 5 0 1 2

(where X is horizontal and Y is vertical)

  • The grid is only used for shape queries, so it should only contain AABBs.
  • We may want a reverse-lookup from shape ID to grid squares in the future.

Constructors

Grid 

Instances

Eq Grid Source # 

Methods

(==) :: Grid -> Grid -> Bool #

(/=) :: Grid -> Grid -> Bool #

Show Grid Source # 

Methods

showsPrec :: Int -> Grid -> ShowS #

show :: Grid -> String #

showList :: [Grid] -> ShowS #

Generic Grid Source # 

Associated Types

type Rep Grid :: * -> * #

Methods

from :: Grid -> Rep Grid x #

to :: Rep Grid x -> Grid #

NFData Grid Source # 

Methods

rnf :: Grid -> () #

type Rep Grid Source # 
type Rep Grid = D1 * (MetaData "Grid" "Physics.Broadphase.Grid" "shapes-0.1.0.0-E6UUiYRpOc15rGTlEn6KOE" False) (C1 * (MetaCons "Grid" PrefixI True) ((:*:) * (S1 * (MetaSel (Just Symbol "_gridSquares") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (IntMap (IntMap TaggedAabb)))) ((:*:) * (S1 * (MetaSel (Just Symbol "_gridX") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 * GridAxis)) (S1 * (MetaSel (Just Symbol "_gridY") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 * GridAxis)))))

data GridAxis Source #

Constructors

GridAxis 

Instances

Eq GridAxis Source # 
Show GridAxis Source # 
Generic GridAxis Source # 

Associated Types

type Rep GridAxis :: * -> * #

Methods

from :: GridAxis -> Rep GridAxis x #

to :: Rep GridAxis x -> GridAxis #

NFData GridAxis Source # 

Methods

rnf :: GridAxis -> () #

type Rep GridAxis Source # 
type Rep GridAxis = D1 * (MetaData "GridAxis" "Physics.Broadphase.Grid" "shapes-0.1.0.0-E6UUiYRpOc15rGTlEn6KOE" False) (C1 * (MetaCons "GridAxis" PrefixI True) ((:*:) * (S1 * (MetaSel (Just Symbol "_gridLength") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 * Int)) ((:*:) * (S1 * (MetaSel (Just Symbol "_gridUnit") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 * Double)) (S1 * (MetaSel (Just Symbol "_gridOrigin") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 * Double)))))

data TaggedAabb Source #

Constructors

TaggedAabb 

Instances

Eq TaggedAabb Source # 
Show TaggedAabb Source # 
Generic TaggedAabb Source # 

Associated Types

type Rep TaggedAabb :: * -> * #

NFData TaggedAabb Source # 

Methods

rnf :: TaggedAabb -> () #

type Rep TaggedAabb Source # 
type Rep TaggedAabb = D1 * (MetaData "TaggedAabb" "Physics.Broadphase.Grid" "shapes-0.1.0.0-E6UUiYRpOc15rGTlEn6KOE" False) (C1 * (MetaCons "TaggedAabb" PrefixI True) ((:*:) * (S1 * (MetaSel (Just Symbol "_taggedStatic") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 * Bool)) (S1 * (MetaSel (Just Symbol "_taggedBox") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 * Aabb))))

toGrid :: (PhysicsWorld Int w o, WorldObj a ~ o) => (GridAxis, GridAxis) -> w -> Grid Source #

allPairs :: [a] -> [(a, a)] Source #

uniq :: Eq a => [a] -> [a] Source #

flattenIndex :: Grid -> (Int, Int) -> Int Source #

Flatten a pair of axial indices to a single grid index.

flattenIndex' :: GridAxis -> (Int, Int) -> Int Source #

Flatten a pair of axial indices to a single grid index.

pointIndex :: Grid -> (Double, Double) -> Int Source #

Flattened grid index of a given point.

axialIndex :: GridAxis -> Double -> Int Source #

Index along a single axis.

boxIndices :: (GridAxis, GridAxis) -> Aabb -> [Int] Source #

All flattened grid indices that match a given Aabb.