public unsafe static void Execute(ref BodyPairsJobData <T> jobData, IntPtr additionalData, IntPtr bufferRangePatchData, ref JobRanges ranges, int jobIndex) { int currentIdx = 0; while (currentIdx < jobData.PhasedDispatchPairs.Length) { DispatchPairSequencer.DispatchPair dispatchPair = jobData.PhasedDispatchPairs[currentIdx]; var pair = new ModifiableBodyPair { BodyIndices = new BodyIndexPair { BodyAIndex = dispatchPair.BodyAIndex, BodyBIndex = dispatchPair.BodyBIndex }, Entities = new EntityPair { EntityA = jobData.Bodies[dispatchPair.BodyAIndex].Entity, EntityB = jobData.Bodies[dispatchPair.BodyBIndex].Entity } }; jobData.UserJobData.Execute(ref pair); if (pair.BodyIndices.BodyAIndex == -1 || pair.BodyIndices.BodyBIndex == -1) { jobData.PhasedDispatchPairs[currentIdx] = DispatchPairSequencer.DispatchPair.Invalid; } do { currentIdx++; } while (currentIdx < jobData.PhasedDispatchPairs.Length && jobData.PhasedDispatchPairs[currentIdx].IsJoint); } }
public unsafe static void Execute(ref BodyPairsJobData <T> jobData, IntPtr additionalData, IntPtr bufferRangePatchData, ref JobRanges ranges, int jobIndex) { for (int currentIdx = 0; currentIdx < jobData.PhasedDispatchPairs.Length; currentIdx++) { // Skip joint pairs if (jobData.PhasedDispatchPairs[currentIdx].IsJoint) { continue; } DispatchPairSequencer.DispatchPair dispatchPair = jobData.PhasedDispatchPairs[currentIdx]; var pair = new ModifiableBodyPair { BodyIndexPair = new BodyIndexPair { BodyIndexA = dispatchPair.BodyIndexA, BodyIndexB = dispatchPair.BodyIndexB }, EntityPair = new EntityPair { EntityA = jobData.Bodies[dispatchPair.BodyIndexA].Entity, EntityB = jobData.Bodies[dispatchPair.BodyIndexB].Entity } }; jobData.UserJobData.Execute(ref pair); if (pair.BodyIndexA == -1 || pair.BodyIndexB == -1) { jobData.PhasedDispatchPairs[currentIdx] = DispatchPairSequencer.DispatchPair.Invalid; } } }
public void Execute(ref ModifiableBodyPair pair) { if (IsUnityPhysics) { int bodyIndexA = pair.BodyIndexA; int bodyIndexB = pair.BodyIndexB; bool bodyBIsDynamic = bodyIndexB < LastStaticPairPerDynamicBody.Length; if (bodyBIsDynamic) { Assert.IsTrue(LastStaticPairPerDynamicBody[bodyIndexA] <= bodyIndexB); } else { LastStaticPairPerDynamicBody[bodyIndexA] = bodyIndexB; } } }
public void Execute(ref ModifiableBodyPair pair) { if (IsUnityPhysics) { int bodyAIndex = pair.BodyIndices.BodyAIndex; int bodyBIndex = pair.BodyIndices.BodyBIndex; bool bodyBIsDynamic = bodyBIndex < LastStaticPairPerDynamicBody.Length; if (bodyBIsDynamic) { Assert.IsTrue(LastStaticPairPerDynamicBody[bodyAIndex] <= bodyBIndex); } else { LastStaticPairPerDynamicBody[bodyAIndex] = bodyBIndex; } } }
public unsafe static void Execute(ref BodyPairsJobData <T> jobData, IntPtr additionalData, IntPtr bufferRangePatchData, ref JobRanges ranges, int jobIndex) { if (jobData.BlockStreamStart == null || !jobData.BlockStreamStart->HasElements) { return; } var blockStreamReader = new Havok.Physics.HpBlockStreamReader(jobData.BlockStreamStart); int *pluginIndexToLocal = jobData.PluginIndexToLocal->Data; while (blockStreamReader.HasItems) { BodyIndexPair indices = blockStreamReader.Read <BodyIndexPair>(); // Really an hknpBodyIdPair int bodyIndexA = pluginIndexToLocal[indices.BodyIndexA & 0x00ffffff]; int bodyIndexB = pluginIndexToLocal[indices.BodyIndexB & 0x00ffffff]; var pair = new ModifiableBodyPair { BodyIndexPair = new BodyIndexPair { BodyIndexA = bodyIndexA, BodyIndexB = bodyIndexB }, EntityPair = new EntityPair { EntityA = jobData.Bodies[bodyIndexA].Entity, EntityB = jobData.Bodies[bodyIndexB].Entity } }; jobData.UserJobData.Execute(ref pair); if (pair.BodyIndexA == -1 || pair.BodyIndexB == -1) { blockStreamReader.Write(BodyIndexPair.Invalid); } } }