Esempio n. 1
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            if (!(HasSingleton <PhysicsDebugDisplayData>() && GetSingleton <PhysicsDebugDisplayData>().DrawContacts != 0))
            {
                return(inputDeps);
            }

            SimulationCallbacks.Callback callback = (ref ISimulation simulation, ref PhysicsWorld world, JobHandle inDeps) =>
            {
                unsafe
                {
                    // Allocate a block of memory to store our debug output, so it can be shared across the display/finish jobs
                    var sharedOutput = (DebugStream.Context *)UnsafeUtility.Malloc(sizeof(DebugStream.Context), 16, Allocator.TempJob);
                    *   sharedOutput = m_DebugStreamSystem.GetContext(1);
                    sharedOutput->Begin(0);

                    var gatherJob = new DisplayContactsJob
                    {
                        DisplayContactIndices = false,
                        OutputStreamContext   = sharedOutput
                    };

                    JobHandle gatherJobHandle = new DisplayContactsJob
                    {
                        DisplayContactIndices = false,
                        OutputStreamContext   = sharedOutput
                    }.Schedule(simulation, ref world, inDeps);

                    var finishJob = new FinishDisplayContactsJob
                    {
                        OutputStreamContext = sharedOutput
                    };

                    return(finishJob.Schedule(gatherJobHandle));
                }
            };

            m_StepWorld.EnqueueCallback(SimulationCallbacks.Phase.PostCreateContacts, callback);

            return(inputDeps);
        }
Esempio n. 2
0
 protected virtual JobHandle ScheduleContactsJob(DisplayContactsJob job, ISimulation simulation, ref PhysicsWorld world, JobHandle inDeps)
 {
     // Explicitly call ScheduleImpl here, to avoid a dependency on Havok.Physics
     return(job.ScheduleImpl(simulation, ref world, inDeps));
 }