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(); }
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); }