Obi
6.4
Unified particle physics for Unity
|
Classes | |
class | ObiCollisionEventArgs |
class | ParticleInActor |
Public Types | |
enum | BackendType { Oni, Burst } |
Public Member Functions | |
delegate void | SolverCallback (ObiSolver solver) |
delegate void | SolverStepCallback (ObiSolver solver, float stepTime) |
delegate void | CollisionCallback (ObiSolver solver, ObiCollisionEventArgs contacts) |
void | Initialize () |
void | Teardown () |
void | UpdateBackend () |
void | EnsureRigidbodyArraysCapacity (int count) |
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 | PrepareFrame () |
IObiJobHandle | BeginStep (float stepTime) |
Signals the start of a new time step. More... | |
IObiJobHandle | Substep (float stepTime, float substepTime, int index) |
Schedules the job to advance the simulation a given amount of time, then returns a handle to this job. More... | |
void | EndStep (float substepTime) |
Wraps up a simulation step: resets external forces and calls collision callbacks. More... | |
void | Interpolate (float stepTime, float unsimulatedTime) |
Finalizes the frame by performing physics state interpolation. More... | |
void | ReleaseJobHandles () |
void | SpatialQuery (ObiNativeQueryShapeList shapes, ObiNativeAffineTransformList transforms, ObiNativeQueryResultList results) |
Performs multiple spatial queries in parallel against all simplices in the solver, and returns a list of results. More... | |
QueryResult[] | SpatialQuery (QueryShape shape, AffineTransform transform) |
Performs a single spatial queries against all simplices in the solver, and returns a list of results. More... | |
bool | Raycast (Ray ray, out QueryResult hitInfo, int filter, float maxDistance=100, float rayThickness=0) |
Performs a single raycast against all simplices in the solver, and returns the result. More... | |
QueryResult[] | Raycast (List< Ray > rays, int filter, float maxDistance=100, float rayThickness=0) |
Performs multiple raycasts in parallel against all simplices in the solver, and returns the results. More... | |
Public Attributes | |
bool | simulateWhenInvisible = true |
Oni.SolverParameters | parameters |
Vector3 | gravity = new Vector3(0, -9.81f, 0) |
Space | gravitySpace = Space.Self |
float | worldLinearInertiaScale = 0 |
float | worldAngularInertiaScale = 0 |
List< ObiActor > | actors = new List<ObiActor>() |
ParticleInActor[] | m_ParticleToActor |
List< int > | simplices = new List<int>() |
bool | dirtyActiveParticles = true |
bool | dirtySimplices = true |
int | dirtyConstraints = 0 |
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 | 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) |
Properties | |
ISolverImpl | implementation [get] |
bool | initialized [get] |
IObiBackend | simulationBackend [get] |
BackendType | backendType [get, set] |
SimplexCounts | simplexCounts [get] |
UnityEngine.Bounds | Bounds [get] |
bool | IsVisible [get] |
float | maxScale [get] |
int | allocParticleCount [get] |
int | contactCount [get] |
int | particleContactCount [get] |
ParticleInActor[] | particleToActor [get] |
ObiNativeVector4List | rigidbodyLinearDeltas [get] |
ObiNativeVector4List | rigidbodyAngularDeltas [get] |
Color[] | colors [get] |
ObiNativeInt4List | cellCoords [get] |
ObiNativeVector4List | positions [get] |
ObiNativeVector4List | restPositions [get] |
ObiNativeVector4List | prevPositions [get] |
ObiNativeVector4List | startPositions [get] |
ObiNativeVector4List | renderablePositions [get] |
ObiNativeQuaternionList | orientations [get] |
ObiNativeQuaternionList | restOrientations [get] |
ObiNativeQuaternionList | prevOrientations [get] |
ObiNativeQuaternionList | startOrientations [get] |
ObiNativeQuaternionList | renderableOrientations [get] |
ObiNativeVector4List | velocities [get] |
ObiNativeVector4List | angularVelocities [get] |
ObiNativeFloatList | invMasses [get] |
ObiNativeFloatList | invRotationalMasses [get] |
ObiNativeVector4List | invInertiaTensors [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 | anisotropies [get] |
ObiNativeVector4List | principalRadii [get] |
ObiNativeVector4List | normals [get] |
ObiNativeVector4List | vorticities [get] |
ObiNativeVector4List | fluidData [get] |
ObiNativeVector4List | userData [get] |
ObiNativeFloatList | smoothingRadii [get] |
ObiNativeFloatList | buoyancies [get] |
ObiNativeFloatList | restDensities [get] |
ObiNativeFloatList | viscosities [get] |
ObiNativeFloatList | surfaceTension [get] |
ObiNativeFloatList | vortConfinement [get] |
ObiNativeFloatList | atmosphericDrag [get] |
ObiNativeFloatList | atmosphericPressure [get] |
ObiNativeFloatList | diffusion [get] |
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.
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().
actor | An actor. |
IObiJobHandle Obi.ObiSolver.BeginStep | ( | float | stepTime | ) |
Signals the start of a new time step.
Pushes active particles (if dirtyActiveParticles is true), and runtime constraints (if dirtyConstraints != 0). Updates the solver's nertial reference frame. Calls begin step callbacks. Finally, it schedules execution of simulation tasks at the beginng on a physics step (most notably, collision detection), and returns a handle to the job that will perform them.
stepTime | Duration of the entire time step (in seconds). |
void Obi.ObiSolver.EndStep | ( | float | substepTime | ) |
Wraps up a simulation step: resets external forces and calls collision callbacks.
substepTime | Size of the last substep performed this step (in seconds). |
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.
constraintType | Type of the constraints whose parameters will be returned by this method. |
IObiConstraints Obi.ObiSolver.GetConstraintsByType | ( | Oni.ConstraintType | type | ) |
Returns the runtime representation of constraints of a given type being simulated by this solver.
type | Type of the constraints that will be returned by this method. |
void Obi.ObiSolver.Interpolate | ( | float | stepTime, |
float | unsimulatedTime | ||
) |
Finalizes the frame by performing physics state interpolation.
This is usually used for mesh generation, rendering setup and other tasks that must take place after all physics steps for this frame are done.
stepTime | Duration of this time step (in seconds). Note this is the entire timestep, not just the ast substep. |
unsimulatedTime | Remaining time that could not be simulated during this step (in seconds). This is used to interpolate physics state. |
void Obi.ObiSolver.PushSolverParameters | ( | ) |
Updates solver parameters.
Call this after modifying solver or constraint parameters.
bool Obi.ObiSolver.Raycast | ( | Ray | ray, |
out QueryResult | hitInfo, | ||
int | filter, | ||
float | maxDistance = 100 , |
||
float | rayThickness = 0 |
||
) |
Performs a single raycast against all simplices in the solver, and returns the result.
ray | Ray to cast against all simplices in the solver. Expressed in world space. |
hitInfo | Struct containing hit info, if any. |
filter | Filter (mask, category) used to filter out collisions against certain simplices. |
maxDistance | Ray length. |
rayThickness | Ray 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. |
QueryResult [] Obi.ObiSolver.Raycast | ( | List< Ray > | rays, |
int | filter, | ||
float | maxDistance = 100 , |
||
float | rayThickness = 0 |
||
) |
Performs multiple raycasts in parallel against all simplices in the solver, and returns the results.
rays | List of rays to cast against all simplices in the solver. Expressed in world space. |
filter | Filter (mask, category) used to filter out collisions against certain simplices. |
maxDistance | Ray length. |
rayThickness | Ray 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. |
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.
actor | An actor. |
void Obi.ObiSolver.SpatialQuery | ( | ObiNativeQueryShapeList | shapes, |
ObiNativeAffineTransformList | transforms, | ||
ObiNativeQueryResultList | results | ||
) |
Performs multiple spatial queries in parallel against all simplices in the solver, and returns a list of results.
All other query/raycast methods are built on top of this one. Use it when you need maximum flexibility/performance.
shapes | List of query shapes to test against all simplices in the solver. |
transforms | List of transforms, must have the same size as the shapes list. |
results | This list will contain results for all queries, in no specific order. 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 input shapes list. |
QueryResult [] Obi.ObiSolver.SpatialQuery | ( | QueryShape | shape, |
AffineTransform | transform | ||
) |
Performs a single spatial queries against all simplices in the solver, and returns a list of results.
shape | Query shape to test against all simplices in the solver. |
transform | Transform applied to the query shape. |
IObiJobHandle Obi.ObiSolver.Substep | ( | float | stepTime, |
float | substepTime, | ||
int | index | ||
) |
Schedules the job to advance the simulation a given amount of time, then returns a handle to this job.
substepTime | Amount of time to advance (in seconds). |
Oni.SolverParameters Obi.ObiSolver.parameters |
bool Obi.ObiSolver.simulateWhenInvisible = true |
Whether to keep simulating the cloth when its not visible by any camera.
float Obi.ObiSolver.worldAngularInertiaScale = 0 |
how much does world-space angular inertia affect the actor. This only applies when the solver has "simulateInLocalSpace" enabled.
float Obi.ObiSolver.worldLinearInertiaScale = 0 |
how much does world-space linear inertia affect the actor. This only applies when the solver has "simulateInLocalSpace" enabled.