Obi
6.4
Unified particle physics for Unity
|
Classes | |
class | ObiActorSolverArgs |
Public Member Functions | |
delegate void | ActorCallback (ObiActor actor) |
delegate void | ActorStepCallback (ObiActor actor, float stepTime) |
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 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 void | Teleport (Vector3 position, Quaternion rotation) |
Teleports the entire actor to a new location / orientation. More... | |
bool | ActivateParticle (int actorIndex) |
Activates one particle. More... | |
bool | DeactivateParticle (int actorIndex) |
Deactivates one particle. More... | |
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... | |
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... | |
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... | |
void | SaveStateToBlueprint (ObiActorBlueprint bp) |
Resets the position and velocity of all particles, to the values stored in the blueprint. More... | |
void | ClearState () |
virtual void | LoadBlueprint (ObiSolver solver) |
Loads this actor's blueprint into a given solver. Automatically called by ObiSolver. More... | |
virtual void | UnloadBlueprint (ObiSolver solver) |
Unloads this actor's blueprint from a given solver. Automatically called by ObiSolver. More... | |
virtual void | PrepareFrame () |
virtual void | PrepareStep (float stepTime) |
virtual void | BeginStep (float stepTime) |
virtual void | Substep (float substepTime) |
virtual void | EndStep (float substepTime) |
virtual void | Interpolate () |
virtual void | OnSolverVisibilityChanged (bool visible) |
Public Attributes | |
int[] | 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... | |
Protected Member Functions | |
virtual void | Awake () |
virtual void | OnDestroy () |
virtual void | OnEnable () |
virtual void | OnDisable () |
virtual void | OnValidate () |
void | SetSolver (ObiSolver newSolver) |
Forcibly changed the solver in charge of this actor 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 |
Properties | |
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... | |
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... | |
virtual bool | usesCustomExternalForces [get] |
If true, it means external forces aren't applied to the particles directly. More... | |
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... | |
ActorCallback | OnPrepareFrame |
Called at the start of the solver's FixedUpdate (for Fixed and LateFixed updaters) or the solver's Update (for Late updaters) More... | |
ActorStepCallback | OnPrepareStep |
Called at the beginning of a time step, before dirty constraints and active particles have been updated. More... | |
ActorStepCallback | OnBeginStep |
Called at the beginning of a time step, after dirty constraints and active particles have been updated. More... | |
ActorStepCallback | OnSubstep |
Called at the beginning of each substep. More... | |
ActorStepCallback | OnEndStep |
Called at the end of a timestep, after external forces have been reset and collision callbacks called. More... | |
ActorCallback | OnInterpolate |
Called at the end of each frame. More... | |
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.
bool Obi.ObiActor.ActivateParticle | ( | int | actorIndex | ) |
Activates one particle.
actorIndex | Index in the actor arrays of the particle we will activate. |
This operation preserves the relative order of all particles.
void Obi.ObiActor.AddForce | ( | Vector3 | force, |
ForceMode | forceMode | ||
) |
Adds an external force to all particles in the actor.
force | Value expressed in solver space. |
forceMode | Type of "force" applied. |
void Obi.ObiActor.AddTorque | ( | Vector3 | force, |
ForceMode | forceMode | ||
) |
Adds a torque to the actor.
force | Value expressed in solver space. |
forceMode | Type of "torque" applied. |
void Obi.ObiActor.AddToSolver | ( | ) |
Adds this actor to its solver, if any. Automatically called by ObiSolver.
|
virtual |
Copies all data (position, velocity, phase, etc) from one particle to another one.
actorSourceIndex | Index in the actor arrays of the particle we will copy data from. |
actorDestIndex | Index in the actor arrays of the particle we will copy data to. |
Extend this method to implement copying your own custom particle data in custom actors.
bool Obi.ObiActor.DeactivateParticle | ( | int | actorIndex | ) |
Deactivates one particle.
actorIndex | Index in the actor arrays of the particle we will deactivate. |
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.
type | Type of the constraints that will be returned by this method. |
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.
com | The 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.
solverIndex | Index of the particle in the solver arrays. |
solverIndex | First basis vector of the frame. Contains particle radius along this axis in the 4th position. |
solverIndex | Second basis vector of the frame. Contains particle radius along this axis in the 4th position.. |
solverIndex | Third 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.
solverIndex | Index of the particle in the solver arrays. |
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.
solverIndex | Index of the particle in the solver arrays. |
Implements Obi.IObiParticleCollection.
Quaternion Obi.ObiActor.GetParticleOrientation | ( | int | solverIndex | ) |
Given a solver particle index, returns the orientation of that particle in world space.
solverIndex | Index of the particle in the solver arrays. |
Implements Obi.IObiParticleCollection.
Vector3 Obi.ObiActor.GetParticlePosition | ( | int | solverIndex | ) |
Given a solver particle index, returns the position of that particle in world space.
solverIndex | Index of the particle in the solver arrays. |
Implements Obi.IObiParticleCollection.
int Obi.ObiActor.GetParticleRuntimeIndex | ( | int | actorIndex | ) |
Returns the index of this particle in the solver arrays.
actorIndex | Index of the particle in the actor 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.
bool Obi.ObiActor.IsParticleActive | ( | int | actorIndex | ) |
Returns whether a given particle is active.
actorIndex | Index in the actor arrays of the particle. |
|
virtual |
Loads this actor's blueprint into a given solver. Automatically called by ObiSolver.
Reimplemented in Obi.ObiBone, Obi.ObiRod, Obi.ObiRope, Obi.ObiClothBase, Obi.ObiSoftbody, Obi.ObiEmitter, Obi.ObiSkinnedCloth, and Obi.ObiTearableCloth.
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.
void Obi.ObiActor.SaveStateToBlueprint | ( | ObiActorBlueprint | bp | ) |
Resets the position and velocity of all particles, to the values stored in the blueprint.
bp | The 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.
constraintType | Type 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.
newCategory | Category value. |
void Obi.ObiActor.SetFilterMask | ( | int | newMask | ) |
Sets a given mask value for all particles in the actor.
newMask | Mask 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.
mass | The actor's total mass. |
|
virtual |
Updates particle phases in the solver at runtime, including or removing the one-sided flag.
|
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.
|
protected |
Forcibly changed the solver in charge of this actor
newSolver | The 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 |
Teleports the entire actor to a new location / orientation.
position | World space position to teleport the actor to. |
rotation | World 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.
actorIndex | Index in the actor arrays of the particle we will teeleport. |
position | Position to teleport the particle to, expressed in solver space. |
|
virtual |
Unloads this actor's blueprint from a given solver. Automatically called by ObiSolver.
Reimplemented in Obi.ObiBone, Obi.ObiClothBase, Obi.ObiRope, and Obi.ObiTearableCloth.
|
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.
List<int> [] Obi.ObiActor.solverBatchOffsets |
For each of the actor's constraint types, offset of every batch in the solver.
int [] Obi.ObiActor.solverIndices |
Index of each one of the actor's particles in the solver.
|
get |
Amount of particles in use by this actor.
This will always be equal to or smaller than particleCount.
|
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.
|
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.
|
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.
|
getset |
The collision material being used by this actor.
|
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.
|
get |
Amount of particles allocated by this actor.
|
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.
|
get |
The solver in charge of simulating this actor.
This is the first ObiSlver component found up the actor's hierarchy.
|
get |
Reference to the blueprint asset used by this actor.
|
getset |
Whether to use simplices (triangles, edges) for contact generation.
|
get |
If true, it means particles may not be completely spherical, but ellipsoidal.
|
get |
If true, it means external forces aren't applied to the particles directly.
For instance, cloth uses aerodynamic constraints to do so, and fluid uses drag.
|
get |
Whether this actors makes use of particle orientations or not.
ActorStepCallback Obi.ObiActor.OnBeginStep |
Called at the beginning of a time step, after dirty constraints and active particles have been updated.
ActorBlueprintCallback Obi.ObiActor.OnBlueprintLoaded |
Called when the actor blueprint has been loaded into the solver.
ActorBlueprintCallback Obi.ObiActor.OnBlueprintUnloaded |
Called when the actor blueprint has been unloaded from the solver.
ActorStepCallback Obi.ObiActor.OnEndStep |
Called at the end of a timestep, after external forces have been reset and collision callbacks called.
ActorCallback Obi.ObiActor.OnInterpolate |
Called at the end of each frame.
ActorCallback Obi.ObiActor.OnPrepareFrame |
Called at the start of the solver's FixedUpdate (for Fixed and LateFixed updaters) or the solver's Update (for Late updaters)
ActorStepCallback Obi.ObiActor.OnPrepareStep |
Called at the beginning of a time step, before dirty constraints and active particles have been updated.
ActorStepCallback Obi.ObiActor.OnSubstep |
Called at the beginning of each substep.