class MAGES::MeshDeformations::BasePhysicsActor¶
Overview¶
A base class for all physics actors. More…
class BasePhysicsActor: public MonoBehaviour
{
public:
// properties
PhysicsWorld PhysicsWorld;
SimulationMesh SharedSimulationMesh;
SimulationMesh SimulationMesh;
IReadOnlyList StaticParticles;
bool IsPartOfPhysicsWorld;
UnityEvent<PhysicsWorld> AddedToPhysicsWorld;
UnityEvent<PhysicsWorld> RemovedFromPhysicsWorld;
// methods
bool IsParticleStatic(int particleIndex);
void SetStaticParticles(IEnumerable particleIndices);
virtual void AddToPhysicsWorld();
virtual void RemoveFromPhysicsWorld();
};
// direct descendants
class ClothActor;
class DynamicSoftbodyActor;
class PhysicsActor;
class RigidbodyActor;
class RopeActor;
class SoftbodyActor;
Detailed Documentation¶
A base class for all physics actors.
Properties¶
PhysicsWorld PhysicsWorld
Gets or sets the PhysicsWorld that the simulation is or will become part of.
SimulationMesh SharedSimulationMesh
Gets or sets the shared simulation mesh.
The actual runtime simulation SimulationMesh is created from this shared mesh as an instance of it.
SimulationMesh SimulationMesh
Gets the runtime simulation mesh.
IReadOnlyListStaticParticles
Gets the indices of the particles this actor pins in place, in ascending order.
Particles are dynamic by default; only the indices listed here are made static. The list is authored per actor rather than on the SharedSimulationMesh so that it is stored with the scene or prefab. That keeps the authoring intact when the simulation mesh is a sub-asset generated by a ScriptedImporter (such sub-assets are regenerated on every import and cannot be written to).
The indices are applied to the runtime instance built by SimulationMesh, so changes take effect the next time the actor is added to the physics world.
bool IsPartOfPhysicsWorld
Gets a value indicating whether the simulation mesh is part of the physics world.
UnityEvent<PhysicsWorld> AddedToPhysicsWorld
Gets or sets the callback invoked when this actor is added to the physics world.
UnityEvent<PhysicsWorld> RemovedFromPhysicsWorld
Gets or sets the callback invoked when this actor is removed from the physics world.
Methods¶
bool IsParticleStatic(int particleIndex)
Gets a value indicating whether the particle at particleIndex is pinned by this actor.
This reports the actor’s own authoring only. A particle can additionally be static because the shared simulation mesh has Particle.Kinematic baked into it; the two are additive.
Parameters:
particleIndex |
The index of the particle to test. |
Returns:
true if the particle is listed in StaticParticles.
void SetStaticParticles(IEnumerableparticleIndices)
Replaces the set of particles this actor pins in place.
See StaticParticles for when the change takes effect.
Parameters:
particleIndices |
The particle indices to pin, in any order. Duplicates and negative indices are dropped. Pass |
virtual void AddToPhysicsWorld()
Override this function to add the simulation mesh to the physics world.
virtual void RemoveFromPhysicsWorld()
Override this function to remove the simulation mesh from the physics world.