package collisions;import java.util.ArrayList;public class ContactResolver { private int iterations = 0, iterationsUsed = 0; public ContactResolver(int iterations) { this.iterations = iterations; } public void setIterations(int iterations) { this.iterations = iterations; } /* * Resolves a set of particle contacts for both penetration * and velocity. */ public void resolveContacts(ArrayList<Contact> contacts, int numContacts, long timePassed) { this.iterationsUsed = 0; while (this.iterationsUsed < this.iterations) { // Find the contact with the largest closing velocity float max = 0.0f; int maxIndex = numContacts; for (int i = 0; i < numContacts; i++) { float sepVel = contacts.get(i).calculateSeperatingVelocity(); if (sepVel < max) { max = sepVel; maxIndex = i; } } // Resolve this contact contacts.get(maxIndex).resolve(timePassed); this.iterationsUsed++; } }}