Simplify cloud/dust update

This commit is contained in:
2025-12-02 22:20:41 +00:00
parent b2cb8cfe11
commit 22646d1702
3 changed files with 70 additions and 82 deletions
+3 -2
View File
@@ -18,13 +18,14 @@ import RandomHelp
updateFlame :: World -> Flame -> (World, Maybe Flame)
updateFlame w pt
| _flTimer pt <= 0 = (makeCloudAt Smoke 200 (addZ 20 ep) w, Nothing)
| _flTimer pt <= 0 = (mcloud w, Nothing)
| Just (_, Right wl) <- thit = (doupdate, Just $ reflame wl)
-- might want to move differently if we hit a creature?
| _flTimer pt <= 1 = (makeCloudAt Smoke 200 (addZ 20 ep) $ flFlicker pt doupdate
| _flTimer pt <= 1 = (mcloud $ flFlicker pt doupdate
, Just mvflame)
| otherwise = (flFlicker pt doupdate, Just mvflame)
where
mcloud = makeCloudAt Smoke 200 (addZ 20 ep)
reflame wl = pt & flTimer -~ 1 & flVel %~ reflVelWallDamp 0.9 wl
doupdate =
soundContinue FlameSound sp fireLoudS (Just 2) $
+13 -28
View File
@@ -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 $
+54 -52
View File
@@ -2772,7 +2772,7 @@ checkCombineSelectionExists src/Dodge/DisplayInventory.hs 100;" f
checkConnection src/Dodge/Inventory/Swap.hs 66;" f
checkDeath src/Dodge/Creature/Update.hs 70;" f
checkDeath' src/Dodge/Creature/Update.hs 73;" f
checkEndGame src/Dodge/Update.hs 767;" f
checkEndGame src/Dodge/Update.hs 768;" f
checkErrorGL src/Shader/Compile.hs 86;" f
checkFBO src/Framebuffer/Check.hs 6;" f
checkGLError src/GLHelp.hs 17;" f
@@ -2801,7 +2801,7 @@ circleDecoration src/Dodge/Placement/TopDecoration.hs 56;" f
circleSolid src/Picture/Base.hs 164;" f
circleSolidCol src/Picture/Base.hs 168;" f
clAlt src/Dodge/Cloud.hs 5;" f
clClSpringVel src/Dodge/Update.hs 863;" f
clClSpringVel src/Dodge/Update.hs 864;" f
clColor src/Shader/Poke/Cloud.hs 39;" f
clZoneSize src/Dodge/Zoning/Cloud.hs 24;" f
clampPath src/Dodge/Room/Procedural.hs 146;" f
@@ -2905,7 +2905,7 @@ crAwayFromPost src/Dodge/Creature/Test.hs 85;" f
crBlips src/Dodge/RadarSweep.hs 88;" f
crCamouflage src/Dodge/Creature/Picture.hs 33;" f
crCanSeeCr src/Dodge/Creature/Test.hs 52;" f
crCrSpring src/Dodge/Update.hs 901;" f
crCrSpring src/Dodge/Update.hs 900;" f
crCurrentEquipment src/Dodge/Creature/Statistics.hs 62;" f
crDexterity src/Dodge/Creature/Statistics.hs 19;" f
crDisplayAwareness src/Dodge/Creature/Picture/Awareness.hs 39;" f
@@ -2936,7 +2936,7 @@ crRad src/Dodge/Creature/Radius.hs 7;" f
crSafeDistFromTarg src/Dodge/Creature/Test.hs 74;" f
crSetRoots src/Dodge/Inventory/Location.hs 55;" f
crShape src/Dodge/Creature/Shape.hs 8;" f
crSpring src/Dodge/Update.hs 898;" f
crSpring src/Dodge/Update.hs 897;" f
crStratConMatches src/Dodge/Creature/Test.hs 80;" f
crStrength src/Dodge/Creature/Statistics.hs 29;" f
crUpdate src/Dodge/Creature/Update.hs 63;" f
@@ -3151,7 +3151,7 @@ displayFrameTicks src/Dodge/Render/Picture.hs 50;" f
displayFreeSlots src/Dodge/DisplayInventory.hs 192;" f
displayIndents src/Dodge/DisplayInventory.hs 110;" f
displayPulse src/Dodge/Inventory/SelectionList.hs 179;" f
displayTerminalLineString src/Dodge/Update.hs 479;" f
displayTerminalLineString src/Dodge/Update.hs 480;" f
dist src/Geometry/Vector.hs 185;" f
dist3 src/Geometry/Vector3D.hs 101;" f
divTo src/Geometry/Zone.hs 8;" f
@@ -3374,11 +3374,11 @@ dropInventoryPath src/Dodge/HeldUse.hs 1351;" f
dropItem src/Dodge/Creature/Action.hs 155;" f
dropper src/Dodge/Item/Scope.hs 76;" f
drumMag src/Dodge/Item/Ammo.hs 34;" f
dsZoneSize src/Dodge/Zoning/Cloud.hs 45;" f
dssNearCirc src/Dodge/Zoning/Cloud.hs 42;" f
dssNearPoint src/Dodge/Zoning/Cloud.hs 33;" f
dssNearRect src/Dodge/Zoning/Cloud.hs 39;" f
dssNearSeg src/Dodge/Zoning/Cloud.hs 36;" f
dsZoneSize src/Dodge/Zoning/Cloud.hs 51;" f
dssNearCirc src/Dodge/Zoning/Cloud.hs 48;" f
dssNearPoint src/Dodge/Zoning/Cloud.hs 39;" f
dssNearRect src/Dodge/Zoning/Cloud.hs 45;" f
dssNearSeg src/Dodge/Zoning/Cloud.hs 42;" f
dtIL src/Dodge/DoubleTree.hs 132;" f
dtPropagate' src/Dodge/DoubleTree.hs 45;" f
dtStartPropagate src/Dodge/DoubleTree.hs 38;" f
@@ -3392,7 +3392,7 @@ dtToRootIntMap' src/Dodge/DoubleTree.hs 153;" f
dtToUpDownAdj src/Dodge/DoubleTree.hs 158;" f
dummyMenuOption src/Dodge/Menu/Option.hs 72;" f
dustColor src/Shader/Poke/Cloud.hs 45;" f
dustSpringVel src/Dodge/Update.hs 883;" f
dustSpringVel src/Dodge/Update.hs 882;" f
ebColor src/Dodge/EnergyBall.hs 77;" f
ebDamage src/Dodge/EnergyBall.hs 85;" f
ebEffect src/Dodge/EnergyBall.hs 45;" f
@@ -3482,7 +3482,7 @@ firstTrie src/SimpleTrie.hs 51;" f
firstWorldLoad appDodge/Main.hs 77;" f
fixedCoordPictures src/Dodge/Render/Picture.hs 20;" f
fixedSizePicClampArrow src/Dodge/Picture/SizeInvariant.hs 57;" f
flFlicker src/Dodge/Flame.hs 38;" f
flFlicker src/Dodge/Flame.hs 39;" f
flameMuzzles src/Dodge/HeldUse.hs 325;" f
flameShield src/Dodge/Item/Equipment.hs 33;" f
flameSize src/Dodge/Flame/Size.hs 5;" f
@@ -3548,8 +3548,8 @@ gameRoomViewpoints src/Dodge/Viewpoints.hs 35;" f
gameRoomsFromRooms src/Dodge/Layout.hs 149;" f
gameplayMenu src/Dodge/Menu.hs 154;" f
gameplayMenuOptions src/Dodge/Menu.hs 157;" f
gasEffect src/Dodge/Update.hs 792;" f
gasGasSpringVel src/Dodge/Update.hs 872;" f
gasEffect src/Dodge/Update.hs 793;" f
gasGasSpringVel src/Dodge/Update.hs 873;" f
gasType src/Dodge/HeldUse.hs 1115;" f
gassesNearPoint src/Dodge/Zoning/Cloud.hs 12;" f
generateGenParams src/Dodge/LevelGen/LevelStructure.hs 23;" f
@@ -4055,7 +4055,7 @@ makeDoorDebris src/Dodge/Block/Debris.hs 26;" f
makeDustAt src/Dodge/WorldEvent/Cloud.hs 17;" f
makeExplosionAt src/Dodge/WorldEvent/Explosion.hs 72;" f
makeFlak src/Dodge/Bullet.hs 146;" f
makeFlame src/Dodge/Flame.hs 45;" f
makeFlame src/Dodge/Flame.hs 46;" f
makeFlameExplosionAt src/Dodge/WorldEvent/Explosion.hs 55;" f
makeFlamelet src/Dodge/EnergyBall.hs 21;" f
makeFragBullets src/Dodge/Bullet.hs 132;" f
@@ -4216,7 +4216,7 @@ muzzleRandPos src/Dodge/HeldUse.hs 778;" f
mvButton src/Dodge/Placement/PlaceSpot.hs 176;" f
mvCr src/Dodge/Placement/PlaceSpot.hs 179;" f
mvFS src/Dodge/Placement/PlaceSpot.hs 185;" f
mvGust src/Dodge/Update.hs 783;" f
mvGust src/Dodge/Update.hs 784;" f
mvLS src/Dodge/Placement/PlaceSpot.hs 220;" f
mvPointAlongAtSpeed src/Dodge/Base.hs 121;" f
mvPointMeleeTarg src/Dodge/Creature/Boid.hs 327;" f
@@ -4561,7 +4561,7 @@ randPeakedParam src/RandomHelp.hs 130;" f
randProb src/RandomHelp.hs 68;" f
randSpark src/Dodge/Spark.hs 69;" f
randSparkExtraVel src/Dodge/Spark.hs 92;" f
randWallReflect src/Dodge/Update.hs 639;" f
randWallReflect src/Dodge/Update.hs 640;" f
randomChallenges src/Dodge/Room/Start.hs 63;" f
randomCompass src/Dodge/Layout.hs 60;" f
randomFourCornerRoom src/Dodge/Room/Procedural.hs 246;" f
@@ -4815,7 +4815,7 @@ setLinkType src/Dodge/RoomLink.hs 78;" f
setLinkTypePD src/Dodge/RoomLink.hs 85;" f
setMusicVolume src/Sound.hs 162;" f
setMvPos src/Dodge/Creature/ReaderUpdate.hs 58;" f
setOldPos src/Dodge/Update.hs 498;" f
setOldPos src/Dodge/Update.hs 499;" f
setOutLinks src/Dodge/RoomLink.hs 50;" f
setOutLinksByType src/Dodge/RoomLink.hs 75;" f
setOutLinksPD src/Dodge/RoomLink.hs 95;" f
@@ -4915,7 +4915,7 @@ shuffleLinks src/Dodge/Room/Link.hs 30;" f
shuffleRoomPos src/Dodge/Layout.hs 82;" f
shuffleTail src/RandomHelp.hs 59;" f
sigmoid src/Dodge/Base.hs 151;" f
simpleCrSprings src/Dodge/Update.hs 892;" f
simpleCrSprings src/Dodge/Update.hs 891;" f
simpleTermMessage src/Dodge/Terminal.hs 164;" f
sineRaisePitchOneSecS src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 700;" f
sineRaisePitchTwoSecS src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 484;" f
@@ -5153,7 +5153,7 @@ titleOptionsMenu src/Dodge/Menu.hs 106;" f
titleOptionsNoWrite src/Dodge/Menu.hs 109;" f
tlDoEffect src/Dodge/Terminal.hs 102;" f
tlSetStatus src/Dodge/Terminal.hs 99;" f
tmUpdate src/Dodge/Update.hs 482;" f
tmUpdate src/Dodge/Update.hs 483;" f
toBinary src/Dodge/Inventory/SelectionList.hs 141;" f
toBothLnk src/Dodge/RoomLink.hs 136;" f
toClosestMultiple src/HelpNum.hs 3;" f
@@ -5299,46 +5299,46 @@ updateBaseWheelEvent src/Dodge/Update/Scroll.hs 34;" f
updateBounds src/Dodge/Update/Camera.hs 263;" f
updateBulVel src/Dodge/Bullet.hs 57;" f
updateBullet src/Dodge/Bullet.hs 22;" f
updateBullets src/Dodge/Update.hs 561;" f
updateBullets src/Dodge/Update.hs 562;" f
updateCamera src/Dodge/Update/Camera.hs 31;" f
updateCloseObjects src/Dodge/Inventory.hs 115;" f
updateCloud src/Dodge/Update.hs 796;" f
updateClouds src/Dodge/Update.hs 665;" f
updateCloud src/Dodge/Update.hs 797;" f
updateClouds src/Dodge/Update.hs 666;" f
updateCombinePositioning src/Dodge/DisplayInventory.hs 40;" f
updateCombineSections src/Dodge/DisplayInventory.hs 47;" f
updateCreature src/Dodge/Creature/Update.hs 32;" f
updateCreature' src/Dodge/Creature/Update.hs 41;" f
updateCreatureGroups src/Dodge/Update.hs 533;" f
updateCreatureSoundPositions src/Dodge/Update.hs 512;" f
updateDebris src/Dodge/Update.hs 568;" f
updateCreatureGroups src/Dodge/Update.hs 534;" f
updateCreatureSoundPositions src/Dodge/Update.hs 513;" f
updateDebris src/Dodge/Update.hs 569;" f
updateDebrisChunk src/Dodge/Prop/Moving.hs 16;" f
updateDebugMessageOffset src/Dodge/Update.hs 95;" f
updateDelayedEvents src/Dodge/Update.hs 921;" f
updateDelayedEvents src/Dodge/Update.hs 920;" f
updateDisplaySections src/Dodge/DisplayInventory.hs 116;" f
updateDistortion src/Dodge/Distortion.hs 8;" f
updateDistortions src/Dodge/Update.hs 554;" f
updateDistortions src/Dodge/Update.hs 555;" f
updateDoor src/Dodge/Door.hs 22;" f
updateDoors src/Dodge/Update.hs 309;" f
updateDust src/Dodge/Update.hs 844;" f
updateDusts src/Dodge/Update.hs 671;" f
updateDust src/Dodge/Update.hs 845;" f
updateDusts src/Dodge/Update.hs 672;" f
updateEdge src/Dodge/Path.hs 43;" f
updateEdgeWallObs src/Dodge/Update/WallDamage.hs 39;" f
updateEdgesWall src/Dodge/Update/WallDamage.hs 23;" f
updateEdgesWall' src/Dodge/Update/WallDamage.hs 36;" f
updateEnergyBall src/Dodge/EnergyBall.hs 31;" f
updateEnergyBalls src/Dodge/Update.hs 656;" f
updateEnergyBalls src/Dodge/Update.hs 657;" f
updateEnterRegex src/Dodge/Update/Input/InGame.hs 505;" f
updateExpBarrel src/Dodge/Barreloid.hs 21;" f
updateFlame src/Dodge/Flame.hs 19;" f
updateFlames src/Dodge/Update.hs 653;" f
updateFlames src/Dodge/Update.hs 654;" f
updateFloatingCamera src/Dodge/Update/Camera.hs 36;" f
updateFunctionKey src/Dodge/Update/Input/InGame.hs 363;" f
updateFunctionKeys src/Dodge/Update/Input/InGame.hs 359;" f
updateGas src/Dodge/Update.hs 820;" f
updateGasses src/Dodge/Update.hs 668;" f
updateGusts src/Dodge/Update.hs 780;" f
updateIMl src/Dodge/Update.hs 527;" f
updateIMl' src/Dodge/Update.hs 530;" f
updateGas src/Dodge/Update.hs 821;" f
updateGasses src/Dodge/Update.hs 669;" f
updateGusts src/Dodge/Update.hs 781;" f
updateIMl src/Dodge/Update.hs 528;" f
updateIMl' src/Dodge/Update.hs 531;" f
updateInGameCamera src/Dodge/Update/Camera.hs 84;" f
updateInitialPressInGame src/Dodge/Update/Input/InGame.hs 428;" f
updateInt2Map src/Dodge/Zoning/Base.hs 94;" f
@@ -5363,20 +5363,20 @@ updateMouseContextGame src/Dodge/Update.hs 330;" f
updateMouseHeldInGame src/Dodge/Update/Input/InGame.hs 96;" f
updateMouseInGame src/Dodge/Update/Input/InGame.hs 86;" f
updateMouseReleaseInGame src/Dodge/Update/Input/InGame.hs 166;" f
updateObjCatMaybes src/Dodge/Update.hs 545;" f
updateObjMapMaybe src/Dodge/Update.hs 538;" f
updateObjCatMaybes src/Dodge/Update.hs 546;" f
updateObjMapMaybe src/Dodge/Update.hs 539;" f
updatePastWorlds src/Dodge/Update.hs 420;" f
updatePreload src/Preload/Update.hs 21;" f
updateProjectile src/Dodge/Projectile/Update.hs 26;" f
updatePulse src/Dodge/Creature/Update.hs 123;" f
updatePulseBall src/Dodge/Update.hs 445;" f
updatePulseLaser src/Dodge/Update.hs 608;" f
updatePulseLaser src/Dodge/Update.hs 609;" f
updatePulseLasers src/Dodge/Update.hs 440;" f
updateRBList src/Dodge/Inventory/RBList.hs 22;" f
updateRadarBlip src/Dodge/RadarBlip.hs 11;" f
updateRadarBlips src/Dodge/Update.hs 557;" f
updateRadarBlips src/Dodge/Update.hs 558;" f
updateRadarSweep src/Dodge/RadarSweep.hs 40;" f
updateRadarSweeps src/Dodge/Update.hs 659;" f
updateRadarSweeps src/Dodge/Update.hs 660;" f
updateRandNode src/TreeHelp.hs 109;" f
updateRenderSplit appDodge/Main.hs 113;" f
updateRightParentSF src/Dodge/Item/Grammar.hs 181;" f
@@ -5386,16 +5386,16 @@ updateScrollTestValue src/Dodge/ScrollValue.hs 6;" f
updateSection src/Dodge/DisplayInventory.hs 258;" f
updateSectionsPositioning src/Dodge/DisplayInventory.hs 237;" f
updateShockwave src/Dodge/Shockwave/Update.hs 8;" f
updateShockwaves src/Dodge/Update.hs 650;" f
updateShockwaves src/Dodge/Update.hs 651;" f
updateSingleNodes src/TreeHelp.hs 98;" f
updateSound src/Sound.hs 72;" f
updateSounds src/Sound.hs 67;" f
updateSpark src/Dodge/Spark.hs 19;" f
updateSparks src/Dodge/Update.hs 662;" f
updateTeslaArc src/Dodge/Update.hs 578;" f
updateTeslaArcs src/Dodge/Update.hs 575;" f
updateSparks src/Dodge/Update.hs 663;" f
updateTeslaArc src/Dodge/Update.hs 579;" f
updateTeslaArcs src/Dodge/Update.hs 576;" f
updateTractorBeam src/Dodge/TractorBeam/Update.hs 9;" f
updateTractorBeams src/Dodge/Update.hs 647;" f
updateTractorBeams src/Dodge/Update.hs 648;" f
updateTurret src/Dodge/Machine/Update.hs 49;" f
updateUniverse src/Dodge/Update.hs 74;" f
updateUniverseFirst src/Dodge/Update.hs 85;" f
@@ -5579,19 +5579,21 @@ zConnectColMidX src/Dodge/Render/Connectors.hs 31;" f
zeroZ src/Geometry/Vector.hs 9;" f
zipArcs src/Dodge/Tesla.hs 52;" f
zipCount src/Dodge/Tree/Shift.hs 136;" f
zoneCloud src/Dodge/Zoning/Cloud.hs 30;" f
zoneCloud src/Dodge/Zoning/Cloud.hs 33;" f
zoneClouds src/Dodge/Update.hs 472;" f
zoneCreature src/Dodge/Zoning/Creature.hs 56;" f
zoneCreatures src/Dodge/Update.hs 508;" f
zoneDust src/Dodge/Zoning/Cloud.hs 51;" f
zoneDusts src/Dodge/Update.hs 476;" f
zoneCreatures src/Dodge/Update.hs 509;" f
zoneDust src/Dodge/Zoning/Cloud.hs 57;" f
zoneDusts src/Dodge/Update.hs 477;" f
zoneExtract src/Dodge/Zoning/Base.hs 58;" f
zoneGas src/Dodge/Zoning/Cloud.hs 36;" f
zoneIncPe src/Dodge/Zoning/Pathing.hs 66;" f
zoneMonoid src/Dodge/Zoning/Base.hs 85;" f
zoneOfCirc src/Dodge/Zoning/Base.hs 26;" f
zoneOfCl src/Dodge/Zoning/Cloud.hs 27;" f
zoneOfCr src/Dodge/Zoning/Creature.hs 46;" f
zoneOfDs src/Dodge/Zoning/Cloud.hs 48;" f
zoneOfDs src/Dodge/Zoning/Cloud.hs 54;" f
zoneOfGas src/Dodge/Zoning/Cloud.hs 30;" f
zoneOfIncPe src/Dodge/Zoning/Pathing.hs 52;" f
zoneOfPn src/Dodge/Zoning/Pathing.hs 29;" f
zoneOfPoint src/Dodge/Zoning/Base.hs 46;" f