Simplify cloud/dust update
This commit is contained in:
+13
-28
@@ -664,7 +664,7 @@ updateSparks :: World -> World
|
||||
updateSparks = updateObjCatMaybes sparks updateSpark
|
||||
|
||||
updateClouds :: World -> World
|
||||
updateClouds = updateObjCatMaybes clouds updateCloud
|
||||
updateClouds w = updateObjMapMaybe clouds (updateCloud w) w
|
||||
|
||||
updateGasses :: World -> World
|
||||
updateGasses = updateObjCatMaybes gasses updateGas
|
||||
@@ -794,22 +794,20 @@ gasEffect :: Gas -> World -> World
|
||||
gasEffect cl = case _gsType cl of
|
||||
PoisonGas -> cloudPoisonDamage cl
|
||||
|
||||
updateCloud :: World -> Cloud -> (World, Maybe Cloud)
|
||||
updateCloud :: World -> Cloud -> Maybe Cloud
|
||||
updateCloud w c
|
||||
| _clTimer c < 1 = (w, Nothing)
|
||||
| _clTimer c < 1 = Nothing
|
||||
| otherwise =
|
||||
( w
|
||||
, Just $
|
||||
Just $
|
||||
c
|
||||
& clPos .~ finalPos
|
||||
& clVel .~ finalVel
|
||||
& clTimer -~ 1
|
||||
)
|
||||
where
|
||||
newVel@(V3 _ _ nvz) = (0.95 *^ springVels) + V3 0 0 (0.01 * vertVel)
|
||||
newVel@(V3 _ _ nvz) = (0.95 *^ (springVels + c ^. clVel)) + V3 0 0 (0.01 * vertVel)
|
||||
newVel2 = stripZ newVel
|
||||
vertVel = min 5 $ clAlt c - opz
|
||||
springVels = foldl' (clClSpringVel c) (_clVel c) (clsNearPoint oldPos2 w)
|
||||
springVels = sum $ map (radiusSpring 10 oldPos . _clPos) (clsNearPoint oldPos2 w)
|
||||
oldPos@(V3 _ _ opz) = _clPos c
|
||||
oldPos2 = stripZ oldPos
|
||||
newPos@(V3 _ _ npz) = oldPos + newVel
|
||||
@@ -852,7 +850,9 @@ updateDust w c
|
||||
& dsVel .~ newvel
|
||||
& dsTimer -~ 1
|
||||
where
|
||||
v@(V3 _ _ vz) = foldl' (dustSpringVel c) (_dsVel c) (dssNearPoint oldPos2 w)
|
||||
v@(V3 _ _ vz) = c ^. dsVel + sum (map (radiusSpring 10 oldPos . _dsPos)
|
||||
(dssNearPoint oldPos2 w))
|
||||
-- foldl' (dustSpringVel c) (_dsVel c) (dssNearPoint oldPos2 w)
|
||||
newvel = 0.95 * (maybe v (addZ vz . snd) hitWl - V3 0 0 0.05)
|
||||
oldPos = _dsPos c
|
||||
oldPos2 = stripZ oldPos
|
||||
@@ -861,14 +861,10 @@ updateDust w c
|
||||
hitWl = bouncePoint (const True) 1 oldPos2 newPos2 w
|
||||
finalpos = addZ (max 1 npz) $ maybe newPos2 fst hitWl
|
||||
|
||||
clClSpringVel :: Cloud -> Point3 -> Cloud -> Point3
|
||||
clClSpringVel a v b
|
||||
| dist3 pa pb < radDist = v + 0.1 *^ normalizeV3 (pa - pb)
|
||||
| otherwise = v
|
||||
where
|
||||
pa = _clPos a
|
||||
pb = _clPos b
|
||||
radDist = 10
|
||||
radiusSpring :: Float -> Point3 -> Point3 -> Point3
|
||||
radiusSpring r a b
|
||||
| dist3 a b < r = 0.1 *^ normalizeV3 (a - b)
|
||||
| otherwise = 0
|
||||
|
||||
gasGasSpringVel :: Gas -> Point3 -> Gas -> Point3
|
||||
gasGasSpringVel a v b
|
||||
@@ -879,17 +875,6 @@ gasGasSpringVel a v b
|
||||
pb = _gsPos b
|
||||
radDist = 10
|
||||
|
||||
--radDist = (_clRad a + _clRad b) / 2
|
||||
|
||||
dustSpringVel :: Dust -> Point3 -> Dust -> Point3
|
||||
dustSpringVel a v b
|
||||
| dist3 pa pb < radDist = v +.+.+ 0.1 *.*.* normalizeV3 (pa -.-.- pb)
|
||||
| otherwise = v
|
||||
where
|
||||
pa = _dsPos a
|
||||
pb = _dsPos b
|
||||
radDist = 10
|
||||
|
||||
simpleCrSprings :: World -> World
|
||||
simpleCrSprings w =
|
||||
IM.foldl' (flip crSpring) w $
|
||||
|
||||
Reference in New Issue
Block a user