Boat-Water Interaction Physics System
Try playing the simulation on Itch!
Take a look at the source code and documentation on GitHub.
Why Take on This Challenge?
When I embarked on this project, I wasn't just looking for another programming exercise. I wanted to push myself into unfamiliar territory - implementing a physics simulation system with minimal reliance on existing tools. The idea of working at a low level, manipulating mesh polygons directly, solving complex mathematical and physics problems in code, and tackling performance optimization challenges was both intimidating and exciting. There was something magical about the prospect of creating realistic water physics from fundamental principles.
This project would take me through ocean rendering, boat physics simulation, and the intricate dance between performance and accuracy that defines real-time systems.
You can read about my key learnings during this project in the devLog
Early days
Buoyancy:
Its always a good idea to simplify the problem as much as possible, so I worked for a long time on a standard cube, testing out my code to apply forces of buoyancy in a single thread on the polys present in the mesh.
I progressed ahead and made it work on a simple boat which was very slow and unstable but the results were viewable.
There were plenty of problems, for example I was applying buoyant forces along the normal vector of the various polys as thats what I thought the physics was, which created this effect for me where there was a sideways component of the net force on the boat causing rotations and sideway movement on perfectly still water.
Viscosity:
In the initial implementation of the viscous force, I tried on plane surfaces and cubes, took readings of the force and measured against velocity and surface area variables, then plotted that data in Excel to verify that the data was in accordance to the viscosity formula.
The Green arrows indicate the point velocity of the poly and the purple arrows indicate the viscous force being applied tangential to the poly surface.
Outcome