Obi  7.0.5
Unified particle physics for Unity
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
Obi.ObiSolver Class Reference
Inheritance diagram for Obi.ObiSolver:

Classes

class  ParticleInActor
 
class  SpatialQuery
 

Public Types

enum  BackendType { Compute, Burst }
 
enum  Synchronization { Asynchronous, Synchronous, SynchronousFixed }
 

Public Member Functions

delegate void SolverCallback (ObiSolver solver)
 
delegate void SolverStepCallback (ObiSolver solver, float timeToSimulate, float substepTime)
 
delegate void CollisionCallback (ObiSolver solver, ObiNativeContactList contacts)
 
delegate void SpatialQueryCallback (ObiSolver solver, ObiNativeQueryResultList results)
 
void OnEnable ()
 
void Initialize ()
 
void Teardown ()
 
void UpdateBackend ()
 
void EnsureRigidbodyArraysCapacity (int count)
 
void StartSimulation (float stepDelta, int simulationSteps)
 
void CompleteSimulation ()
 
void Render (float unsimulatedTime)
 Performs physics state interpolation and updates rendering. More...
 
bool AddActor (ObiActor actor)
 Adds an actor to the solver. More...
 
bool RemoveActor (ObiActor actor)
 Attempts to remove an actor from this solver, and returns whether this was sucessful or not. More...
 
void PushSolverParameters ()
 Updates solver parameters. More...
 
Oni.ConstraintParameters GetConstraintParameters (Oni.ConstraintType constraintType)
 Returns the parameters used by a given constraint type. More...
 
IObiConstraints GetConstraintsByType (Oni.ConstraintType type)
 Returns the runtime representation of constraints of a given type being simulated by this solver. More...
 
void RegisterRenderSystem (IRenderSystem renderSystem)
 
void UnregisterRenderSystem (IRenderSystem renderSystem)
 
RenderSystem< T > GetRenderSystem< T > ()
 
IRenderSystem GetRenderSystem (Oni.RenderingSystemType type)
 
int EnqueueSpatialQuery (QueryShape shape, AffineTransform transform)
 Enqueues a generic spatial query to be performed during the next physics update. If called when the solver is yet uninitialized, the query will be ignored and this method will return -1. More...
 
int EnqueueSpatialQueries (ObiNativeQueryShapeList shapes, ObiNativeAffineTransformList transforms)
 Enqueues multiple generic spatial query to be performed during the next physics update. If called when the solver is yet uninitialized, the query will be ignored and this method will return -1. More...
 
int EnqueueRaycast (Ray ray, int filter, float maxDistance=100, float rayThickness=0)
 Enqueues a raycast to be performed during the next physics update. If called when the solver is yet uninitialized, the query will be ignored and this method will return -1. More...
 

Public Attributes

bool simulateWhenInvisible = true
 
int substeps = 4
 
int maxStepsPerFrame = 1
 
Synchronization synchronization = Synchronization.Asynchronous
 
Oni.SolverParameters parameters
 
uint maxQueryResults = 8192
 
uint maxFoamParticles = 8192
 
uint maxParticleNeighbors = 128
 
uint maxParticleContacts = 6
 
Vector3 gravity = new Vector3(0, -9.81f, 0)
 
Space gravitySpace = Space.Self
 
Vector3 ambientWind = new Vector3(0, 0, 0)
 
Space windSpace = Space.Self
 
int foamSubsteps = 1
 
float maxFoamVelocityStretch = 0.3f
 
Vector2 foamFade = new Vector2(0.05f, 0.8f)
 
Vector2 foamAccelAgingRange = new Vector2(0.5f, 0.8f)
 
float foamAccelAging = 4
 
float worldLinearInertiaScale = 0
 
float worldAngularInertiaScale = 0
 
List< ObiActoractors = new List<ObiActor>()
 
ObiNativeIntList deformableTriangles
 
ObiNativeIntList deformableEdges
 
ObiNativeVector2List deformableUVs
 
SimplexCounts m_SimplexCounts
 
bool dirtyDeformableTriangles = true
 
bool dirtyDeformableEdges = true
 
Oni.SimplexType dirtySimplices = Oni.SimplexType.All
 
int dirtyRendering = 0
 
int dirtyConstraints = 0
 
bool synchronousSpatialQueries = false
 
Oni.ConstraintParameters distanceConstraintParameters = new Oni.ConstraintParameters(true, Oni.ConstraintParameters.EvaluationOrder.Sequential, 1)
 
Oni.ConstraintParameters bendingConstraintParameters = new Oni.ConstraintParameters(true, Oni.ConstraintParameters.EvaluationOrder.Parallel, 1)
 
Oni.ConstraintParameters particleCollisionConstraintParameters = new Oni.ConstraintParameters(true, Oni.ConstraintParameters.EvaluationOrder.Sequential, 1)
 
Oni.ConstraintParameters particleFrictionConstraintParameters = new Oni.ConstraintParameters(true, Oni.ConstraintParameters.EvaluationOrder.Parallel, 1)
 
Oni.ConstraintParameters collisionConstraintParameters = new Oni.ConstraintParameters(true, Oni.ConstraintParameters.EvaluationOrder.Sequential, 1)
 
Oni.ConstraintParameters frictionConstraintParameters = new Oni.ConstraintParameters(true, Oni.ConstraintParameters.EvaluationOrder.Parallel, 1)
 
Oni.ConstraintParameters skinConstraintParameters = new Oni.ConstraintParameters(true, Oni.ConstraintParameters.EvaluationOrder.Sequential, 1)
 
Oni.ConstraintParameters volumeConstraintParameters = new Oni.ConstraintParameters(true, Oni.ConstraintParameters.EvaluationOrder.Parallel, 1)
 
Oni.ConstraintParameters shapeMatchingConstraintParameters = new Oni.ConstraintParameters(true, Oni.ConstraintParameters.EvaluationOrder.Parallel, 1)
 
Oni.ConstraintParameters tetherConstraintParameters = new Oni.ConstraintParameters(true, Oni.ConstraintParameters.EvaluationOrder.Parallel, 1)
 
Oni.ConstraintParameters pinConstraintParameters = new Oni.ConstraintParameters(true, Oni.ConstraintParameters.EvaluationOrder.Parallel, 1)
 
Oni.ConstraintParameters pinholeConstraintParameters = new Oni.ConstraintParameters(true, Oni.ConstraintParameters.EvaluationOrder.Parallel, 1)
 
Oni.ConstraintParameters stitchConstraintParameters = new Oni.ConstraintParameters(true, Oni.ConstraintParameters.EvaluationOrder.Parallel, 1)
 
Oni.ConstraintParameters densityConstraintParameters = new Oni.ConstraintParameters(true, Oni.ConstraintParameters.EvaluationOrder.Parallel, 1)
 
Oni.ConstraintParameters stretchShearConstraintParameters = new Oni.ConstraintParameters(true, Oni.ConstraintParameters.EvaluationOrder.Sequential, 1)
 
Oni.ConstraintParameters bendTwistConstraintParameters = new Oni.ConstraintParameters(true, Oni.ConstraintParameters.EvaluationOrder.Sequential, 1)
 
Oni.ConstraintParameters chainConstraintParameters = new Oni.ConstraintParameters(false, Oni.ConstraintParameters.EvaluationOrder.Sequential, 1)
 
int pendingQueryCount => bufferedQueryShapes.count
 
int activeParticleCount => activeParticles.count
 

Properties

uint maxSurfaceChunks [get, set]
 
uint usedSurfaceChunks [get]
 
float timeSinceSimulationStart [get, set]
 
bool dirtyActiveParticles [get, set]
 
ISolverImpl implementation [get, set]
 
bool initialized [get]
 
IObiBackend simulationBackend [get]
 
BackendType backendType [get, set]
 
SimplexCounts simplexCounts [get]
 
UnityEngine.Bounds bounds [get]
 Solver bounds expressed in world space. More...
 
UnityEngine.Bounds localBounds [get]
 Solver bounds expressed in the solver's local space. More...
 
bool isVisible [get, set]
 
float maxScale = true [get, set]
 
bool simulationInFlight = 1 [get, set]
 
int allocParticleCount [get]
 
int contactCount [get]
 
int particleContactCount [get]
 
ParticleInActor[] particleToActor [get]
 
ObiNativeIntList activeParticles [get]
 
ObiNativeIntList simplices [get]
 
ObiNativeIntList points [get]
 
ObiNativeIntList edges [get]
 
ObiNativeIntList triangles [get]
 
ObiNativeVector4List rigidbodyLinearDeltas [get]
 
ObiNativeVector4List rigidbodyAngularDeltas [get]
 
ObiNativeColorList colors [get]
 
ObiNativeInt4List cellCoords [get]
 
ObiNativeVector4List positions [get]
 
ObiNativeVector4List prevPositions [get]
 
ObiNativeVector4List restPositions [get]
 
ObiNativeVector4List startPositions [get]
 
ObiNativeVector4List endPositions [get]
 
ObiNativeVector4List renderablePositions [get]
 
ObiNativeQuaternionList orientations [get]
 
ObiNativeQuaternionList prevOrientations [get]
 
ObiNativeQuaternionList restOrientations [get]
 
ObiNativeQuaternionList startOrientations [get]
 
ObiNativeQuaternionList endOrientations [get]
 
ObiNativeQuaternionList renderableOrientations [get]
 
ObiNativeVector4List velocities [get]
 
ObiNativeVector4List angularVelocities [get]
 
ObiNativeFloatList invMasses [get]
 
ObiNativeFloatList invRotationalMasses [get]
 
ObiNativeVector4List externalForces [get]
 
ObiNativeVector4List externalTorques [get]
 
ObiNativeVector4List wind [get]
 
ObiNativeVector4List positionDeltas [get]
 
ObiNativeQuaternionList orientationDeltas [get]
 
ObiNativeIntList positionConstraintCounts [get]
 
ObiNativeIntList orientationConstraintCounts [get]
 
ObiNativeIntList collisionMaterials [get]
 
ObiNativeIntList phases [get]
 
ObiNativeIntList filters [get]
 
ObiNativeVector4List renderableRadii [get]
 
ObiNativeVector4List principalRadii [get]
 
ObiNativeVector4List normals [get]
 
ObiNativeFloatList life [get]
 
ObiNativeVector4List fluidData [get]
 
ObiNativeVector4List userData [get]
 
ObiNativeVector4List fluidInterface [get]
 
ObiNativeVector4List fluidMaterials [get]
 
ObiNativeMatrix4x4List anisotropies [get]
 
ObiNativeVector4List foamPositions [get]
 
ObiNativeVector4List foamVelocities [get]
 
ObiNativeVector4List foamColors [get]
 
ObiNativeVector4List foamAttributes [get]
 
ObiNativeIntList foamCount [get]
 
ObiNativeContactList colliderContacts [get]
 
ObiNativeContactList particleContacts [get]
 
ObiNativeEffectiveMassesList contactEffectiveMasses [get]
 
ObiNativeEffectiveMassesList particleContactEffectiveMasses [get]
 
ObiNativeQueryResultList queryResults [get]
 

Events

CollisionCallback OnCollision
 
CollisionCallback OnParticleCollision
 
SpatialQueryCallback OnSpatialQueryResults
 
SolverCallback OnAdvection
 
SolverCallback OnInitialize
 
SolverCallback OnTeardown
 
SolverCallback OnUpdateParameters
 
SolverCallback OnParticleCountChanged
 
SolverStepCallback OnSimulationStart
 
SolverCallback OnRequestReadback
 
SolverStepCallback OnSimulationEnd
 
SolverStepCallback OnInterpolate
 

Detailed Description

ObiSolver simulates particles and constraints, provided by a list of ObiActor. Particles belonging to different solvers won't interact with each other in any way.

Member Function Documentation

bool Obi.ObiSolver.AddActor ( ObiActor  actor)

Adds an actor to the solver.

Attemps to add the actor to this solver returning whether this was successful or not. In case the actor was already added, or had no reference to a blueprint, this operation will return false. If this was the first actor added to the solver, will attempt to initialize the solver. While in play mode, if the actor is sucessfully added to the solver, will also call actor.LoadBlueprint().

Parameters
actorAn actor.
Returns
Whether the actor was sucessfully added.
int Obi.ObiSolver.EnqueueRaycast ( Ray  ray,
int  filter,
float  maxDistance = 100,
float  rayThickness = 0 
)

Enqueues a raycast to be performed during the next physics update. If called when the solver is yet uninitialized, the query will be ignored and this method will return -1.

Parameters
rayRay to cast against all simplices in the solver. Expressed in world space.
filterFilter (mask, category) used to filter out collisions against certain simplices.
maxDistanceRay length.
rayThicknessRay thickness. If the ray hits a simplex, hitInfo will contain a point on the simplex. If it merely passes near the simplex (within its thickness distance, but no actual hit), it will contain the point on the ray closest to the simplex surface.
Returns
Index of the query in the queue. Use the queryIndex member of each query result to correlate each result to the query that spawned it. For instance: a query result with queryIndex 5, belongs to the query shape at index 5 in the queue.
int Obi.ObiSolver.EnqueueSpatialQueries ( ObiNativeQueryShapeList  shapes,
ObiNativeAffineTransformList  transforms 
)

Enqueues multiple generic spatial query to be performed during the next physics update. If called when the solver is yet uninitialized, the query will be ignored and this method will return -1.

Parameters
shapesQuery shapes to test against all simplices in the solver.
transformsTransforms to apply to the query shapes.
Returns
Index of the first query in the queue. Use the queryIndex member of each query result to correlate each result to the query that spawned it. For instance: a query result with queryIndex 5, belongs to the query shape at index 5 in the queue.
int Obi.ObiSolver.EnqueueSpatialQuery ( QueryShape  shape,
AffineTransform  transform 
)

Enqueues a generic spatial query to be performed during the next physics update. If called when the solver is yet uninitialized, the query will be ignored and this method will return -1.

Parameters
shapeQuery shape to test against all simplices in the solver.
transformTransform to apply to the query shape.
Returns
Index of the query in the queue. Use the queryIndex member of each query result to correlate each result to the query that spawned it. For instance: a query result with queryIndex 5, belongs to the query shape at index 5 in the queue.
Oni.ConstraintParameters Obi.ObiSolver.GetConstraintParameters ( Oni.ConstraintType  constraintType)

Returns the parameters used by a given constraint type.

If you know the type of the constraints at runtime, this is the same as directly accessing the appropiate public Oni.ConstraintParameters struct in the solver.

Parameters
constraintTypeType of the constraints whose parameters will be returned by this method.
Returns
Parameters for the constraints of the specified type.
IObiConstraints Obi.ObiSolver.GetConstraintsByType ( Oni.ConstraintType  type)

Returns the runtime 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.
void Obi.ObiSolver.PushSolverParameters ( )

Updates solver parameters.

Call this after modifying solver or constraint parameters.

bool Obi.ObiSolver.RemoveActor ( ObiActor  actor)

Attempts to remove an actor from this solver, and returns whether this was sucessful or not.

Will only reurn true if the actor had been previously added successfully to this solver. If the actor is sucessfully removed from the solver, will also call actor.UnloadBlueprint(). Once the last actor is removed from the solver, this method will attempt to tear down the solver.

Parameters
actorAn actor.
Returns
Whether the actor was sucessfully removed.
void Obi.ObiSolver.Render ( float  unsimulatedTime)

Performs physics state interpolation and updates rendering.

Parameters
unsimulatedTimeRemaining time that could not be simulated during this frame (in seconds). This is used to interpolate physics state.

Member Data Documentation

Oni.SolverParameters Obi.ObiSolver.parameters
Initial value:
= new Oni.SolverParameters(Oni.SolverParameters.Interpolation.None,
new Vector4(0, -9.81f, 0, 0))
float Obi.ObiSolver.worldAngularInertiaScale = 0

how much does world-space angular inertia affect particles in the solver.

float Obi.ObiSolver.worldLinearInertiaScale = 0

how much does world-space linear inertia affect particles in the solver

Property Documentation

UnityEngine.Bounds Obi.ObiSolver.bounds
get

Solver bounds expressed in world space.

UnityEngine.Bounds Obi.ObiSolver.localBounds
get

Solver bounds expressed in the solver's local space.

Event Documentation

SolverStepCallback Obi.ObiSolver.OnInterpolate

Called every frame after interpolation, right before updating rendering.

SolverStepCallback Obi.ObiSolver.OnSimulationEnd

Called at the end of physics simulation.

SolverStepCallback Obi.ObiSolver.OnSimulationStart

Called at the start of physics simulation, before updating active particles, constraints, etc.


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