コード例 #1
0
        // Schedule a set of jobs to synchronize the collision world with the dynamics world.
        public JobHandle ScheduleUpdateDynamicTree(ref PhysicsWorld world, float timeStep, float3 gravity, JobHandle inputDeps, bool multiThreaded = true)
        {
            if (!multiThreaded)
            {
                return(new UpdateDynamicLayerJob
                {
                    World = world,
                    TimeStep = timeStep,
                    Gravity = gravity
                }.Schedule(inputDeps));
            }
            else
            {
                // Synchronize transforms
                JobHandle handle = new UpdateRigidBodyTransformsJob
                {
                    MotionDatas = world.MotionDatas,
                    RigidBodies = m_Bodies
                }.Schedule(world.MotionDatas.Length, 32, inputDeps);

                // Update broadphase
                // Thread count is +1 for main thread
                return(Broadphase.ScheduleDynamicTreeBuildJobs(ref world, timeStep, gravity, JobsUtility.JobWorkerCount + 1, handle));
            }
        }
コード例 #2
0
        // Synchronize the collision world with the dynamics world.
        public void UpdateDynamicTree(ref PhysicsWorld world, float timeStep, float3 gravity)
        {
            // Synchronize transforms
            for (int i = 0; i < world.DynamicsWorld.NumMotions; i++)
            {
                UpdateRigidBodyTransformsJob.ExecuteImpl(i, world.MotionDatas, m_Bodies);
            }

            // Update broadphase
            float aabbMargin = world.CollisionWorld.CollisionTolerance * 0.5f;

            Broadphase.BuildDynamicTree(world.DynamicBodies, world.MotionDatas, world.MotionVelocities, gravity, timeStep, aabbMargin);
        }
コード例 #3
0
        // Schedule a set of jobs to synchronize the collision world with the dynamics world.
        public JobHandle ScheduleUpdateDynamicTree(ref PhysicsWorld world, float timeStep, float3 gravity, JobHandle inputDeps, int threadCountHint = 0)
        {
            if (threadCountHint <= 0)
            {
                return(new UpdateDynamicLayerJob
                {
                    World = world,
                    TimeStep = timeStep,
                    Gravity = gravity
                }.Schedule(inputDeps));
            }
            else
            {
                // Synchronize transforms
                JobHandle handle = new UpdateRigidBodyTransformsJob
                {
                    MotionDatas = world.MotionDatas,
                    RigidBodies = m_Bodies
                }.Schedule(world.MotionDatas.Length, 32, inputDeps);

                // Update broadphase
                return(Broadphase.ScheduleDynamicTreeBuildJobs(ref world, timeStep, gravity, threadCountHint, handle));
            }
        }