Hello everyone!
I hope it’s okay i do a little showcase in this section of the forum, but since this is mostly a performance showcase of the Job System, Burst, ECS and DOD i think it’s most relevant here.
So lately i’ve been working on a new physics engine to power my [softbody based vehicles and heightmap deformation based terrain physics,]( Vehicle Physics Simulation (Update 20-Feb-17 Terrain Editor Preview 1) page-2) 2 perfect subjects for optimization through DOD, ECS, Burst & Parallel Multi threading.
Initially i built a proof of concept engine where i’ve integrated seamless interaction between softbody, rigidbody & particles, on top of that i’m also trying to integrate per body/constraint selection between force, impulse & position based dynamics while maintaining seamless interaction.
The proof of concept was built with a standard OOP single-threaded design using the classic way with GameObjects, MeshRender & MeshFilter etc to represent bodies, i did this well knowing i later would have to rewrite it all in order to take full advantage of all the new performance options we have available now, but since i hadn’t worked with either the Job System, ECS or Burst before i thought it would be best to wait with those and focus on the actual physics implementation and at the same time use the prototype for performance comparison, and wow what a difference!
Now on to the exciting stuff, before i go into more details i’d like to show a small demonstration of the scale of the performance capabilities.
The demos below are running at 50Hz with 2 contact iterations.
- 20k bodies/particles with full two-way interaction piling in a small 50x50x50 meter box made of plane colliders, here we are solving about 100k potential contacts and 60k actual contacts each iteration:
- 200k bodies/particles with full two-way interaction however spread out and falling onto a 1x1km plane spaced with 1 m between each body.
[Edit] Added hardware specs.
CPU: Intel i7 4790k
GPU: Nvidia GTX 970
RAM: 16 GB 1333MHz
Compared to my prototype which was actually relatively decently optimized, i’m seeing 20-200+ times speedups everywhere.
Now i will not do any direct comparison to other physics engines at this early stage as there’s obviously still quite a few features missing to make a fair comparison, however i already feel pretty confident saying that no other currently commercially available physics engine can keep up with the scale of performance potential this have.
Below you can see the full feature set implemented in the initial prototype before i started on the “real” engine, and everything written in blue are the features currently converted.
Feature List: (Updated 11-Mar-19)
Dynamics:
-Force Based Dynamics
-Impulse Based Dynamics
-Position Based Dynamics
Physics Objects:
- Softbody
- Rigidbody
- Particle
- LinearNode
- AngularNode
Integrators:
- Explicit Euler (2 different variants)
- Semi-Implicit Euler ( 2 different variants + angular integration)
- Verlet (3 different variants)
- VelocityVerlet ( 2 different variants)
Constraints & Motors
- Spring Constraint(With & without elastic deformation)
- Distance Constraint (Force, Impulse & Projection variants)
- Point Constraint (Projection Only)
- Linear Motor (Force, Impulse & Projection variants)
- Angular Motor(Torque & Impulse variants)
Global Forces:
- Linear Gravity
- Spherical/Orbital Gravity
- Linear + Angular Damping(Force & Velocity based variants)
- Fluid Drag
- Buoyancy
- Wind force
Collision Detection:
-BroadPhase
- AABB (Axis Aligned Bounding Box)
- OBB (Oriented Bounding Box)
- OBS (Oriented Bounding Sphere)
- Brute Force Method
- Spatial Partitioning (Grid)
-NarrowPhase
- SAT (Separating Axis Theorem)
- Sphere Collider
- Plane Collider
- Contact Manifold Generation(Relative Velocity, Contact Normal, CollisionPoint(s), Penetration Depth)
Collision Response:
- Penalty Method (Force/Acceleration based)
- Linear + Angular Impulse Method (Velocity/Momentum based)
- Projection Method (Position based)
-Friction - Linear Force based Friction
- Linear + Angular Friction Impulse (Velocity/Momentum based)
-Restitution(Bounciness)
-Baumgarte Stabilization
-Collision Solver - Gauss-Seidel method (this will probably not be converted as it doesn’t really work in parallel)
Physics Material
- Friction
- Restitution(Bounciness)
Other features
- Mesh skinning/deformation
- Raycasting
- Raycast based Wheel Collider
- Per Node/Body Integration method
- Cloth cutting and tearing (proper mesh separation is not yet implemented)
- Internal Softbody collision
- Procedurally generated softbodies + mesh (currently only Clothplane and Cube)
- Multiple simultaneous physics worlds.