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(); }
public OverlapWorker(int workerIndex, BufferPool pool, NarrowPhase <TCallbacks> narrowPhase) { Batcher = new StreamingBatcher(pool, narrowPhase.CollisionTaskRegistry); Filters = new BatcherFilters(workerIndex, narrowPhase); ConstraintGenerators = new ConstraintGenerators(workerIndex, pool, narrowPhase); PendingConstraints = new PendingConstraintAddCache(pool); }
public OverlapWorker(int workerIndex, BufferPool pool, NarrowPhase <TCallbacks> narrowPhase) { Batcher = new StreamingBatcher(pool, narrowPhase.CollisionTaskRegistry); Filters = new BatcherFilters(workerIndex, narrowPhase); ConstraintGenerators = new ConstraintGenerators(workerIndex, pool, narrowPhase); PendingConstraints = new PendingConstraintAddCache(pool); QuickList <int, Buffer <int> > .Create(pool.SpecializeFor <int>(), 16, out PendingSetAwakenings); }
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); }
//Every single collision task type will mirror this general layout. public unsafe override void ExecuteBatch <TContinuations, TFilters>(ref UntypedList batch, ref StreamingBatcher batcher, ref TContinuations continuations, ref TFilters filters) { CollisionTaskCommon.ExecuteBatch <TContinuations, TFilters, Sphere, SphereWide, Box, BoxWide, OneOrientationTestPairWide <Sphere, SphereWide, Box, BoxWide>, Convex1ContactManifoldWide, SphereBoxTester>(ref batch, ref batcher, ref continuations, ref filters); }
//Note that we leave the details of input and output of a task's execution to be undefined. //A task can reach into the batcher and create new entries or trigger continuations as required. /// <summary> /// Executes the task on the given input. /// </summary> /// <typeparam name="TFilters">Type of the filters used to influence execution of collision tasks.</typeparam> /// <typeparam name="TContinuations">Type of the continuations that can be triggered by the this execution.</typeparam> /// <param name="batcher">Batcher responsible for the invocation.</param> /// <param name="batch">Batch of pairs to test.</param> /// <param name="continuations">Continuations to invoke upon completion of a top level pair.</param> /// <param name="filters">Filters to use to influence execution of the collision tasks.</param> public abstract void ExecuteBatch <TContinuations, TFilters>(ref UntypedList batch, ref StreamingBatcher batcher, ref TContinuations continuations, ref TFilters filters) where TContinuations : struct, IContinuations where TFilters : struct, ICollisionSubtaskFilters;
//Every single collision task type will mirror this general layout. public unsafe override void ExecuteBatch <TContinuations, TFilters>(ref UntypedList batch, ref StreamingBatcher batcher, ref TContinuations continuations, ref TFilters filters) { CollisionTaskCommon.ExecuteBatch <TContinuations, TFilters, Capsule, CapsuleWide, Capsule, CapsuleWide, UnflippableTestPairWide <Capsule, CapsuleWide, Capsule, CapsuleWide>, Convex2ContactManifoldWide, CapsulePairTester>(ref batch, ref batcher, ref continuations, ref filters); }