public MassAggregateApplication(int particleCount) { World = new ParticleWorld(particleCount * 10); for (int i = 0; i < particleCount; i++) { World.Particles.Add(new Particle()); } GroundContactGenerator = new GroundContacts(World.Particles); World.ContactGenerators.Add(GroundContactGenerator); }
protected void OnDetectGround(IEnumerable <Collider> grounds) { lock (_grounds) { var collection = grounds.ToHashSet(); var oldContacts = GroundContacts.Except(collection); var contacts = collection.Except(GroundContacts); oldContacts.ForEach(c => _grounds.Remove(c)); contacts.ForEach(c => _grounds.Add(c)); } }