/// <summary> /// Combines the two identifiers using a variant of the Szudzik's function, removing the chance for duplicate /// symmetric pairs. The relatively small number of physics bodies inside the scene allows the use of integers. /// </summary> private void GenerateHash() { int hashA = bodyA.GetHashCode(); int hashB = bodyB.GetHashCode(); int a, b; if (hashA >= hashB) { a = hashA; b = hashB; } else { a = hashB; b = hashA; } hash = a * a + a + b; }