Exemple #1
0
		public static CollisionPointStructure Find(
			CollisionPointStructure[] collisionPoints,
			ContactIndex contactIndex)
		{
			foreach (CollisionPointStructure cps in collisionPoints)
			{
				if (cps.ObjectA == contactIndex.IndexA &&
				    cps.ObjectB == contactIndex.IndexB)
				{
					return cps;
				}
			}
			return null;
		}
		private void recursiveSearch(
			ContactIndex searchPoint,
			List<ContactIndex> readList,
			List<ContactIndex> partition,
			SimulationObject[] simulationObjects)
		{
			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 (simulationObjects [searchPoint.IndexA].ObjectType == ObjectType.StaticRigidBody &&
				    simulationObjects [searchPoint.IndexB].ObjectType == ObjectType.StaticRigidBody)
					break;

				if (simulationObjects [searchPoint.IndexA].ObjectType == ObjectType.StaticRigidBody &&
				           (searchPoint.IndexB == collisionValue.IndexA ||
				           searchPoint.IndexB == collisionValue.IndexB)) {

					if (!partition.Contains (collisionValue)) 
					{
						partition.Add (collisionValue);

						recursiveSearch (
							collisionValue,
							readList, 
							partition,
							simulationObjects);
					}

				} else if (simulationObjects [searchPoint.IndexB].ObjectType == ObjectType.StaticRigidBody &&
				           (searchPoint.IndexA == collisionValue.IndexA ||
				           searchPoint.IndexA == collisionValue.IndexB)) {

					if (!partition.Contains (collisionValue)) 
					{
						partition.Add (collisionValue);

						recursiveSearch (
							collisionValue,
							readList, 
							partition,
							simulationObjects);
					}

				} else if ((simulationObjects[searchPoint.IndexA].ObjectType == ObjectType.RigidBody &&
						   simulationObjects[searchPoint.IndexB].ObjectType == ObjectType.RigidBody) &&
						   (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,
							simulationObjects);
					}
				}
			}	
		}