// Schedule all the jobs for the simulation step. public SimulationJobHandles ScheduleStepJobs(PhysicsWorld physicsWorld, PhysicsCallbacks physicsCallbacks, JobHandle inputDeps) { var physicsSettings = physicsWorld.Settings; SafetyChecks.IsFalse(physicsWorld.TimeStep < 0f); SimulationContext.Reset(ref physicsWorld, false); SimulationContext.TimeStep = physicsWorld.TimeStep; if (physicsWorld.DynamicBodyCount == 0) { // No need to do anything, since nothing can move m_StepHandles = new SimulationJobHandles(inputDeps); return(m_StepHandles); } // Execute phase callback. var handle = physicsCallbacks.ScheduleCallbacksForPhase(PhysicsCallbacks.Phase.PreStepSimulation, ref physicsWorld, inputDeps); // Apply gravity and copy input velocities at this point (in parallel with the scheduler, but before the callbacks) handle = Solver.ScheduleApplyGravityAndCopyInputVelocitiesJob( ref physicsWorld.DynamicsWorld, SimulationContext.InputVelocities, physicsWorld.TimeStep * physicsSettings.Gravity, handle, physicsSettings.NumberOfThreadsHint); handle = physicsCallbacks.ScheduleCallbacksForPhase(PhysicsCallbacks.Phase.PostCreateOverlapBodies, ref physicsWorld, handle); handle = physicsCallbacks.ScheduleCallbacksForPhase(PhysicsCallbacks.Phase.PostCreateContacts, ref physicsWorld, handle); handle = physicsCallbacks.ScheduleCallbacksForPhase(PhysicsCallbacks.Phase.PostCreateConstraints, ref physicsWorld, handle); // Integrate motions. handle = Integrator.ScheduleIntegrateJobs(ref physicsWorld, handle, physicsSettings.NumberOfThreadsHint); // Schedule phase callback. handle = physicsCallbacks.ScheduleCallbacksForPhase(PhysicsCallbacks.Phase.PostIntegrate, ref physicsWorld, handle); m_StepHandles.FinalExecutionHandle = handle; m_StepHandles.FinalDisposeHandle = handle; return(m_StepHandles); }
public SimulationJobHandles ScheduleStepJobs(PhysicsWorld physicsWorld, PhysicsCallbacks callbacks, JobHandle inputDeps) => new SimulationJobHandles(inputDeps);