Obi  6.4
Unified particle physics for Unity
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
Obi.ObiRope Class Reference
Inheritance diagram for Obi.ObiRope:
Obi.ObiRopeBase Obi.IDistanceConstraintsUser Obi.IBendConstraintsUser Obi.ObiActor Obi.IObiParticleCollection

Classes

class  ObiRopeTornEventArgs
 

Public Member Functions

delegate void RopeTornCallback (ObiRope rope, ObiRopeTornEventArgs tearInfo)
 
override void LoadBlueprint (ObiSolver solver)
 Loads this actor's blueprint into a given solver. Automatically called by ObiSolver. More...
 
override void UnloadBlueprint (ObiSolver solver)
 Unloads this actor's blueprint from a given solver. Automatically called by ObiSolver. More...
 
override void Substep (float substepTime)
 
bool Tear (ObiStructuralElement element)
 Tears any given rope element. After calling Tear() one or multiple times, a call to RebuildConstraintsFromElements is needed to update the rope particle/constraint representation. More...
 
override void RebuildConstraintsFromElements ()
 Regenerates all rope constraints using rope elements. It's the opposite of RebuildElementsFromConstraints().This should be called anytime the element representation of the rope is changed (adding/removing/updating elements). This is usually the case after tearing the rope or changing its length using a cursor. More...
 
- Public Member Functions inherited from Obi.ObiRopeBase
float CalculateLength ()
 Calculates and returns current rope length, including stretching/compression. More...
 
void RecalculateRestLength ()
 Recalculates the rope's rest length, that is, its length as specified by the blueprint. More...
 
void RecalculateRestPositions ()
 Recalculates all particle rest positions, used when filtering self-collisions. More...
 
void RebuildElementsFromConstraints ()
 Regenerates all rope elements using constraints. It's the opposite of RebuildConstraintsFromElements(). This is automatically called when loading a blueprint, but should also be called when manually altering rope constraints (adding/removing/updating constraints and/or batches). More...
 
ObiStructuralElement GetElementAt (float mu, out float elementMu)
 Returns a rope element that contains a length-normalized coordinate. It will also return the length-normalized coordinate within the element. More...
 
- Public Member Functions inherited from Obi.ObiActor
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 PrepareFrame ()
 
virtual void PrepareStep (float stepTime)
 
virtual void BeginStep (float stepTime)
 
virtual void EndStep (float substepTime)
 
virtual void Interpolate ()
 
virtual void OnSolverVisibilityChanged (bool visible)
 

Public Attributes

bool tearingEnabled = false
 
float tearResistanceMultiplier = 1000
 
int tearRate = 1
 
- Public Attributes inherited from Obi.ObiRopeBase
List< ObiStructuralElementelements = new List<ObiStructuralElement>()
 
- Public Attributes inherited from Obi.ObiActor
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

override void OnValidate ()
 
void ApplyTearing (float substepTime)
 
override void RebuildElementsFromConstraintsInternal ()
 
- Protected Member Functions inherited from Obi.ObiActor
virtual void Awake ()
 
virtual void OnDestroy ()
 
virtual void OnEnable ()
 
virtual void OnDisable ()
 
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

ObiRopeBlueprint m_RopeBlueprint
 
bool _distanceConstraintsEnabled = true
 
float _stretchingScale = 1
 
float _stretchCompliance = 0
 
float _maxCompression = 0
 
bool _bendConstraintsEnabled = true
 
float _bendCompliance = 0
 
float _maxBending = 0.025f
 
float _plasticYield = 0
 
float _plasticCreep = 0
 
- Protected Attributes inherited from Obi.ObiRopeBase
bool m_SelfCollisions = false
 
float restLength_ = 0
 
- Protected Attributes inherited from Obi.ObiActor
int m_ActiveParticleCount = 0
 
ObiSolver m_Solver
 
bool m_Loaded = false
 
ObiCollisionMaterial m_CollisionMaterial
 
bool m_SurfaceCollisions = false
 

Properties

bool selfCollisions [get, set]
 Whether particles in this actor colide with particles using the same phase value. More...
 
bool distanceConstraintsEnabled [get, set]
 Whether this actor's distance constraints are enabled. More...
 
float stretchingScale [get, set]
 Scale value for this actor's distance constraints rest length. More...
 
float stretchCompliance [get, set]
 Compliance of this actor's stretch constraints. More...
 
float maxCompression [get, set]
 Maximum compression this actor's distance constraints can undergo. More...
 
bool bendConstraintsEnabled [get, set]
 Whether this actor's bend constraints are enabled. More...
 
float bendCompliance [get, set]
 Compliance of this actor's bend constraints. More...
 
float maxBending [get, set]
 Max bending value that constraints can undergo before resisting bending. More...
 
float plasticYield [get, set]
 Threshold for plastic behavior. More...
 
float plasticCreep [get, set]
 Percentage of deformation that gets absorbed into the rest shape per second, once deformation goes above the plasticYield threshold. More...
 
float interParticleDistance [get]
 Average distance between consecutive particle centers in this rope. More...
 
override ObiActorBlueprint sourceBlueprint [get]
 
ObiRopeBlueprint ropeBlueprint [get, set]
 
- Properties inherited from Obi.ObiRopeBase
float restLength [get]
 
ObiPath path [get]
 
- Properties inherited from Obi.ObiActor
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]
 
- Properties inherited from Obi.IDistanceConstraintsUser
bool distanceConstraintsEnabled [get, set]
 
float stretchingScale [get, set]
 
float stretchCompliance [get, set]
 
float maxCompression [get, set]
 
- Properties inherited from Obi.IBendConstraintsUser
bool bendConstraintsEnabled [get, set]
 
float bendCompliance [get, set]
 
float maxBending [get, set]
 
float plasticYield [get, set]
 
float plasticCreep [get, set]
 

Events

RopeTornCallback OnRopeTorn
 
- Events inherited from Obi.ObiRopeBase
ActorCallback OnElementsGenerated
 
- Events inherited from Obi.ObiActor
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...
 

Member Function Documentation

override void Obi.ObiRope.LoadBlueprint ( ObiSolver  solver)
virtual

Loads this actor's blueprint into a given solver. Automatically called by ObiSolver.

Reimplemented from Obi.ObiActor.

override void Obi.ObiRope.RebuildConstraintsFromElements ( )
virtual

Regenerates all rope constraints using rope elements. It's the opposite of RebuildElementsFromConstraints().This should be called anytime the element representation of the rope is changed (adding/removing/updating elements). This is usually the case after tearing the rope or changing its length using a cursor.

Reimplemented from Obi.ObiRopeBase.

bool Obi.ObiRope.Tear ( ObiStructuralElement  element)

Tears any given rope element. After calling Tear() one or multiple times, a call to RebuildConstraintsFromElements is needed to update the rope particle/constraint representation.

override void Obi.ObiRope.UnloadBlueprint ( ObiSolver  solver)
virtual

Unloads this actor's blueprint from a given solver. Automatically called by ObiSolver.

Reimplemented from Obi.ObiActor.

Member Data Documentation

float Obi.ObiRope.tearResistanceMultiplier = 1000

Factor that controls how much a structural cloth spring can stretch before breaking.

Property Documentation

float Obi.ObiRope.bendCompliance
getset

Compliance of this actor's bend constraints.

bool Obi.ObiRope.bendConstraintsEnabled
getset

Whether this actor's bend constraints are enabled.

bool Obi.ObiRope.distanceConstraintsEnabled
getset

Whether this actor's distance constraints are enabled.

float Obi.ObiRope.interParticleDistance
get

Average distance between consecutive particle centers in this rope.

float Obi.ObiRope.maxBending
getset

Max bending value that constraints can undergo before resisting bending.

float Obi.ObiRope.maxCompression
getset

Maximum compression this actor's distance constraints can undergo.

This is expressed as a percentage of the scaled rest length.

float Obi.ObiRope.plasticCreep
getset

Percentage of deformation that gets absorbed into the rest shape per second, once deformation goes above the plasticYield threshold.

float Obi.ObiRope.plasticYield
getset

Threshold for plastic behavior.

Once bending goes above this value, a percentage of the deformation (determined by plasticCreep) will be permanently absorbed into the rope's rest shape.

bool Obi.ObiRope.selfCollisions
getset

Whether particles in this actor colide with particles using the same phase value.

float Obi.ObiRope.stretchCompliance
getset

Compliance of this actor's stretch constraints.

float Obi.ObiRope.stretchingScale
getset

Scale value for this actor's distance constraints rest length.

The default is 1. For instamce, a value of 2 will make the distance constraints twice as long, 0.5 will reduce their length in half.

Event Documentation

RopeTornCallback Obi.ObiRope.OnRopeTorn

Called when a constraint is torn.


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