Soft body physics component.
Represents the physics simulation data for a deformable object using Jolt's SoftBody system. This component works in conjunction with Object::Component::Mesh which holds the geometry.
Architecture
- Mesh (Object plugin): Contains vertices[], normals[], indices[] for rendering
- SoftBody (Physics plugin): Contains physics settings and per-vertex physics data
- Jolt: Maintains internal vertex copy for simulation (unavoidable)
The SoftBodySystem:
- On construct: Auto-detects Mesh component and initializes physics data
- On update: Writes Jolt simulation results back to Mesh.vertices
Usage
From existing Mesh (e.g., imported .obj):
auto mesh = OBJLoader("model.obj").GetMesh();
auto teapot = core.CreateEntity();
teapot.AddComponent<Transform>(core, position);
teapot.AddComponent<Mesh>(core, mesh);
static SoftBodySettings Balloon(float pressure=1000.0f)
Settings for pressure-based soft bodies (balloons).
Definition SoftBody.hpp:164
SoftBody()=default
Default constructor - creates an empty SoftBody.
Procedural cloth (using Object::Helper):
soft.PinVertex(0);
soft.PinVertex(9);
Engine::Entity CreateCloth(Engine::Core &core, CreateClothInfo info)
Definition CreateShape.cpp:75
static SoftBodySettings Cloth(float stiffness=0.5f)
Settings optimized for cloth simulation.
Definition SoftBody.hpp:121
Note: Collider components (BoxCollider, SphereCollider, etc.) are ignored for SoftBody. Use SoftBodySettings::vertexRadius for collision detection.
- See also
- Object::Component::Mesh
-
Object::Helper::CreateCloth
-
Object::Helper::CreateRope
- Examples
- Creating a 2-unit jelly cube with 5x5x5 grid:, Creating a cloth for soft body simulation:, and Creating a rope for soft body simulation:.