Stop bullets when they hit walls
This commit is contained in:
+3
-8
@@ -182,24 +182,19 @@ pHalf !a !b = 0.5 *.* (a +.+ b)
|
||||
-- segment.
|
||||
circOnSegNoEndpoints :: Point2 -> Point2 -> Point2 -> Float -> Bool
|
||||
{-# INLINE circOnSegNoEndpoints #-}
|
||||
circOnSegNoEndpoints !p1 !p2 !c !rad = isJustTrue (fmap (\p -> magV (p -.- c) < rad) y)
|
||||
circOnSegNoEndpoints !p1 !p2 !c !rad = intersectSegSegTest p1 p2 (c -.- thenormal) (c +.+ thenormal)
|
||||
where
|
||||
y = intersectSegLine p1 p2 c (c +.+ vNormal (p1 -.- p2))
|
||||
isJustTrue (Just True) = True
|
||||
isJustTrue _ = False
|
||||
thenormal = rad *.* vNormal (normalizeV $ p1 -.- p2)
|
||||
|
||||
-- | Test whether a circle is on a segment by intersecting a normal and testing
|
||||
-- the distance to the endpoints of the segment.
|
||||
circOnSeg :: Point2 -> Point2 -> Point2 -> Float -> Bool
|
||||
{-# INLINE circOnSeg #-}
|
||||
circOnSeg !p1 !p2 !c !rad = magV (p1 -.- c) <= rad
|
||||
|| magV (p2 -.- c) <= rad
|
||||
-- || isJustTrue (fmap (\p -> magV (p -.- c) < rad) y)
|
||||
|| intersectSegSegTest p1 p2 (c -.- thenormal) (c +.+ thenormal)
|
||||
where
|
||||
thenormal = rad *.* vNormal (normalizeV $ p1 -.- p2)
|
||||
y = intersectSegLine p1 p2 c (c +.+ vNormal (p1 -.- p2))
|
||||
isJustTrue (Just True) = True
|
||||
isJustTrue _ = False
|
||||
cylinderOnSeg :: Point3 -> Point3 -> Point3 -> Float -> Bool
|
||||
{-# INLINE cylinderOnSeg #-}
|
||||
cylinderOnSeg = undefined
|
||||
|
||||
Reference in New Issue
Block a user