// Synchronize the collision world with the dynamics world. void UpdateDynamicTree(ref PhysicsWorld world) { // Synchronize transforms for (var i = 0; i < world.DynamicsWorld.BodyMotionCount; i++) { UpdatePhysicsBodyTransformsJob.Execute(i, world.BodyMotionData, m_PhysicsBodies); } // Update broadphase var aabbMargin = PhysicsSettings.Constants.CollisionTolerance * 0.5f; Broadphase.BuildDynamicTree(world.DynamicBodies, world.BodyMotionData, world.BodyMotionVelocity, world.Settings.Gravity, world.TimeStep, aabbMargin); }
// Schedule a set of jobs to synchronize the collision world with the dynamics world. internal JobHandle ScheduleUpdateDynamicTree(ref PhysicsWorld world, JobHandle inputDeps) { if (world.Settings.NumberOfThreadsHint <= 1) { return(new UpdateDynamicLayerJob { World = world, TimeStep = world.TimeStep, Gravity = world.Settings.Gravity }.Schedule(inputDeps)); } // Synchronize transforms var handle = new UpdatePhysicsBodyTransformsJob { MotionDatas = world.BodyMotionData, PhysicsBodies = m_PhysicsBodies }.Schedule(world.BodyMotionData.Length, 32, inputDeps); // Update broadphase return(Broadphase.ScheduleDynamicTreeBuildJobs(ref world, handle)); }