Changed some loops to directly use Direction instead of int with a cast.
Created a buffered stack that loops around to avoid a bunch of memory copying in PolyMeshDetail.GetHeightDetail