Struct Simulation
Steps a physics world.
Inherited Members
Namespace: Unity.Physics
Assembly: Unity.Physics.dll
Syntax
public struct Simulation : ISimulation, IDisposable
Properties
CollisionEvents
Gets the collision events.
Declaration
public CollisionEvents CollisionEvents { get; }
Property Value
| Type | Description |
|---|---|
| CollisionEvents | The collision events. |
Contacts
Gets the contacts stream. This value is only valid after the CreateContactsJob (Narrowphase System), and before BuildJacobiansJob (CreateJacobiansSystem)
Declaration
public readonly NativeStream Contacts { get; }
Property Value
| Type | Description |
|---|---|
| NativeStream | The contacts stream-->. |
FinalJobHandle
Gets the handle of the final job.
Declaration
public JobHandle FinalJobHandle { get; }
Property Value
| Type | Description |
|---|---|
| JobHandle | The final job handle. |
FinalSimulationJobHandle
Gets the handle of the final simulation job (not including dispose jobs).
Declaration
public JobHandle FinalSimulationJobHandle { get; }
Property Value
| Type | Description |
|---|---|
| JobHandle | The final simulation job handle. |
ImpulseEvents
Gets the impulse events.
Declaration
public ImpulseEvents ImpulseEvents { get; }
Property Value
| Type | Description |
|---|---|
| ImpulseEvents | The impulse events. |
TriggerEvents
Gets the trigger events.
Declaration
public TriggerEvents TriggerEvents { get; }
Property Value
| Type | Description |
|---|---|
| TriggerEvents | The trigger events. |
Type
Gets the simulation type.
Declaration
public SimulationType Type { get; }
Property Value
| Type | Description |
|---|---|
| SimulationType |
Methods
Create()
Creates a new Simulation.
Declaration
public static Simulation Create()
Returns
| Type | Description |
|---|---|
| Simulation | A Simulation. |
Dispose()
Disposes the simulation.
Declaration
public void Dispose()
ResetSimulationContext(SimulationStepInput)
Resets the simulation storage
- Reallocates input velocities storage if necessary
- Disposes event streams and allocates new ones with a single work item
Declaration
public void ResetSimulationContext(SimulationStepInput input)
Parameters
| Type | Name | Description |
|---|---|---|
| SimulationStepInput | input | The input. |
ScheduleBroadphaseJobs(SimulationStepInput, JobHandle, bool)
Schedule broadphase jobs.
Declaration
public SimulationJobHandles ScheduleBroadphaseJobs(SimulationStepInput input, JobHandle inputDeps, bool multiThreaded = true)
Parameters
| Type | Name | Description |
|---|---|---|
| SimulationStepInput | input | The input. |
| JobHandle | inputDeps | The input deps. |
| bool | multiThreaded | (Optional) True if multi threaded. |
Returns
| Type | Description |
|---|---|
| SimulationJobHandles | The SimulationJobHandles. |
ScheduleCreateJacobiansJobs(SimulationStepInput, JobHandle, bool)
Schedule create jacobians jobs.
Declaration
public SimulationJobHandles ScheduleCreateJacobiansJobs(SimulationStepInput input, JobHandle inputDeps, bool multiThreaded = true)
Parameters
| Type | Name | Description |
|---|---|---|
| SimulationStepInput | input | The input. |
| JobHandle | inputDeps | The input deps. |
| bool | multiThreaded | (Optional) True if multi threaded. |
Returns
| Type | Description |
|---|---|
| SimulationJobHandles | The SimulationJobHandles. |
ScheduleNarrowphaseJobs(SimulationStepInput, JobHandle, bool)
Schedule narrowphase jobs.
Declaration
public SimulationJobHandles ScheduleNarrowphaseJobs(SimulationStepInput input, JobHandle inputDeps, bool multiThreaded = true)
Parameters
| Type | Name | Description |
|---|---|---|
| SimulationStepInput | input | The input. |
| JobHandle | inputDeps | The input deps. |
| bool | multiThreaded | (Optional) True if multi threaded. |
Returns
| Type | Description |
|---|---|
| SimulationJobHandles | The SimulationJobHandles. |
ScheduleSolveAndIntegrateJobs(SimulationStepInput, JobHandle, bool)
Schedule solve and integrate jobs.
Declaration
public SimulationJobHandles ScheduleSolveAndIntegrateJobs(SimulationStepInput input, JobHandle inputDeps, bool multiThreaded = true)
Parameters
| Type | Name | Description |
|---|---|---|
| SimulationStepInput | input | The input. |
| JobHandle | inputDeps | The input deps. |
| bool | multiThreaded | (Optional) True if multi threaded. |
Returns
| Type | Description |
|---|---|
| SimulationJobHandles | The SimulationJobHandles. |
ScheduleStepJobs(SimulationStepInput, JobHandle, bool)
Schedule all the jobs for the simulation step. Enqueued callbacks can choose to inject additional jobs at defined sync points. multiThreaded defines which simulation type will be called: - true will result in default multithreaded simulation - false will result in a very small number of jobs (1 per physics step phase) that are scheduled sequentially Behavior doesn't change regardless of the multiThreaded argument provided.
Declaration
public SimulationJobHandles ScheduleStepJobs(SimulationStepInput input, JobHandle inputDeps, bool multiThreaded = true)
Parameters
| Type | Name | Description |
|---|---|---|
| SimulationStepInput | input | The input. |
| JobHandle | inputDeps | The input deps. |
| bool | multiThreaded | (Optional) True if multi threaded. |
Returns
| Type | Description |
|---|---|
| SimulationJobHandles | The SimulationJobHandles. |
Step(SimulationStepInput)
Steps the world immediately.
Declaration
public void Step(SimulationStepInput input)
Parameters
| Type | Name | Description |
|---|---|---|
| SimulationStepInput | input | The input. |
StepImmediate(SimulationStepInput, ref SimulationContext)
Steps the simulation immediately on a single thread without spawning any jobs.
Declaration
public static void StepImmediate(SimulationStepInput input, ref SimulationContext simulationContext)
Parameters
| Type | Name | Description |
|---|---|---|
| SimulationStepInput | input | The input. |
| SimulationContext | simulationContext | [in,out] Context for the simulation. |