2020-12-27 04:19:51 +00:00
|
|
|
module Classes.Physics.Collidible where
|
|
|
|
|
|
|
|
import Linear
|
|
|
|
|
2020-12-27 04:30:57 +00:00
|
|
|
-- internal imports
|
|
|
|
|
|
|
|
import Classes.Physics.Mass
|
|
|
|
|
2020-12-27 04:19:51 +00:00
|
|
|
-- | Typeclass for implementing collision results on objects.
|
|
|
|
class Mass c => Collidible c where
|
|
|
|
|
|
|
|
-- | returns the top left and bottom right corners relative to the objects
|
|
|
|
-- positional vector of the axis alignes bounding box (AABB).
|
|
|
|
boundary
|
|
|
|
:: c -- Object
|
|
|
|
-> ( V2 Double -- Top left corner of AABB relative to position
|
|
|
|
, V2 Double -- Bottom right corner of AABB relative to position
|
|
|
|
)
|
|
|
|
-- | This Function is called for every collision for both colliding objects.
|
|
|
|
collide
|
2020-12-27 04:30:57 +00:00
|
|
|
:: c -- ^ Original object
|
2020-12-27 04:19:51 +00:00
|
|
|
-> c -- ^ Collision partner
|
|
|
|
-> c -- ^ Updated original object
|