protected Simulation(BufferPool bufferPool, SimulationAllocationSizes initialAllocationSizes) { BufferPool = bufferPool; Shapes = new Shapes(bufferPool, initialAllocationSizes.ShapesPerType); BroadPhase = new BroadPhase(bufferPool, initialAllocationSizes.Bodies, initialAllocationSizes.Bodies + initialAllocationSizes.Statics); Bodies = new Bodies(bufferPool, Shapes, BroadPhase, initialAllocationSizes.Bodies, initialAllocationSizes.Islands, initialAllocationSizes.ConstraintCountPerBodyEstimate); Statics = new Statics(bufferPool, Shapes, Bodies, BroadPhase, Activator, initialAllocationSizes.Statics); Solver = new Solver(Bodies, BufferPool, 8, initialCapacity: initialAllocationSizes.Constraints, initialIslandCapacity: initialAllocationSizes.Islands, minimumCapacityPerTypeBatch: initialAllocationSizes.ConstraintsPerTypeBatch); constraintRemover = new ConstraintRemover(BufferPool, Bodies, Solver); Deactivator = new Deactivator(Bodies, Solver, BroadPhase, constraintRemover, BufferPool); Activator = new IslandActivator(Bodies, Statics, Solver, BroadPhase, Deactivator, bufferPool); Bodies.Initialize(Solver, Activator); Solver.activator = Activator; PoseIntegrator = new PoseIntegrator(Bodies, Shapes, BroadPhase); SolverBatchCompressor = new BatchCompressor(Solver, Bodies); BodyLayoutOptimizer = new BodyLayoutOptimizer(Bodies, BroadPhase, Solver, bufferPool); ConstraintLayoutOptimizer = new ConstraintLayoutOptimizer(Bodies, Solver); }
public IslandActivator(Bodies bodies, Statics statics, Solver solver, BroadPhase broadPhase, Deactivator deactivator, BufferPool pool) { this.bodies = bodies; this.statics = statics; this.solver = solver; this.broadPhase = broadPhase; this.deactivator = deactivator; this.pool = pool; this.phaseOneWorkerDelegate = PhaseOneWorker; this.phaseTwoWorkerDelegate = PhaseTwoWorker; }
/// <summary> /// Clears the simulation of every object and returns all pooled memory to the buffer pool. Leaves the simulation in an unusable state. /// </summary> public void Dispose() { Clear(); Activator.Dispose(); Deactivator.Dispose(); Solver.Dispose(); BroadPhase.Dispose(); NarrowPhase.Dispose(); Bodies.Dispose(); Statics.Dispose(); BodyLayoutOptimizer.Dispose(BufferPool); Shapes.Dispose(); }