Obi  7.0.5
Unified particle physics for Unity
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
Obi.ObiActor Class Reference
Inheritance diagram for Obi.ObiActor:
Obi.IObiParticleCollection Obi.ObiBone Obi.ObiClothBase Obi.ObiEmitter Obi.ObiPlant Obi.ObiPlant Obi.ObiRopeBase Obi.ObiSoftbody Obi.ObiCloth Obi.ObiSkinnedCloth Obi.ObiTearableCloth Obi.ObiRod Obi.ObiRope

Classes

class  ObiActorSolverArgs
 

Public Member Functions

delegate void ActorCallback (ObiActor actor)
 
delegate void ActorStepCallback (ObiActor actor, float simulatedTime, float substepTime)
 
delegate void ActorBlueprintCallback (ObiActor actor, ObiActorBlueprint blueprint)
 
void AddToSolver ()
 Adds this actor to its solver, if any. Automatically called by ObiSolver. More...
 
void RemoveFromSolver ()
 Remove this actor from its solver, if any. Automatically called by ObiSolver. More...
 
virtual void ProvideDeformableTriangles (ObiNativeIntList deformableTriangles, ObiNativeVector2List deformableUVs)
 
virtual void ProvideDeformableEdges (ObiNativeIntList deformableEdges)
 
virtual int GetDeformableEdgeCount ()
 
virtual bool CopyParticle (int actorSourceIndex, int actorDestIndex)
 Copies all data (position, velocity, phase, etc) from one particle to another one. More...
 
void TeleportParticle (int actorIndex, Vector3 position)
 Teleports one actor particle to a certain position in solver space. More...
 
virtual Matrix4x4 Teleport (Vector3 position, Quaternion rotation)
 Teleports the entire actor to a new location / orientation. More...
 
virtual bool ActivateParticle ()
 Activates one particle. More...
 
virtual bool DeactivateParticle (int actorIndex)
 Deactivates one particle. More...
 
virtual bool IsParticleActive (int actorIndex)
 Returns whether a given particle is active. More...
 
virtual void SetSelfCollisions (bool selfCollisions)
 Updates particle phases in the solver at runtime, including or removing the self-collision flag. More...
 
virtual void SetOneSided (bool oneSided)
 Updates particle phases in the solver at runtime, including or removing the one-sided flag. More...
 
void SetSimplicesDirty ()
 Marks simplices dirty. More...
 
void SetConstraintsDirty (Oni.ConstraintType constraintType)
 Marks a given constraint type as dirty. More...
 
void SetRenderingDirty (Oni.RenderingSystemType rendererType)
 Marks rendering dirty. More...
 
IObiConstraints GetConstraintsByType (Oni.ConstraintType type)
 Returns the data representation of constraints of a given type being simulated by this solver. More...
 
virtual void UpdateParticleProperties ()
 Call when some particle properties have been modified and need updating. More...
 
int GetParticleRuntimeIndex (int actorIndex)
 Returns the index of this particle in the solver arrays. More...
 
Vector3 GetParticlePosition (int solverIndex)
 Given a solver particle index, returns the position of that particle in world space. More...
 
Quaternion GetParticleOrientation (int solverIndex)
 Given a solver particle index, returns the orientation of that particle in world space. More...
 
Vector3 GetParticleRestPosition (int solverIndex)
 Given a solver particle index, returns the rest position of that particle. More...
 
Quaternion GetParticleRestOrientation (int solverIndex)
 Given a solver particle index, returns the rest orientation of that particle. More...
 
void GetParticleAnisotropy (int solverIndex, ref Vector4 b1, ref Vector4 b2, ref Vector4 b3)
 Given a solver particle index, returns the anisotropic frame of that particle in world space. More...
 
float GetParticleMaxRadius (int solverIndex)
 Given a solver particle index, returns the maximum world space radius of that particle, in any axis. More...
 
Color GetParticleColor (int solverIndex)
 Given a solver particle index, returns the color of that particle. More...
 
void SetFilterCategory (int newCategory)
 Sets a given category value for all particles in the actor. More...
 
void SetFilterMask (int newMask)
 Sets a given mask value for all particles in the actor. More...
 
void SetMass (float mass)
 Sets the inverse mass of each particle so that the total actor mass matches the one passed by parameter. More...
 
float GetMass (out Vector3 com)
 Returns the actor's mass (sum of all particle masses), and the position of its center of mass. More...
 
void AddForce (Vector3 force, ForceMode forceMode)
 Adds an external force to all particles in the actor. More...
 
void AddTorque (Vector3 force, ForceMode forceMode)
 Adds a torque to the actor. More...
 
void ResetParticles ()
 Resets the position and velocity of all particles, to the values stored in the blueprint. More...
 
bool SaveStateToBlueprint (ObiActorBlueprint bp)
 Resets the position and velocity of all particles, to the values stored in the blueprint. More...
 
void ClearState ()
 
virtual void SimulationStart (float timeToSimulate, float substepTime)
 
virtual void SimulationEnd (float simulatedTime, float substepTime)
 
virtual void RequestReadback ()
 
virtual void Interpolate (float simulatedTime, float substepTime)
 
virtual void OnSolverVisibilityChanged (bool visible)
 

Public Attributes

ObiNativeIntList solverIndices
 Index of each one of the actor's particles in the solver. More...
 
List< int >[] solverBatchOffsets
 For each of the actor's constraint types, offset of every batch in the solver. More...
 
int groupID = 0
 

Protected Member Functions

virtual void Awake ()
 
virtual void OnDestroy ()
 
virtual void OnEnable ()
 
virtual void OnDisable ()
 
virtual void OnValidate ()
 
void SetSolver (ObiSolver newSolver)
 Forcibly changes the solver in charge of this actor More...
 
void SetMassScale (float scale)
 Sets the mass of all particles in the actor to their blueprint values, multiplied by a scale factor. More...
 
virtual void OnBlueprintRegenerate (ObiActorBlueprint blueprint)
 
void UpdateCollisionMaterials ()
 
virtual void SwapWithFirstInactiveParticle (int actorIndex)
 
void StoreState ()
 

Protected Attributes

int m_ActiveParticleCount = 0
 
ObiSolver m_Solver
 
bool m_Loaded = false
 
ObiCollisionMaterial m_CollisionMaterial
 
bool m_SurfaceCollisions = false
 
float m_MassScale = 1
 

Properties

int deformableEdgesOffset [get, set]
 
ObiSolver solver [get]
 The solver in charge of simulating this actor. More...
 
bool isLoaded [get]
 True if the actor blueprint has been loaded into a solver. If true, it guarantees actor.solver, actor.solverIndices and actor.solverBatchOffsets won't be null. More...
 
ObiCollisionMaterial collisionMaterial [get, set]
 The collision material being used by this actor. More...
 
virtual bool surfaceCollisions [get, set]
 Whether to use simplices (triangles, edges) for contact generation. More...
 
float massScale [get, set]
 Scale applied to this actor's particle masses. More...
 
int particleCount [get]
 Amount of particles allocated by this actor. More...
 
int activeParticleCount [get]
 Amount of particles in use by this actor. More...
 
bool usesOrientedParticles [get]
 Whether this actors makes use of particle orientations or not. More...
 
virtual bool usesAnisotropicParticles [get]
 If true, it means particles may not be completely spherical, but ellipsoidal. More...
 
Oni.SimplexType simplexTypes [get]
 
Matrix4x4 actorLocalToSolverMatrix [get]
 Matrix that transforms from the actor's local space to the solver's local space. More...
 
Matrix4x4 actorSolverToLocalMatrix [get]
 Matrix that transforms from the solver's local space to the actor's local space. More...
 
abstract ObiActorBlueprint sourceBlueprint [get]
 Reference to the blueprint asset used by this actor. More...
 
ObiActorBlueprint sharedBlueprint [get]
 Reference to the blueprint in use by this actor. More...
 
ObiActorBlueprint blueprint [get]
 Returns a unique instance of this actor's sourceBlueprint. More...
 
- Properties inherited from Obi.IObiParticleCollection
int particleCount [get]
 
int activeParticleCount [get]
 
bool usesOrientedParticles [get]
 

Events

ActorBlueprintCallback OnBlueprintLoaded
 Called when the actor blueprint has been loaded into the solver. More...
 
ActorBlueprintCallback OnBlueprintUnloaded
 Called when the actor blueprint has been unloaded from the solver. More...
 
ActorBlueprintCallback OnBlueprintRegenerated
 Called when the blueprint currently in use has been re-generated. This will always be preceded by a call to OnBlueprintUnloaded and OnBlueprintLoaded. More...
 
ActorStepCallback OnSimulationStart
 Called before simulation starts. More...
 
ActorStepCallback OnSimulationEnd
 Called after simulation ends. More...
 
ActorCallback OnRequestReadback
 You can use this callback to issue GPU->CPU readbacks. More...
 
ActorStepCallback OnInterpolate
 Called at the end of each frame, after interpolation but before rendering. More...
 

Detailed Description

Represents a group of related particles. ObiActor does not make any assumptions about the relationship between these particles, except that they get allocated and released together.

Member Function Documentation

virtual bool Obi.ObiActor.ActivateParticle ( )
virtual

Activates one particle.

Returns
True if a particle could be activated. False if there are no particles to activate.

This operation preserves the relative order of all particles.

Reimplemented in Obi.ObiEmitter.

void Obi.ObiActor.AddForce ( Vector3  force,
ForceMode  forceMode 
)

Adds an external force to all particles in the actor.

Parameters
forceValue expressed in solver space.
forceModeType of "force" applied.
void Obi.ObiActor.AddTorque ( Vector3  force,
ForceMode  forceMode 
)

Adds a torque to the actor.

Parameters
forceValue expressed in solver space.
forceModeType of "torque" applied.
void Obi.ObiActor.AddToSolver ( )

Adds this actor to its solver, if any. Automatically called by ObiSolver.

virtual bool Obi.ObiActor.CopyParticle ( int  actorSourceIndex,
int  actorDestIndex 
)
virtual

Copies all data (position, velocity, phase, etc) from one particle to another one.

Parameters
actorSourceIndexIndex in the actor arrays of the particle we will copy data from.
actorDestIndexIndex in the actor arrays of the particle we will copy data to.
Returns
Whether the indices passed are within actor bounds.

Extend this method to implement copying your own custom particle data in custom actors.

virtual bool Obi.ObiActor.DeactivateParticle ( int  actorIndex)
virtual

Deactivates one particle.

Parameters
actorIndexIndex in the actor arrays of the particle we will deactivate.
Returns
True if the particle was active. False if the particle was already inactive.

This operation does not preserve the relative order of other particles, because the last active particle will swap positions with the particle being deactivated.

IObiConstraints Obi.ObiActor.GetConstraintsByType ( Oni.ConstraintType  type)

Returns the data representation of constraints of a given type being simulated by this solver.

Parameters
typeType of the constraints that will be returned by this method.
Returns
The runtime constraints of the type speficied. Most constraints are stored in the blueprint, with a couple notable exceptions: pin and stitch constraints are always created at runtime, so they're not stored in the blueprint but in the actor itself.
float Obi.ObiActor.GetMass ( out Vector3  com)

Returns the actor's mass (sum of all particle masses), and the position of its center of mass.

Parameters
comThe actor's center of mass, expressed in solver space.

Particles with infinite mass (invMass = 0) are ignored.

void Obi.ObiActor.GetParticleAnisotropy ( int  solverIndex,
ref Vector4  b1,
ref Vector4  b2,
ref Vector4  b3 
)

Given a solver particle index, returns the anisotropic frame of that particle in world space.

Parameters
solverIndexIndex of the particle in the solver arrays.
solverIndexFirst basis vector of the frame. Contains particle radius along this axis in the 4th position.
solverIndexSecond basis vector of the frame. Contains particle radius along this axis in the 4th position..
solverIndexThird basis vector of the frame. Contains particle radius along this axis in the 4th position.

Implements Obi.IObiParticleCollection.

Color Obi.ObiActor.GetParticleColor ( int  solverIndex)

Given a solver particle index, returns the color of that particle.

Parameters
solverIndexIndex of the particle in the solver arrays.
Returns
The color of the particle.

Implements Obi.IObiParticleCollection.

float Obi.ObiActor.GetParticleMaxRadius ( int  solverIndex)

Given a solver particle index, returns the maximum world space radius of that particle, in any axis.

Parameters
solverIndexIndex of the particle in the solver arrays.
Returns
The maximum radius of a given particle in world space.

Implements Obi.IObiParticleCollection.

Quaternion Obi.ObiActor.GetParticleOrientation ( int  solverIndex)

Given a solver particle index, returns the orientation of that particle in world space.

Parameters
solverIndexIndex of the particle in the solver arrays.
Returns
The orientation of a given particle in world space.

Implements Obi.IObiParticleCollection.

Vector3 Obi.ObiActor.GetParticlePosition ( int  solverIndex)

Given a solver particle index, returns the position of that particle in world space.

Parameters
solverIndexIndex of the particle in the solver arrays.
Returns
The position of a given particle in world space.

Implements Obi.IObiParticleCollection.

Quaternion Obi.ObiActor.GetParticleRestOrientation ( int  solverIndex)

Given a solver particle index, returns the rest orientation of that particle.

Parameters
solverIndexIndex of the particle in the solver arrays.
Returns
The orientation of a given particle in world space.

Implements Obi.IObiParticleCollection.

Vector3 Obi.ObiActor.GetParticleRestPosition ( int  solverIndex)

Given a solver particle index, returns the rest position of that particle.

Parameters
solverIndexIndex of the particle in the solver arrays.
Returns
The position of a given particle in world space.

Implements Obi.IObiParticleCollection.

int Obi.ObiActor.GetParticleRuntimeIndex ( int  actorIndex)

Returns the index of this particle in the solver arrays.

Parameters
actorIndexIndex of the particle in the actor arrays.
Returns
The index of a given particle in the solver arrays.

At runtime when the blueprint is loaded, this is the same as calling actor.solverIndices[solverIndex]. If the blueprint is not loaded it will return the same index passed to it: actorIndex. Note that this function does not perform any range checking.

Implements Obi.IObiParticleCollection.

virtual bool Obi.ObiActor.IsParticleActive ( int  actorIndex)
virtual

Returns whether a given particle is active.

Parameters
actorIndexIndex in the actor arrays of the particle.
Returns
True if the particle is active. False if the particle is inactive.
void Obi.ObiActor.RemoveFromSolver ( )

Remove this actor from its solver, if any. Automatically called by ObiSolver.

void Obi.ObiActor.ResetParticles ( )

Resets the position and velocity of all particles, to the values stored in the blueprint.

Note however that this does not affect constraints, so if you've torn a cloth/rope or resized a rope, calling ResetParticles won't restore the initial topology of the actor.

bool Obi.ObiActor.SaveStateToBlueprint ( ObiActorBlueprint  bp)

Resets the position and velocity of all particles, to the values stored in the blueprint.

Parameters
bpThe blueprint that we want to fill with current particle data.

Note that this will not resize the blueprint's data arrays, and that it does not perform range checking. For this reason, you must supply a blueprint large enough to store all particles' data.

void Obi.ObiActor.SetConstraintsDirty ( Oni.ConstraintType  constraintType)

Marks a given constraint type as dirty.

Parameters
constraintTypeType of the constraints that need re-creation.

This will cause the solver to perform a constraint re-creation at the start of the next step. Needed when the constraint data in an actor changes at runtime, as a result of changing topology (torn cloth or ropes), or changes in internal constraint parameters such as compliance values. This is a relatively expensive operation, so it's best to amortize as many constraint modification operations as possible in a single step.

void Obi.ObiActor.SetFilterCategory ( int  newCategory)

Sets a given category value for all particles in the actor.

Parameters
newCategoryCategory value.
void Obi.ObiActor.SetFilterMask ( int  newMask)

Sets a given mask value for all particles in the actor.

Parameters
newMaskMask value.
void Obi.ObiActor.SetMass ( float  mass)

Sets the inverse mass of each particle so that the total actor mass matches the one passed by parameter.

Parameters
massThe actor's total mass.
void Obi.ObiActor.SetMassScale ( float  scale)
protected

Sets the mass of all particles in the actor to their blueprint values, multiplied by a scale factor.

Parameters
scalenew mass scale.
virtual void Obi.ObiActor.SetOneSided ( bool  oneSided)
virtual

Updates particle phases in the solver at runtime, including or removing the one-sided flag.

void Obi.ObiActor.SetRenderingDirty ( Oni.RenderingSystemType  rendererType)

Marks rendering dirty.

virtual void Obi.ObiActor.SetSelfCollisions ( bool  selfCollisions)
virtual

Updates particle phases in the solver at runtime, including or removing the self-collision flag.

Reimplemented in Obi.ObiEmitter.

void Obi.ObiActor.SetSimplicesDirty ( )

Marks simplices dirty.

void Obi.ObiActor.SetSolver ( ObiSolver  newSolver)
protected

Forcibly changes the solver in charge of this actor

Parameters
newSolverThe solver we want to put in charge of this actor.

First it removes the actor from its current solver, then changes the actor's current solver and then readds it to this new solver.

virtual Matrix4x4 Obi.ObiActor.Teleport ( Vector3  position,
Quaternion  rotation 
)
virtual

Teleports the entire actor to a new location / orientation.

Parameters
positionWorld space position to teleport the actor to.
rotationWorld space rotation to teleport the actor to.

Reimplemented in Obi.ObiSoftbody.

void Obi.ObiActor.TeleportParticle ( int  actorIndex,
Vector3  position 
)

Teleports one actor particle to a certain position in solver space.

Parameters
actorIndexIndex in the actor arrays of the particle we will teeleport.
positionPosition to teleport the particle to, expressed in solver space.
virtual void Obi.ObiActor.UpdateParticleProperties ( )
virtual

Call when some particle properties have been modified and need updating.

Does not do anything by default. Call when manually modifying particle properties in the solver, should the actor need to do some book keeping. For softbodies, updates their rest state.

Reimplemented in Obi.ObiSoftbody.

Member Data Documentation

List<int> [] Obi.ObiActor.solverBatchOffsets

For each of the actor's constraint types, offset of every batch in the solver.

ObiNativeIntList Obi.ObiActor.solverIndices

Index of each one of the actor's particles in the solver.

Property Documentation

int Obi.ObiActor.activeParticleCount
get

Amount of particles in use by this actor.

This will always be equal to or smaller than particleCount.

Matrix4x4 Obi.ObiActor.actorLocalToSolverMatrix
get

Matrix that transforms from the actor's local space to the solver's local space.

If there's no solver present, this is the same as the actor's local to world matrix.

Matrix4x4 Obi.ObiActor.actorSolverToLocalMatrix
get

Matrix that transforms from the solver's local space to the actor's local space.

If there's no solver present, this is the same as the actor's world to local matrix. This is always the same as the inverse of actorLocalToSolverMatrix.

ObiActorBlueprint Obi.ObiActor.blueprint
get

Returns a unique instance of this actor's sourceBlueprint.

This is mostly used when the actor needs to change some blueprint data at runtime, and you don't want to change the blueprint asset as this would affect all other actors using it. Tearable cloth and ropes make use of this.

ObiCollisionMaterial Obi.ObiActor.collisionMaterial
getset

The collision material being used by this actor.

int Obi.ObiActor.deformableEdgesOffset
getset

index of the first deformable edge in the solver that belongs to this rope.

bool Obi.ObiActor.isLoaded
get

True if the actor blueprint has been loaded into a solver. If true, it guarantees actor.solver, actor.solverIndices and actor.solverBatchOffsets won't be null.

float Obi.ObiActor.massScale
getset

Scale applied to this actor's particle masses.

int Obi.ObiActor.particleCount
get

Amount of particles allocated by this actor.

ObiActorBlueprint Obi.ObiActor.sharedBlueprint
get

Reference to the blueprint in use by this actor.

If you haven't called blueprint before, this will be the same as sourceBlueprint. If you have called blueprint before, it will be the same as blueprint.

ObiSolver Obi.ObiActor.solver
get

The solver in charge of simulating this actor.

This is the first ObiSolver component found up the actor's hierarchy.

abstract ObiActorBlueprint Obi.ObiActor.sourceBlueprint
get

Reference to the blueprint asset used by this actor.

virtual bool Obi.ObiActor.surfaceCollisions
getset

Whether to use simplices (triangles, edges) for contact generation.

virtual bool Obi.ObiActor.usesAnisotropicParticles
get

If true, it means particles may not be completely spherical, but ellipsoidal.

bool Obi.ObiActor.usesOrientedParticles
get

Whether this actors makes use of particle orientations or not.

Event Documentation

ActorBlueprintCallback Obi.ObiActor.OnBlueprintLoaded

Called when the actor blueprint has been loaded into the solver.

ActorBlueprintCallback Obi.ObiActor.OnBlueprintRegenerated

Called when the blueprint currently in use has been re-generated. This will always be preceded by a call to OnBlueprintUnloaded and OnBlueprintLoaded.

ActorBlueprintCallback Obi.ObiActor.OnBlueprintUnloaded

Called when the actor blueprint has been unloaded from the solver.

ActorStepCallback Obi.ObiActor.OnInterpolate

Called at the end of each frame, after interpolation but before rendering.

ActorCallback Obi.ObiActor.OnRequestReadback

You can use this callback to issue GPU->CPU readbacks.

ActorStepCallback Obi.ObiActor.OnSimulationEnd

Called after simulation ends.

ActorStepCallback Obi.ObiActor.OnSimulationStart

Called before simulation starts.


The documentation for this class was generated from the following file: