Elastic Solids is a physics engine extension for Unity designed to simulate deformable volumetric objects (Soft Body Dynamics). Unlike hollow cloth simulations, this project models internal pressure and volume conservation using tetrahedral meshes.
Developed as advanced Computer Graphics coursework, it implements a mass-spring system extended with volumetric constraints to simulate materials like jelly or flesh realistically.
Physics Features
The core of the simulation is a custom solver that integrates Newton’s laws for thousands of nodes in real-time.
:: Tetrahedral Volumetric Forces
Standard springs only maintain edge lengths. This solver adds Volume Conservation Forces to each tetrahedron, preventing the mesh from collapsing or inverting under pressure.
:: Custom TetGen Integration
Includes a modified C++ build of TetGen compiled as a native plugin.
It parses .node, .ele, and .face files to generate the tetrahedral
lattice automatically from any standard mesh.
:: Penalty-Based Collisions
Implements continuous collision detection using Implicit Penalty Methods. It calculates penetration depth and applies a corrective force proportional to the intrusion, ensuring stable contacts.
:: Environmental Interaction
The solver accounts for external factors like Wind Drag and Damping Forces to dissipate energy and stabilize the integration.
Technical Challenges
Mesh Generation Pipeline
Unity uses surface meshes (triangles), but volumetric physics requires a tetrahedral mesh. Manually creating these structures is impossible for complex assets.
I integrated a modified version of TetGen, a quality tetrahedral mesh generator. I wrote a custom parser
that reads the raw ASCII output (.node, .ele) and reconstructs the topological connectivity graph
(neighbors, edges, internal springs) inside Unity at runtime[cite: 206, 212].
Integration Instability
Stiff springs and high forces (like collision penalties) cause explicit integrators to explode (explode to infinity) if the time step is too large.
I implemented a Sub-stepping system. The physics solver runs multiple times per visual frame
(independent of Unity’s Update), dividing deltaTime into smaller, safe increments to maintain numerical
stability without sacrificing simulation speed[cite: 213].