Devlog #2: Zoom, stars, and chaos
new updates to GraSim!
zooming is obviously an essential part of GraSim, so I added it as quickly as possible. there are some randomly put stars around the map. zooming introduced a crucial bug:
since you drag to add speed, when you zoom out the max of 10x the max speed gets 10x higher. this caused an issue called tunneling! each frame, the simulation moves bodies velocity * dt. at very high speeds, as mentioned above, a body can actually travel faster than it’s own diameter in a single frame! so, in frame N if they are apart, in frame N+1 they could well be already crossed.
i fixed this with substeps. basically, instead of checking just per frame, we check for collisions every X times per frame. more times checked = less distance possible, so it’s the easiest way of stopping passing into each other.
unfortunately, gravity is already expensive with O(N^2), and substeps adds another O(N^2) on top of that. the next few updates will likely focus on cutting down this time complexity as well as the time complexity of other features noticeably!
thank you so much for reading :)
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.