コード例 #1
0
        public static void Test()
        {
            var pool     = new BufferPool();
            var registry = new CollisionTaskRegistry();
            var task     = new SpherePairCollisionTask();

            registry.Register(task);
            var continuations = new ContinuationsTest();
            var filters       = new SubtaskFiltersTest();
            var sphere        = new Sphere(1);
            var poseA         = new RigidPose {
                Position = new Vector3(0, 0, 0), Orientation = BepuUtilities.Quaternion.Identity
            };
            var poseB = new RigidPose {
                Position = new Vector3(0, 1, 0), Orientation = BepuUtilities.Quaternion.Identity
            };
            Action <int> action = iterationCount =>
            {
                var batcher = new StreamingBatcher(pool, registry);
                for (int i = 0; i < iterationCount; ++i)
                {
                    batcher.Add(ref sphere, ref sphere, ref poseA, ref poseB, new ContinuationIndex(), ref continuations, ref filters);
                    batcher.Add(ref sphere, ref sphere, ref poseA, ref poseB, new ContinuationIndex(), ref continuations, ref filters);
                    batcher.Add(ref sphere, ref sphere, ref poseA, ref poseB, new ContinuationIndex(), ref continuations, ref filters);
                    batcher.Add(ref sphere, ref sphere, ref poseA, ref poseB, new ContinuationIndex(), ref continuations, ref filters);
                }
                batcher.Flush(ref continuations, ref filters);
            };
            var time0 = Test(action, 1 << 25);

            Console.WriteLine($"Completed count: {continuations.Count}, time (ms): {1e3 * time0}");
            Console.ReadKey();
        }
コード例 #2
0
        static void TestPair <TA, TB>(ref TA a, ref TB b, ref RigidPose poseA, ref RigidPose poseB,
                                      ref ContinuationsTest continuations, ref SubtaskFiltersTest filters, BufferPool pool, CollisionTaskRegistry registry, int iterationCount)
            where TA : struct, IShape where TB : struct, IShape
        {
            var batcher = new StreamingBatcher(pool, registry);

            for (int i = 0; i < iterationCount; ++i)
            {
                batcher.Add(ref a, ref b, ref poseA, ref poseB, new ContinuationIndex(0, 0, 0), ref continuations, ref filters);
                batcher.Add(ref a, ref b, ref poseA, ref poseB, new ContinuationIndex(0, 0, 0), ref continuations, ref filters);
                batcher.Add(ref a, ref b, ref poseA, ref poseB, new ContinuationIndex(0, 0, 0), ref continuations, ref filters);
                batcher.Add(ref a, ref b, ref poseA, ref poseB, new ContinuationIndex(0, 0, 0), ref continuations, ref filters);
            }
            batcher.Flush(ref continuations, ref filters);
        }
コード例 #3
0
        static void Test <TA, TB>(ref TA a, ref TB b, ref RigidPose poseA, ref RigidPose poseB,
                                  BufferPool pool, CollisionTaskRegistry registry, int iterationCount)
            where TA : struct, IShape where TB : struct, IShape
        {
            var continuations = new ContinuationsTest();
            var filters       = new SubtaskFiltersTest();

            TestPair(ref a, ref b, ref poseA, ref poseB, ref continuations, ref filters, pool, registry, 64);
            var start = Stopwatch.GetTimestamp();

            TestPair(ref a, ref b, ref poseA, ref poseB, ref continuations, ref filters, pool, registry, iterationCount);
            var end  = Stopwatch.GetTimestamp();
            var time = (end - start) / (double)Stopwatch.Frequency;

            Console.WriteLine($"Completed {continuations.Count} {typeof(TA).Name}-{typeof(TB).Name} pairs, time (ms): {1e3 * time}, time per pair (ns): {1e9 * time / continuations.Count}");
        }