For the past day or two i've been attempting to code a softbody physics sim in pico-8 with minimal success. I've found plenty of good resources, but none of them are just right for how I'm planning to implement it.
I'm mainly following this video by TheSandwichCoder and this blogpost by lisyarus as guides for my own simulation. However, I want my softbody to handle continuous collision detection/resolution on a grid, specifically the map that pico-8 provides. I've found nothing of the sort so far...
The closest resources I've got:
hit.p8 by @kikito - handles continuous collision detection and resolution between two rects. it even returns the surface normal, and accounts for specific edge cases, which is perfect! however, I need something that's a collision between a point and the map (i know how to do this) that still returns the normal (i don't know how to do this) so i'm back to square one.
Line of Sight, specifically the optimized one in the replies by @dw817 - handles collision between two points along a grid, which is really close to what i want! no clue on how to derive the surface normal using it though, so I'm once again lost...
Pressure Softbody by @OgelGames - the cartridge that originally inspired me to try and make my own softbody sim. due to issues with the Verlet Integration algorithm used for this specific cartridge, I wanted to try my hand at a re-code using the Shape Matching algorithm instead. However, I'm currently stuck on the collisions thing, and that's what this post is for.
What I need, broken down
Given a point x,y
with a velocity vx,vy
, figure out if said point will collide with the map. If it does collide, push the point the smallest possible distance that results in the collision being resolved, while also providing the normal of the side the point collided with for additional physics calculations later (e.g, 0,-1
for collisions with the top side, 1,0
when it's on the right side)
I know i can easily get if a point is inside a solid cell using fget(mget(x\8,y\8),0)
, but that's about as far as I am currently. help!
My next best idea is to somehow recode hit.p8 for my specific purposes, but I'm making this post, which means I haven't had success lol
[Please log in to post a comment]