Safe Haskell | None |
---|---|
Language | Haskell2010 |
Classes for data structures that can behave like a "world" of physical objects.
- class Physical p where
- class Physical p => Contactable p where
- class (Ord k, Contactable o) => PhysicsWorld k w o | w -> k o where
- wAdvance :: PhysicsWorld k w o => Double -> w -> w
- woUpdateShape :: Contactable o => o -> o
- type External = Double -> PhysicalObj -> PhysicalObj
- wApplyExternals :: PhysicsWorld k w o => [External] -> Double -> w -> w
Documentation
class Physical p where Source #
Class for objects with physical properties.
woPhys :: Functor f => (PhysicalObj -> f PhysicalObj) -> p -> f p Source #
Lens for the embedded PhysicalObj
class Physical p => Contactable p where Source #
Class for objects that can be in contact with each other.
woMu :: Functor f => (Double -> f Double) -> p -> f p Source #
Lens for embedded coefficient of friction "mu"
woShape :: Functor f => (Shape -> f Shape) -> p -> f p Source #
Lens for embedded contact shape
woMuShape :: Functor f => ((Double, Shape) -> f (Double, Shape)) -> p -> f p Source #
Lens for embedded pair of (coefficient of friction, contact shape)
Contactable (WorldObj a) Source # | |
class (Ord k, Contactable o) => PhysicsWorld k w o | w -> k o where Source #
Class for worlds (:: w) inhabited by physical objects (:: o) each uniquely identified by a key (:: k)
Keys of all the world's inhabitants
wObj :: k -> Traversal' w o Source #
Traversal
of inhabitants with a given key
wPair :: (k, k) -> Traversal' w (o, o) Source #
Traversal'
of pairs of inhabitants with a given pair of keys
wObjs :: IndexedTraversal' k w o Source #
IndexedTraversal'
of all inhabitants
Contactable a => PhysicsWorld Int (World a) a Source # | |
:: PhysicsWorld k w o | |
=> Double | Time delta |
-> w | |
-> w |
Advance the physical state of the world by a given time delta using each inhabitant's current velocity.
woUpdateShape :: Contactable o => o -> o Source #
Update the shape of an object to match its current physical state.
By keeping all shapes in world space, we ensure that each shape only needs to be transformed once per frame.
type External = Double -> PhysicalObj -> PhysicalObj Source #
An External
is a non-constraint effect (e.g. gravity) on physical objects.
wApplyExternals :: PhysicsWorld k w o => [External] -> Double -> w -> w Source #
Apply External
effects to the objects in a world.
This happens each frame before constraints are created and solved.