class MAGES::MeshDeformations::DynamicSoftbodyActor¶
Overview¶
A dynamic softbody actor. More…
class DynamicSoftbodyActor: public MAGES::MeshDeformations::BasePhysicsActor { public: // structs struct ClearCountersJob; struct FindResidualDistanceConstraintsJob; struct InitializeParticleToVertexMappingJob; struct NormalizeNormalsJob; struct RecreateFlatMeshJob; struct RecreateSmoothMeshJob; struct RemoveNeighborsFromDifferentSubMeshesJob; struct RemoveResidualDistanceConstraintsJob; struct RemoveVolumeConstraintsWithLimitedNumberOfNeighbors; struct SubMeshIndexData; struct UpdateKinematicParticlesJob; struct UpdateMeshJob; // classes class SubMeshIndexDatas; // properties override SimulationMesh SharedSimulationMesh; uint Layer; bool UpdateKinematicParticles; bool SmoothShading; bool GenerateFacesInPhysicsMaterialBoundaries; bool RemoveResidualDistanceConstraints; bool RemoveVolumeConstraintsWithLimitedNeighbors; int MinNeighborsBeforeVolumeConstraintsRemoval; // methods virtual override void AddToPhysicsWorld(); virtual override void RemoveFromPhysicsWorld(); DynamicSoftbodySnapshot Save(); void Load(DynamicSoftbodySnapshot snapshot); void CutSplit(Disc cuttingDisc); void CutRemove(Disc cuttingDisc); void GenerateUVMapsFromMesh(Mesh mesh); void GenerateUVMapsFromMesh2(Mesh mesh); static Vector3 ComputeBarycentric(Vector3 p, Vector3 a, Vector3 b, Vector3 c); static Vector3 ClosestPointOnTriangle( Vector3 p, Vector3 a, Vector3 b, Vector3 c ); };
Inherited Members¶
public:
// properties
PhysicsWorld PhysicsWorld;
SimulationMesh SharedSimulationMesh;
SimulationMesh SimulationMesh;
bool IsPartOfPhysicsWorld;
UnityEvent<PhysicsWorld> AddedToPhysicsWorld;
UnityEvent<PhysicsWorld> RemovedFromPhysicsWorld;
// methods
virtual void AddToPhysicsWorld();
virtual void RemoveFromPhysicsWorld();
Detailed Documentation¶
A dynamic softbody actor.
The dynamic softbody, creates the render mesh dyanamically based on the current volume constraints of the simulation mesh.<br> This allows us to cut the softbody based on forces and the render mesh to be automatically updated.
Properties¶
uint Layer
Gets or sets the layer used for collision filtering.
bool UpdateKinematicParticles
Gets or sets a value indicating whether to update the kinematic particles position when this actor’s transform is updated.
bool SmoothShading
Gets or sets a value indicating whether to generate smooth or flat shading for the render mesh.
bool GenerateFacesInPhysicsMaterialBoundaries
Gets or sets a value indicating whether to generate faces (triangles) in the boundaries of the physics material.
bool RemoveResidualDistanceConstraints
Gets or sets a value indicating whether should remove residual distance constraints after a tear.
bool RemoveVolumeConstraintsWithLimitedNeighbors
Gets or sets a value indicating whether after the simulation mesh has been modified, the volume constraints with limited number of neighbors should be removed.
int MinNeighborsBeforeVolumeConstraintsRemoval
Gets or sets the minimum number of neighbors before volume constraints removal.
Methods¶
virtual override void AddToPhysicsWorld()
Override this function to add the simulation mesh to the physics world.
virtual override void RemoveFromPhysicsWorld()
Override this function to remove the simulation mesh from the physics world.
DynamicSoftbodySnapshot Save()
Captures the actor’s current simulation state into a self-contained, immutable snapshot.
The API is stateless: the returned snapshot owns deep copies of the data and the actor keeps no reference to it. Undo/redo stacking is the caller’s responsibility.
While the actor is part of a physics world the live runtime slices are captured (the current, post-cut topology). Otherwise the design-time BasePhysicsActor.SharedSimulationMesh arrays (the pristine baseline) are captured. In both cases particle positions are set to the rest positions, velocities are zeroed and Particle.Kinematic is derived from a zero inverse mass; transient solver state and physics materials are not captured.
Returns:
The captured snapshot, or null if there is no simulation data to capture.
void Load(DynamicSoftbodySnapshot snapshot)
Restores the actor to a previously captured snapshot, discarding the actor’s current simulation state (e.g. undoing a cut).
This is a runtime-only operation: the actor must already be part of a physics world. The current simulation mesh is removed and a rebuilt instance is re-added through the command queue, so the effect lands on the next physics step. The re-add uses float4x4.identity so the snapshot’s world-space rest positions reproduce exactly. Once the add is applied the snapshot’s per-particle and per-constraint enabled flags are re-applied (the add path force-enables everything) and the visible mesh is reconstructed.
Parameters:
snapshot |
The snapshot to restore. Must originate from Save on this actor. |
void CutSplit(Disc cuttingDisc)
Cut the mesh with a disc by splitting intersected tetrahedra. Only allowed to be called from the PhysicsUpdate Event.
Parameters:
cuttingDisc |
The disc based on which to cut. |
void CutRemove(Disc cuttingDisc)
Cut the mesh with a disc by removing intersected tetrahedra. Only allowed to be called from the PhysicsUpdate Event.
Parameters:
cuttingDisc |
The disc based on which to cut. |
void GenerateUVMapsFromMesh(Mesh mesh)
Uses the mesh for generating UV Maps.
Parameters:
mesh |
The mesh to use UV maps from. |
void GenerateUVMapsFromMesh2(Mesh mesh)
Uses the mesh for generating UV Maps.
Parameters:
mesh |
The mesh to use UV maps from. |