Beispiel #1
0
        public unsafe override void ExecuteBatch <TCallbacks>(ref UntypedList batch, ref CollisionBatcher <TCallbacks> batcher)
        {
            var testPairs = batch.Buffer.As <FliplessPair>();

            for (int i = 0; i < batch.Count; ++i)
            {
                ref var pair = ref testPairs[i];
                ref var a    = ref Unsafe.AsRef <Compound>(pair.A);
Beispiel #2
0
 static void ComputeCollisions(CollisionTaskRegistry registry, Shapes shapes, BufferPool pool,
     ref Manifolds manifolds, CollidableDescription a, CollidableDescription b, ref Buffer<RigidPose> posesA, ref Buffer<RigidPose> posesB, Buffer<int> remapIndices, int pairCount)
 {
     var batcher = new CollisionBatcher<BatcherCallbacks>(pool, shapes, registry, 1 / 60f, new BatcherCallbacks { Pool = pool, Manifolds = manifolds });
     for (int i = 0; i < pairCount; ++i)
     {
         var index = remapIndices[i];
         ref var poseA = ref posesA[index];
         ref var poseB = ref posesB[index];
Beispiel #3
0
        static void TestPair <TA, TB>(ref TA a, ref TB b, ref Buffer <RigidPose> posesA, ref Buffer <RigidPose> posesB,
                                      ref TestCollisionCallbacks callbacks, BufferPool pool, Shapes shapes, CollisionTaskRegistry registry, int iterationCount)
            where TA : struct, IShape where TB : struct, IShape
        {
            var batcher = new CollisionBatcher <TestCollisionCallbacks>(pool, shapes, registry, 1 / 60f, callbacks);

            for (int i = 0; i < iterationCount; ++i)
            {
                ref var poseA = ref posesA[i];
                ref var poseB = ref posesB[i];
        public unsafe override void ExecuteBatch <TCallbacks>(ref UntypedList batch, ref CollisionBatcher <TCallbacks> batcher)
        {
            var testPairs = batch.Buffer.As <CollisionPair>();

            for (int i = 0; i < batch.Count; ++i)
            {
                ref var pair = ref testPairs[i];
                Debug.Assert(pair.Continuation.ChildA == 0 && pair.Continuation.ChildB == 0 && pair.Continuation.Type == CollisionContinuationType.Direct,
                             "Compound-involving pairs cannot be marked as children of compound pairs. Convex-convex children of such pairs will be.");
                ref var b            = ref Unsafe.AsRef <Compound>(pair.B);
        public unsafe override void ExecuteBatch <TCallbacks>(ref UntypedList batch, ref CollisionBatcher <TCallbacks> batcher)
        {
            var            pairs         = batch.Buffer.As <BoundsTestedPair>();
            TOverlapFinder overlapFinder = default;

            //We perform all necessary bounding box computations and lookups up front. This helps avoid some instruction pipeline pressure at the cost of some extra data cache requirements.
            //Because of this, you need to be careful with the batch size on this collision task.
            overlapFinder.FindLocalOverlaps(ref pairs, batch.Count, batcher.Pool, batcher.Shapes, batcher.Dt, out var overlaps);
            for (int i = 0; i < batch.Count; ++i)
            {
                ref var pairOverlaps = ref overlaps.GetOverlapsForPair(i);
                if (pairOverlaps.Count > 0)
                {
                    ref var pair         = ref pairs[i];
                    ref var compound     = ref Unsafe.AsRef <TCompound>(pair.B);
        public unsafe override void ExecuteBatch <TCallbacks>(ref UntypedList batch, ref CollisionBatcher <TCallbacks> batcher)
        {
            var            pairs         = batch.Buffer.As <BoundsTestedPair>();
            TOverlapFinder overlapFinder = default;

            //We perform all necessary bounding box computations and lookups up front. This helps avoid some instruction pipeline pressure at the cost of some extra data cache requirements.
            //Because of this, you need to be careful with the batch size on this collision task.
            overlapFinder.FindLocalOverlaps(ref pairs, batch.Count, batcher.Pool, batcher.Shapes, batcher.Dt, out var overlaps);
            for (int pairIndex = 0; pairIndex < batch.Count; ++pairIndex)
            {
                overlaps.GetPairOverlaps(pairIndex, out var pairOverlaps);
                var totalOverlapCountForPair = pairOverlaps[0].Count;
                for (int j = 1; j < pairOverlaps.Length; ++j)
                {
                    totalOverlapCountForPair += pairOverlaps[j].Count;
                }
                if (totalOverlapCountForPair > 0)
                {
                    ref var pair         = ref pairs[pairIndex];
                    ref var compoundA    = ref Unsafe.AsRef <TCompoundA>(pair.A);
                    ref var compoundB    = ref Unsafe.AsRef <TCompoundB>(pair.B);
Beispiel #7
0
 public ref CompoundMeshReduction CreateContinuation <TCallbacks>(
     ref CollisionBatcher <TCallbacks> collisionBatcher, int totalChildCount, ref Buffer <ChildOverlapsCollection> pairOverlaps, in BoundsTestedPair pair, out int continuationIndex)
 public ref NonconvexReduction CreateContinuation <TCallbacks>(
     ref CollisionBatcher <TCallbacks> collisionBatcher, int childCount, in BoundsTestedPair pair, out int continuationIndex)
Beispiel #9
0
 public ref MeshReduction CreateContinuation <TCallbacks>(
     ref CollisionBatcher <TCallbacks> collisionBatcher, int childCount, in BoundsTestedPair pair, in OverlapQueryForPair pairQuery, out int continuationIndex)
 public ref NonconvexReduction CreateContinuation <TCallbacks>(
     ref CollisionBatcher <TCallbacks> collisionBatcher, int totalChildCount, ref Buffer <ChildOverlapsCollection> pairOverlaps, ref Buffer <OverlapQueryForPair> pairQueries, in BoundsTestedPair pair, out int continuationIndex)