34 [[nodiscard(
"check soft-body creation")]]
50 [[nodiscard(
"check soft-body creation")]]
52 float originY,
float originZ);
60 void update(
float dt);
62 [[nodiscard(
"check the soft-body step outcome")]]
70 return SimulationDeterminism::ToleranceBounded;
73 [[nodiscard(
"check soft-body observation restore")]]
77 void setGravity(
float x,
float y,
float z);
85 void setDeformationResistance(
float value);
87 [[nodiscard]]
float getDeformationResistance()
const;
89 void setIterations(
int value);
93 void setDamping(
float value);
95 [[nodiscard]]
float getDamping()
const {
return damping_; }
97 void setParticleRadius(
float value);
99 [[nodiscard]]
float getParticleRadius()
const;
101 void setParticleMass(
float value);
105 void setPlasticity(
float yield,
float creep,
float recovery,
float maxDeformation);
107 [[nodiscard]]
float getPlasticYield()
const;
109 [[nodiscard]]
float getPlasticCreep()
const;
111 [[nodiscard]]
float getPlasticRecovery()
const;
113 [[nodiscard]]
float getMaxDeformation()
const;
126 void unpin(
int index);
128 [[nodiscard]]
bool isPinned(
int index)
const;
130 [[nodiscard]]
int grabAt(
float x,
float y,
float z,
float radius);
132 void moveGrab(
float x,
float y,
float z);
136 [[nodiscard]]
bool isGrabbing()
const {
return grabIndex_ >= 0; }
140 void applyForce(
float x,
float y,
float z);
152 [[nodiscard]]
World3D* getCollideWorld()
const;
159 ownedCollisionWorld_.reset();
161 collisionWorld_ =
world;
169 [[nodiscard]]
bool isDestroyed() const noexcept {
return destroyed_; }
171 [[nodiscard]]
int getCols()
const {
return cols_; }
172 [[nodiscard]]
int getRows()
const {
return rows_; }
173 [[nodiscard]]
int getLayers()
const;
175 [[nodiscard]]
float getParticleX(
int index)
const;
176 [[nodiscard]]
float getParticleY(
int index)
const;
177 [[nodiscard]]
float getParticleZ(
int index)
const;
178 void setParticlePosition(
int index,
float x,
float y,
float z);
180 [[nodiscard]]
float getVolumeRatio()
const;
191 float plastic[8][3]{};
195 [[nodiscard]]
bool validIndex(
int index)
const noexcept;
196 [[nodiscard]]
int indexOf(
int x,
int y,
int z)
const noexcept;
197 void updateSubsteps(
float dt,
int substeps);
198 void integrate(
float dt);
199 void solveShapeMatching(
float dt);
200 void solveSelfCollision();
201 void collideWorld(
float dt);
202 void collideBounds();
204 int cols_ = 0, rows_ = 0, layers_ = 0;
205 float spacing_ = 1.f;
206 std::vector<Particle> particles_;
207 std::vector<Cluster> clusters_;
208 float gravityX_ = 0.f, gravityY_ = -9.8f, gravityZ_ = 0.f;
209 float forceX_ = 0.f, forceY_ = 0.f, forceZ_ = 0.f;
210 float damping_ = 0.04f;
211 float deformationResistance_ = 0.8f;
212 float particleRadius_ = 0.2f;
213 float particleMass_ = 0.1f;
215 bool selfCollision_ =
false;
216 float plasticYield_ = 0.f, plasticCreep_ = 0.f, plasticRecovery_ = 0.f, maxDeformation_ = 0.f;
217 bool hasBounds_ =
false;
218 float boundX_ = 0.f, boundY_ = 0.f, boundZ_ = 0.f;
219 float boundW_ = 0.f, boundH_ = 0.f, boundD_ = 0.f;
221 float grabX_ = 0.f, grabY_ = 0.f, grabZ_ = 0.f;
222 bool hasInteraction_ =
false;
223 float interactX_ = 0.f, interactY_ = 0.f, interactZ_ = 0.f;
224 float interactRadius_ = 0.f, interactStrength_ = 0.f;
226 softbody::ISoftBodyCollisionWorld* collisionWorld_ =
nullptr;
227 std::unique_ptr<softbody::ISoftBodyCollisionWorld> ownedCollisionWorld_;
228 bool destroyed_ =
false;
229 SimulationObservation observation_{};
#define EVENGINE_API_BACKENDS
std::vector< std::uint32_t > indices
Backend-neutral, observable fixed-step contract for physics domains.
TerrainThermalSettings settings
Move-only operation result carrying either a value or Status.
Minimal observable contract for physics simulation providers.
Volumetric particle soft body using overlapping shape-matching clusters.
SimulationBackendKind kind() const noexcept override
Identifies the built-in CPU implementation.
bool isDestroyed() const noexcept
Whether destroy() has disabled this runtime instance.
SimulationDeterminism determinism() const noexcept override
Results are repeatable within documented floating-point tolerance.
int getParticleCount() const
float getGravityY() const
Returns the gravity y.
float getParticleMass() const
Returns the particle mass.
void releaseGrab()
Release grab.
float getGravityZ() const
Returns the gravity z.
void setCollisionWorld(softbody::ISoftBodyCollisionWorld *world)
Set a backend-neutral borrowed collision provider. @lifetime The provider must outlive this object or...
SimulationObservation observation() const noexcept override
Returns completed fixed-step metadata by value.
bool getSelfCollision() const
Returns the self collision.
int getIterations() const
Returns the iterations.
SoftBody3D & operator=(const SoftBody3D &)=delete
bool isGrabbing() const
True when grabbing.
int getGrabIndex() const
Returns the grab index.
SoftBody3D(const SoftBody3D &)=delete
float getDamping() const
Returns the damping.
void clearBounds()
Clears bounds.
float getGravityX() const
Returns the gravity x.
void setSelfCollision(bool enabled)
Sets the self collision.
Box3D rigid-body world. Script coordinates are meters (Box3D native), unlike 2D World which uses pixe...
Narrow borrowed collision service consumed by the soft-body core.
Optional physics backend for vehicle mobility and body attach.
SimulationBackendKind
Kind of implementation that owns a simulation step.
SimulationDeterminism
Determinism guarantee made by a simulation backend.
One deterministic fixed-step emitted by SimulationClock.
Observable backend progress shared by CPU and accelerator providers.
Validated solver policy for one simulation step.
Versioned, owning creation definition for one volumetric soft body.