protected override JobHandle OnUpdate(JobHandle inputDeps) { if (!(HasSingleton <PhysicsDebugDisplayData>() && GetSingleton <PhysicsDebugDisplayData>().DrawTriggerEvents != 0)) { return(inputDeps); } unsafe { DebugStream.Context debugOutput = m_DebugStreamSystem.GetContext(1); debugOutput.Begin(0); // 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[0] = debugOutput; var job = new DisplayTriggerEventsJob { World = m_BuildPhysicsWorldSystem.PhysicsWorld, OutputStreamContext = sharedOutput, }; JobHandle handle = ScheduleTriggerEventsJob(job, m_StepPhysicsWorldSystem.Simulation, ref m_BuildPhysicsWorldSystem.PhysicsWorld, inputDeps); #pragma warning disable 618 JobHandle finishHandle = new FinishDisplayTriggerEventsJob { OutputStreamContext = sharedOutput }.Schedule(handle); #pragma warning restore 618 m_EndFramePhysicsSystem.HandlesToWaitFor.Add(finishHandle); return(handle); } }
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 { DebugStream.Context debugOutput = m_DebugStreamSystem.GetContext(1); debugOutput.Begin(0); // 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[0] = debugOutput; var gatherJob = new DisplayContactsJob { DisplayContactIndices = false, OutputStreamContext = sharedOutput }; JobHandle gatherJobHandle = ScheduleContactsJob(gatherJob, simulation, ref world, inDeps); var finishJob = new FinishDisplayContactsJob { OutputStreamContext = sharedOutput }; return(finishJob.Schedule(gatherJobHandle)); } }; m_StepWorld.EnqueueCallback(SimulationCallbacks.Phase.PostCreateContacts, callback); return(inputDeps); }