Victor's Devblog

If you are interested to receive those weekly articles as a newsletter, poke me offline! Automated subscription is disabled because of bots...

Otherwise, Atom feed is here!

Multi Collisions

This week I did a few small tweaks then hit a bigger wall:

Minor Improvements

In order of appearance in the following video:
- Added CLI arguments to control seed & basic procedural generation parameters
- Adapted procedural generation to ensure road is reachable from the player's spawn position
- Added transition between each wheel's gripping and sliding phase, to make the loss/gain of grip easier to handle
- Implemented a more diverse procedural generation, with more bumps and tighter turns

The new road generation is just different settings over the existing system but it definitely feels different. I don't like it as much as a game, but it should definitely help me tune the physics and car control so it feels better at various speeds.

Multi Collisions

The Issue

I spent time this week thinking about centralizing my physics material. For now, each entity in the game has its own parameters (restitution, friction elasticity, etc.) which works ok but this won't scale as I start adding visual and audio events to the world's surfaces. My ultimate goal will be to have a "list" of materials with the properties listed above plus various sounds and particle systems to play when the car drives on it, and have each entity use one of them.

So I started thinking about the data that would compose those materials, for instance the sound to play when the car slides on a surface, and I realized a big flaw in my system: if an ellipsoid composing my game's car can only ever collide with 1 surface at a time, what will happen to a tire touching the ground but also a wall at the same time? for now, physics ignores the shallower collision, which leads to manageable but odd restitution when it happens, but audio won't be as forgiving. Here is what I'm talking about:

Notice how the tire alternatively collides down and right, with a bit more push back as usual to compensate it can only avoid 1 blocker at a time.

The Solution (draft)

The solution will obviously be to allow resolving multiple collisions at a time and per ellipsoid. My model (collision = damped spring) makes this especially easy compared to existing solvers, but I still have to be careful about it. In particular, I need to make sure that I only apply restitution force from multiple surfaces when it is appropriate:

In the example above:
- first case (similar to gif above) requires double restitution
- second case (two coplanar triangles sharing an edge) requires that only 1 restitution is applied (we wouldn't want the car to be pushed back twice as hard because of an imaginary division)
- third case remains open, maybe it's ok to imagine the edge/corner of a surface to be stiffer

The idea will be to merge collisions (= ignore some of them), probably based on normals and if a new point of contact lies in the same plane as an existing collision surface. I'll skip the details of what I have in mind as I will attempt to report on it next week as I implement it.


No progress on yard.