The original computes a collision impulse per polygon of the collision mesh. It does so by rasterizing the mesh against the terrain and accumulating the per-pixel penetrations.
Current code tries to simulate it by tessellating each polygon into samples, and then iterating those samples on CPU.
The fundamental physics equations (there aren't many that are needed, really) seem to be correct as of 56fb63238af867ee6d606ca3d92eb69e1870844c. But the integration is unstable, regardless of the time deltas I supply. Hence my latest investigation points to the lack of collision resolution being the cause of the trouble.
How
Basic algorithm:
setup an orthographic projection around the mechos
the vertex shader fetches the polygon data (normal, middle point)
the pixel shader computes level penetration per pixel
rendering results in a 2-layered texture:
lower hemisphere part, each pixel storing the mini-impulse
higher hemisphere part
the texture needs to be summed up by custom mipmapping
... and then read by the CPU side to update the simulation values
Problems:
read-back latency
implementation complexity
Possible improvements:
batch the work for all the mechos at once
process multiple simulation steps before read-back
apply some intermediate (not-yet-read by CPU) results during rendering
relaxes the need to read back the level data after terra-forming (!)
What
The original computes a collision impulse per polygon of the collision mesh. It does so by rasterizing the mesh against the terrain and accumulating the per-pixel penetrations.
Current code tries to simulate it by tessellating each polygon into samples, and then iterating those samples on CPU.
The fundamental physics equations (there aren't many that are needed, really) seem to be correct as of 56fb63238af867ee6d606ca3d92eb69e1870844c. But the integration is unstable, regardless of the time deltas I supply. Hence my latest investigation points to the lack of collision resolution being the cause of the trouble.
How
Basic algorithm:
Problems:
Possible improvements: