Fix bug in intersectCircSeg

This commit is contained in:
2021-12-15 17:47:41 +00:00
parent adab32bf68
commit 9dadea2c36
4 changed files with 7 additions and 8 deletions
+1 -2
View File
@@ -71,14 +71,13 @@ bulPenCr' bt p cr w
++ ++
) )
$ bulletHitSound ep $ bulletHitSound ep
$ over worldEvents (addPiercer . ) $ over instantParticles (piercer :)
w w
where where
(d1,_) = randomR (-0.7,0.7) $ _randGen w (d1,_) = randomR (-0.7,0.7) $ _randGen w
cid = _crID cr cid = _crID cr
sp = head $ _btTrail' bt sp = head $ _btTrail' bt
ep = sp +.+ _ptVel bt ep = sp +.+ _ptVel bt
addPiercer = over particles (piercer :)
piercer = (aGenBulAt (Just cid) p (_ptVel bt) (_btDrag bt) piercer = (aGenBulAt (Just cid) p (_ptVel bt) (_btDrag bt)
(_btHitEffect' bt) (_btWidth' bt) (_btHitEffect' bt) (_btWidth' bt)
) {_btTimer' = _btTimer' bt - 1} ) {_btTimer' = _btTimer' bt - 1}
+4 -4
View File
@@ -1,6 +1,6 @@
module Dodge.Particle.Spark module Dodge.Particle.Spark
( colSpark ( colSpark
, colSpark' , colSparkRandDir
, createBarrelSpark , createBarrelSpark
) )
where where
@@ -34,9 +34,9 @@ createBarrelSpark pos dir maycid time colid = instantParticles .:~ BulletPt
sp = head (_btTrail' bt) sp = head (_btTrail' bt)
ep = sp +.+ _ptVel bt ep = sp +.+ _ptVel bt
colSpark :: Int -> Color -> Point2 -> Float -> World -> World colSpark :: Int -> Color -> Point2 -> Float -> World -> World
colSpark = colSpark' 0.7 colSpark = colSparkRandDir 0.7
colSpark' :: Float -> Int -> Color -> Point2 -> Float -> World -> World colSparkRandDir :: Float -> Int -> Color -> Point2 -> Float -> World -> World
colSpark' randDir time col pos baseDir w = w colSparkRandDir randDir time col pos baseDir w = w
& instantParticles .:~ spark & instantParticles .:~ spark
& randGen .~ g & randGen .~ g
where where
+1 -1
View File
@@ -24,7 +24,7 @@ damageWall dt wl = case _wlStructure wl of
wallEff :: DamageType -> Wall -> World -> World wallEff :: DamageType -> Wall -> World -> World
wallEff dt wl = case dt of wallEff dt wl = case dt of
Lasering _ sp p _ -> colSpark 8 lSparkCol (outTo sp p) (reflDirWall sp p wl) Lasering _ sp p _ -> colSpark 8 lSparkCol (outTo sp p) (reflDirWall sp p wl)
Piercing _ sp p _ -> colSpark' 0.2 8 pSparkCol (outTo sp p) (reflDirWall sp p wl) Piercing _ sp p _ -> colSparkRandDir 0.2 8 pSparkCol (outTo sp p) (reflDirWall sp p wl)
. wlDustAt wl (outTo sp p) . wlDustAt wl (outTo sp p)
Blunt _ sp p _ -> wlDustAt wl (outTo sp p) Blunt _ sp p _ -> wlDustAt wl (outTo sp p)
Explosive _ _ -> id Explosive _ _ -> id
+1 -1
View File
@@ -259,7 +259,7 @@ inSegArea a b c = param >= 0 && param <= dotV (b -.- a) (b -.- a)
intersectCircSeg :: Point2 -> Float -> Point2 -> Point2 -> [Point2] intersectCircSeg :: Point2 -> Float -> Point2 -> Point2 -> [Point2]
intersectCircSeg c r a b intersectCircSeg c r a b
| y < 0 = [] | y < 0 = []
| otherwise = nub $ filter (inSegArea a b) [ d -.- v, d +.+ c ] | otherwise = nub $ filter (inSegArea a b) [ d -.- v, d +.+ v ]
where where
d = closestPointOnLine a b c d = closestPointOnLine a b c
x = dist d c x = dist d c