/// <summary> /// Advances the simulation a given amount of time. Note that once BeginStep has been called, /// Substep can be called multiple times. /// </summary> /// <param name="stepDeltaTime"> Duration (in seconds) of the substep.</param> protected void Substep(float substepDeltaTime) { using (m_SubstepPerfMarker.Auto()) { // Necessary when using multiple substeps: ObiColliderBase.UpdateColliders(); // Grab rigidbody info: ObiRigidbodyBase.UpdateAllRigidbodies(); IntPtr stepSimulation = Oni.CreateEmpty(); // Generate a task for each solver's step, and combine them all together: foreach (ObiSolver solver in solvers) { if (solver != null) { Oni.AddChild(stepSimulation, solver.Substep(substepDeltaTime)); } } // Schedule the task for execution: Oni.Schedule(stepSimulation); // Wait the task to complete: Oni.Complete(stepSimulation); // Update rigidbody velocities: ObiRigidbodyBase.UpdateAllVelocities(); } }
/// <summary> /// Prepares all solvers to begin simulating a new physics step. This involves /// caching some particle data for interpolation, performing collision detection, among other things. /// </summary> /// <param name="stepDeltaTime"> Duration (in seconds) of the next step.</param> protected void BeginStep(float stepDeltaTime) { using (m_BeginStepPerfMarker.Auto()) { // Update colliders right before collision detection: ObiColliderBase.UpdateColliders(); IntPtr beginStep = Oni.CreateEmpty(); // Generate a task for each solver's collision detection, and combine them all together: foreach (ObiSolver solver in solvers) { if (solver != null) { Oni.AddChild(beginStep, solver.BeginStep(stepDeltaTime)); } } // Schedule the task for execution: Oni.Schedule(beginStep); // Wait the task to complete: Oni.Complete(beginStep); } }