-
-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add particle physics (explosions) #18
base: main
Are you sure you want to change the base?
Conversation
I am considering reworking the collision shapes. It's kind of a long story. TL;DR: I was lazy, so tried to infer collision shapes from the frame buffer. It has bugs. The typical way to handle collision shapes in physics simulations is by creating a mesh in some kind of editor, like Blender or whatever. There's even a pretty awesome looking When working on melonJS, I had a fairly good experience with Tiled. Using the So I opted to infer collision shapes instead of winding them around my sprites by hand. The inference is done by grabbing a 5x5 block of pixels from the frame buffer and wrapping a convex hull around it. But, which 5x5 blocks are used? As a particle moves through the scene, its next position is predicted by adding the velocity. Then a ray is traced from its current position to its predicted position (using the Bresenham line drawing algorithm). Pixels in the frame buffer are checked along the ray, and when a "hit" is found, it is used as the center of the 5x5 block. This does actually work. It's not terrible. But there are inescapable problems. The most noticeable issue if that when particles are moving nearly parallel with the floor, they will sometimes hit invisible "ledges" that causes them to fly away at an unexpected angle. This is mostly caused by the "diamond shape" that each pixel is given, and partially by the relatively small size of 5x5 pixel shapes. With the floor, this is even worse since the longest the floor can be (relative to a particle's perspective) is 5x1 pixels. This gives it plenty of opportunity to clip the edges of this small part of the floor. So, are there better options? Maybe. Right now I'm considering using That's the story so far! I will at least explore using |
- Particles were being thrown away from the center of contact, which looks wrong. - This changes the velocities to ignore the difference in the Y dimension, allowing the particles of each object to be thrown "through" each other.
TODO:
dt
.collision.trace()
into multiple functions.vek
as a replacement for home-grown geometry primitives.xcf
as a replacement for inferred collision shapes andpcx
.