public static CollisionPointStructure Find( CollisionPointStructure[] collisionPoints, ContactIndex contactIndex) { foreach (CollisionPointStructure cps in collisionPoints) { if (cps.ObjectIndexA == contactIndex.IndexA && cps.ObjectIndexB == contactIndex.IndexB) { return(cps); } } return(null); }
//TODO correggere RigidBody con static/terrain (meglio terrain) private void RecursiveSearch( ContactIndex searchPoint, List <ContactIndex> readList, List <ContactIndex> partition, Dictionary <int, Tuple <ObjectType, bool> > objectsTypeDic) { for (int i = 0; i < readList.Count; i++) { ContactIndex collisionValue = readList [i]; if (searchPoint.IndexA == collisionValue.IndexA && searchPoint.IndexB == collisionValue.IndexB && searchPoint.KeyIndex == collisionValue.KeyIndex) { continue; } if (objectsTypeDic[searchPoint.IndexA].Item2 && objectsTypeDic[searchPoint.IndexB].Item2) { break; } if (objectsTypeDic[searchPoint.IndexA].Item2 && (searchPoint.IndexB == collisionValue.IndexA || searchPoint.IndexB == collisionValue.IndexB)) { if (!partition.Contains(collisionValue)) { partition.Add(collisionValue); RecursiveSearch( collisionValue, readList, partition, objectsTypeDic); } } else if (objectsTypeDic[searchPoint.IndexB].Item2 && (searchPoint.IndexA == collisionValue.IndexA || searchPoint.IndexA == collisionValue.IndexB)) { if (!partition.Contains(collisionValue)) { partition.Add(collisionValue); RecursiveSearch( collisionValue, readList, partition, objectsTypeDic); } } else if ((!objectsTypeDic[searchPoint.IndexA].Item2 && !objectsTypeDic[searchPoint.IndexB].Item2) && (searchPoint.IndexA == collisionValue.IndexB || searchPoint.IndexB == collisionValue.IndexA || searchPoint.IndexA == collisionValue.IndexA || searchPoint.IndexB == collisionValue.IndexB)) { if (!partition.Contains(collisionValue)) { partition.Add(collisionValue); RecursiveSearch( collisionValue, readList, partition, objectsTypeDic); } } } }