I set out to make a rigid body physics system, at the moment it’s a particle simulation.
Right now I have most of the code for rigid bodies aside from collision detection between cubes implemented though much of it does not work correctly. Spheres are convenient because they don’t need to deal with rotation until I want to implement rolling so I have sphere collision detection and resolution working.
I started by implementing most of the base systems and objects. Once I had those implemented I tried making some cubes. The cubes did not work out well as they would bounce off of the ground with far more energy than they hit it with. They would also start rotating at about 40 radians per second in some direction.
I ended up backtracking to spheres and finding that they actually worked with minimal effort and have resting contacts support.
I worked around with the code for a while, and at the moment I’m pretty sure that the inertia tensor is getting multiplied into vectors and other matrices in the wrong order so it ends up adding a lot of speed to the rotational velocity that it shouldn’t. When the object starts spinning at crazy high speeds, it hits the ground again at those speeds and the issue continues to compound itself. Additionally I only use a linear projection for interpenetration resolution and frictionless contact generation at the moment since they end up just adding another source of errors and I want to isolate the issue.
Although that’s what I think, it’s pretty likely that I also just have some number slightly wrong or forgot to negate something in an equation since that’s been my experience with errors in recent years and I should have had it working by now if that were the only issue…
I plan to continue to work on this over the next few days since I won’t be able to focus o anything else until this is resolved. Also I want to get this working with my voxel traced global illumination once I get cubes and rotations in general working. The effect is not quite good enough at the moment to do purely glossy surfaces that have no roughness or normal variation as there is very visible banding from tracing through the volume since it’s not blurred. So that’s another thing that I want to fix. I hope that I can get the cube stuff resolved by Saturday afternoon, though the VXGI won’t be implemented since I need to implement Gaussian filtering for the voxel volume before it can get good looking results for glossy surfaces.