public Vector collideWithMesh(Mesh mesh) {

		// If recursion is over 5, it should be over
		if (collisionRecursionDepth > 1000) {
			return basePoint;
		}

		// Check for collisions
		for (int triangle = 0; triangle < mesh.triangles.length; triangle++) {
			checkTriangleForCollision(mesh.triangles[triangle]);
		}

		// If checking for gravity, indicate if there is a collision in the
		// first place
		if (checkingGravity && collisionFound) {
			collisionWithGravity = true;
		}

		// If collision didn't occur, move along the velocity
		if (!collisionFound) {
			return Vector.add(basePoint, velocity);
		}

		// If collision did occur,
		// Store the original destination point and make a new base point
		Vector destinationPoint = Vector.add(basePoint, velocity);
		Vector newBasePoint = new Vector(basePoint);

		// If the object is farther than the very close distance
		if (nearestDistance >= veryCloseDistance) {

			// Move it up to the plane at the very close distance away
			Vector v = new Vector(velocity);
			Vector newVelocity = new Vector(v).normalize().mult(
					nearestDistance - veryCloseDistance);
			newBasePoint = Vector.add(basePoint, newVelocity);

			// Adjust the intersection point so that the sliding plane
			// is unaffected by the object being slightly off the surface
			intersectionPoint = Vector.sub(intersectionPoint, v.normalize()
					.mult(veryCloseDistance));
		}

		// Determine the sliding plane
		slidingPlaneOrigin = intersectionPoint;
		slidingPlaneNormal = Vector.sub(newBasePoint, intersectionPoint);
		slidingPlaneNormal.normalize();

		// Calculate the new destination point
		Vector newDestinationPoint = Vector.sub(destinationPoint, new Vector(
				slidingPlaneNormal).mult(Triangle.signedDistanceTo(
				destinationPoint, slidingPlaneNormal, slidingPlaneOrigin)));

		// Generate the slide vector, which is going to be the new
		// velocity vector for the next iteration
		Vector newVelocity = Vector.sub(newDestinationPoint, intersectionPoint);

		// Don't recurse if the new velocity is too small
		if (newVelocity.length() < veryCloseDistance) {
			return newBasePoint;
		}

		// Recurse:
		collisionRecursionDepth++;
		basePoint = newBasePoint;
		velocity = newVelocity;
		collisionFound = false;
		return collideWithMesh(mesh);
	}