Cleanup
This commit is contained in:
+7
-16
@@ -831,7 +831,8 @@ updateGas w c
|
|||||||
newVel@(V3 _ _ nvz) = (0.95 *^ springVels) + V3 0 0 (0.01 * vertVel)
|
newVel@(V3 _ _ nvz) = (0.95 *^ springVels) + V3 0 0 (0.01 * vertVel)
|
||||||
newVel2 = stripZ newVel
|
newVel2 = stripZ newVel
|
||||||
vertVel = min 5 $ 20 - opz
|
vertVel = min 5 $ 20 - opz
|
||||||
springVels = foldl' (gasGasSpringVel c) (_gsVel c) (gassesNearPoint oldPos2 w)
|
springVels = c ^. gsPos
|
||||||
|
+ alaf Sum foldMap (radiusSpring 10 oldPos . _gsPos) (gassesNearPoint oldPos2 w)
|
||||||
oldPos@(V3 _ _ opz) = _gsPos c
|
oldPos@(V3 _ _ opz) = _gsPos c
|
||||||
oldPos2 = stripZ oldPos
|
oldPos2 = stripZ oldPos
|
||||||
newPos@(V3 _ _ npz) = oldPos + newVel
|
newPos@(V3 _ _ npz) = oldPos + newVel
|
||||||
@@ -846,35 +847,25 @@ updateDust w c
|
|||||||
| otherwise =
|
| otherwise =
|
||||||
Just $
|
Just $
|
||||||
c
|
c
|
||||||
& dsPos .~ finalpos
|
& dsPos +~ newvel
|
||||||
|
& dsPos . _z %~ max 1
|
||||||
& dsVel .~ newvel
|
& dsVel .~ newvel
|
||||||
& dsTimer -~ 1
|
& dsTimer -~ 1
|
||||||
where
|
where
|
||||||
v@(V3 _ _ vz) = c ^. dsVel + sum (map (radiusSpring 10 oldPos . _dsPos)
|
v@(V3 _ _ vz) = c ^. dsVel
|
||||||
(dssNearPoint oldPos2 w))
|
+ alaf Sum foldMap (radiusSpring 10 oldPos . _dsPos) (dssNearPoint oldPos2 w)
|
||||||
newvel = 0.95 * (maybe v (addZ vz . snd) hitWl - V3 0 0 0.05)
|
newvel = 0.95 * (maybe v (addZ vz . snd) hitWl - V3 0 0 0.05)
|
||||||
oldPos = _dsPos c
|
oldPos = _dsPos c
|
||||||
oldPos2 = stripZ oldPos
|
oldPos2 = stripZ oldPos
|
||||||
newPos@(V3 _ _ npz) = oldPos + v
|
newPos = oldPos + v
|
||||||
newPos2 = stripZ newPos
|
newPos2 = stripZ newPos
|
||||||
hitWl = bouncePoint (const True) 1 oldPos2 newPos2 w
|
hitWl = bouncePoint (const True) 1 oldPos2 newPos2 w
|
||||||
--finalpos = addZ (max 1 npz) $ maybe newPos2 fst hitWl
|
|
||||||
finalpos = oldPos + newvel & _z %~ max 1
|
|
||||||
|
|
||||||
radiusSpring :: Float -> Point3 -> Point3 -> Point3
|
radiusSpring :: Float -> Point3 -> Point3 -> Point3
|
||||||
radiusSpring r a b
|
radiusSpring r a b
|
||||||
| dist3 a b < r = 0.1 *^ normalizeV3 (a - b)
|
| dist3 a b < r = 0.1 *^ normalizeV3 (a - b)
|
||||||
| otherwise = 0
|
| otherwise = 0
|
||||||
|
|
||||||
gasGasSpringVel :: Gas -> Point3 -> Gas -> Point3
|
|
||||||
gasGasSpringVel a v b
|
|
||||||
| dist3 pa pb < radDist = v + 0.1 *^ normalizeV3 (pa - pb)
|
|
||||||
| otherwise = v
|
|
||||||
where
|
|
||||||
pa = _gsPos a
|
|
||||||
pb = _gsPos b
|
|
||||||
radDist = 10
|
|
||||||
|
|
||||||
simpleCrSprings :: World -> World
|
simpleCrSprings :: World -> World
|
||||||
simpleCrSprings w =
|
simpleCrSprings w =
|
||||||
IM.foldl' (flip crSpring) w $
|
IM.foldl' (flip crSpring) w $
|
||||||
|
|||||||
Reference in New Issue
Block a user