Remove ssaTri, bullet movement is broken
This commit is contained in:
+3
-51
@@ -191,50 +191,6 @@ newProjectileKey = IM.newKey . _props
|
||||
{- | Finds unused creature key. -}
|
||||
newCrKey :: World -> Int
|
||||
newCrKey = IM.newKey . _creatures
|
||||
{- | TODO: determine precisely what this does. -}
|
||||
reflectPointCreature :: Point2 -> Point2 -> Creature -> Maybe (Point2, Point2, Int)
|
||||
reflectPointCreature p1 p2 cr = case intersectCircSegFirst (_crPos cr) (_crRad cr) p1 p2 of
|
||||
Nothing -> Nothing
|
||||
Just a -> Just
|
||||
( p1
|
||||
, errorNormalizeV 35 (ssaTriPoint p2 (_crPos cr) p1 (_crRad cr) -.- _crPos cr)
|
||||
+.+ (_crPos cr -.- _crOldPos cr)
|
||||
, _crID cr)
|
||||
{- | TODO: determine precisely what this does. -}
|
||||
reflectPointCreatures :: Point2 -> Point2 -> IM.IntMap Creature -> Maybe (Point2,Point2,Int)
|
||||
reflectPointCreatures p1 p2 cs
|
||||
= safeMinimumOn f
|
||||
$ IM.mapMaybe (reflectPointCreature p1 p2) cs
|
||||
where
|
||||
f (a,_,_) = magV (a -.- p1)
|
||||
{- | TODO: determine precisely what this does. -}
|
||||
reflectCircCreature
|
||||
:: Float -- ^ Radius
|
||||
-> Point2 -- ^ Start point
|
||||
-> Point2 -- ^ End point
|
||||
-> Creature
|
||||
-> Maybe (Point2, Point2, Int)
|
||||
reflectCircCreature rad p1 p2 cr = case intersectCircSegFirst (_crPos cr) (rad + _crRad cr) p1 p2 of
|
||||
Nothing -> Nothing
|
||||
Just _ -> Just
|
||||
( p1
|
||||
, errorNormalizeV 37 (ssaTriPoint p2 (_crPos cr) p1 (_crRad cr) -.- _crPos cr)
|
||||
+.+ (_crPos cr -.- _crOldPos cr)
|
||||
, _crID cr
|
||||
)
|
||||
{- | TODO: determine precisely what this does. -}
|
||||
reflectCircCreatures
|
||||
:: Float -- ^ Radius
|
||||
-> Point2 -- ^ Start point
|
||||
-> Point2 -- ^ End point
|
||||
-> IM.IntMap Creature
|
||||
-> Maybe (Point2,Point2,Int)
|
||||
reflectCircCreatures rad p1 p2 cs
|
||||
= safeMinimumOn f
|
||||
$ IM.mapMaybe (reflectCircCreature rad p1 p2) cs
|
||||
where
|
||||
f (a,_,_) = magV (a -.- p1)
|
||||
|
||||
-- | collides a point with forcefields
|
||||
-- if found, returns point of collision, deflection if required, and the id
|
||||
collidePointFFs :: a
|
||||
@@ -336,12 +292,10 @@ collidePointWallsNorm p1 p2 ws
|
||||
f (a,_) = magV (p1 -.- a)
|
||||
-- | Returns the first creature, if any, that a point intersects with.
|
||||
collidePointCreatures :: Point2 -> Point2 -> IM.IntMap Creature -> Maybe Int
|
||||
collidePointCreatures p1 p2 crs
|
||||
= fmap fst
|
||||
collidePointCreatures p1 p2 = fmap fst
|
||||
. safeMinimumOn snd
|
||||
. IM.toList
|
||||
. IM.mapMaybe (\x -> fmap (dist p1) $ intersectCircSegFirst (_crPos x) (_crRad x) p1 p2)
|
||||
$ crs
|
||||
. IM.mapMaybe (\x -> dist p1 <$> intersectCircSegFirst (_crPos x) (_crRad x) p1 p2)
|
||||
-- | As for 'collidePointCreatures', only increases the radius of creatures by a
|
||||
--fixed amount, thus collides a moving circle with creaures.
|
||||
collideCircCreatures :: Point2 -> Point2 -> Float -> IM.IntMap Creature -> Maybe Int
|
||||
@@ -350,12 +304,10 @@ collideCircCreatures p1 p2 rad = collidePointCreatures p1 p2 . fmap (crRad +~ ra
|
||||
-- | Returns the first creature id, if any, that a point intersects with, gives point
|
||||
--in creature on line.
|
||||
collidePointCrsPoint :: Point2 -> Point2 -> IM.IntMap Creature -> Maybe (Point2,Int)
|
||||
collidePointCrsPoint p1 p2 crs
|
||||
= fmap f
|
||||
collidePointCrsPoint p1 p2 = fmap f
|
||||
. safeMinimumOn (dist p1 . snd)
|
||||
. IM.toList
|
||||
. IM.mapMaybe (\x -> intersectCircSegFirst (_crPos x) (_crRad x) p1 p2)
|
||||
$ crs
|
||||
where
|
||||
f (cID,p) = (p,cID)
|
||||
{- | Finds the first creature hit on a line.
|
||||
|
||||
Reference in New Issue
Block a user