Start simplifying projectile update

This commit is contained in:
2025-08-03 13:46:20 +01:00
parent 5f158cc87a
commit c3b2bb30f5
10 changed files with 218 additions and 228 deletions
+43 -43
View File
@@ -1,12 +1,12 @@
module Dodge.Prop.Moving (
fallSmallBounceDamage,
fallSmallBounce,
-- fallSmallBounceDamage,
-- fallSmallBounce,
updateDebrisChunk,
) where
import Linear.Metric
import Linear.V3
import Dodge.Damage
--import Dodge.Damage
import Dodge.Base
import Dodge.Data.World
import Geometry
@@ -30,47 +30,47 @@ updateDebrisChunk w db = (w, mdb)
& dbVel .~ (0.7 * reflectInNormal n sv) - V3 0 0 1
dospin = (_dbSpin db *)
mdb = do
guard (np ^. _z > -100)
guard (np ^. _z > -1000)
return cdb'
fallSmallBounceDamage :: Prop -> World -> World
fallSmallBounceDamage pr w =
w
& dodamage
& cWorld . lWorld . props . ix (_prID pr) %~ fallMovement w
where
p = _prPos pr
v = _prVel pr
dodamage
| _prPosZ pr < 25 = damageInCircle (const thedam) p 5
| otherwise = id
thedam = Crushing (floor . (* 10) . max 0 . subtract 5 . abs $ _prVelZ pr) v
--fallSmallBounceDamage :: Prop -> World -> World
--fallSmallBounceDamage pr w =
-- w
-- & dodamage
-- & cWorld . lWorld . props . ix (_prID pr) %~ fallMovement w
-- where
-- p = _prPos pr
-- v = _prVel pr
-- dodamage
-- | _prPosZ pr < 25 = damageInCircle (const thedam) p 5
-- | otherwise = id
-- thedam = Crushing (floor . (* 10) . max 0 . subtract 5 . abs $ _prVelZ pr) v
fallSmallBounce :: Prop -> World -> World
fallSmallBounce pr w = w & cWorld . lWorld . props . ix (_prID pr) %~ fallMovement w
--fallSmallBounce :: Prop -> World -> World
--fallSmallBounce pr w = w & cWorld . lWorld . props . ix (_prID pr) %~ fallMovement w
fallMovement :: World -> Prop -> Prop
fallMovement w pr
| newposz < 0 && velz < (-2) =
pr
& prVelZ %~ ((* 0.5) . negate)
& updateWithVel (0.5 *.* vel)
& prVel %~ (0.5 *.*)
| newposz < 0 =
pr & prUpdate .~ PropUpdateId
& prPosZ .~ 0
-- & pjQuat *~ (_pjQuatSpin pr)
| otherwise =
pr
& prVelZ -~ 1
& prPosZ +~ velz
& updateWithVel vel
& prQuat *~ _prQuatSpin pr
where
newposz = _prPosZ pr + velz
velz = _prVelZ pr
vel = _prVel pr
pos = _prPos pr
updateWithVel v = case bouncePoint (const True) 0.5 pos (pos + v) w of
Nothing -> prPos +~ v
Just (p, v') -> (prPos .~ p) . (prVel .~ v')
--fallMovement :: World -> Prop -> Prop
--fallMovement w pr
-- | newposz < 0 && velz < (-2) =
-- pr
-- & prVelZ %~ ((* 0.5) . negate)
-- & updateWithVel (0.5 *.* vel)
-- & prVel %~ (0.5 *.*)
-- | newposz < 0 =
-- pr & prUpdate .~ PropUpdateId
-- & prPosZ .~ 0
-- -- & pjQuat *~ (_pjQuatSpin pr)
-- | otherwise =
-- pr
-- & prVelZ -~ 1
-- & prPosZ +~ velz
-- & updateWithVel vel
-- & prQuat *~ _prQuatSpin pr
-- where
-- newposz = _prPosZ pr + velz
-- velz = _prVelZ pr
-- vel = _prVel pr
-- pos = _prPos pr
-- updateWithVel v = case bouncePoint (const True) 0.5 pos (pos + v) w of
-- Nothing -> prPos +~ v
-- Just (p, v') -> (prPos .~ p) . (prVel .~ v')