ProceduralMesh Icosphere with twisted Faces

Hi,

i have a nasty Problem with my Icosphere. I try to implement CDLOD. As you can see there are Holes in my Sphere. When i move the Camera inside the Sphere i can see the missing Triangles.

But i can’t find the Problem in my Code. Is there a way to tell if the Triangle facing in the wrong Direction?
I tried to find the Holes with comparing the Index. But there is no Pattern :frowning: they change “randomly” when they get split.
That menas if Triangle x is facing the wrong Direction it can face the right Direction when i move the Camera.

I found an Implementation in OpenGl. No Problems there =/

Ignore the morph thing, it’s some other Part of my Code.

Edit: The Sphere is made of Patches, depending on the Camera distance. Each Patch contains 153 Vertices. The size of each Patch is calculated by the Camera distance.

//clear
	pVertices.Empty();
	pIndices.Empty();
	int32 index = 0;
	//Generate
	int32 RC = 1 + (int32)pow(2, (int32)levels);

	float delta = 1 / (float)(RC - 1);

	int32 rowIdx = 0;
	int32 nextIdx = 0;
	for (int32 row = 0; row < RC; row++)
	{
		int32 numCols = RC - row;
		nextIdx += numCols;
		for (int32 column = 0; column < numCols; column++)
		{
			//calc position
			FVector2D pos = FVector2D(column / (float)(RC - 1), row / (float)(RC - 1));
			//calc morph
			FVector2D morph = FVector2D(0, 0);
			if (row % 2 == 0)
			{
				if (column % 2 == 1) morph = FVector2D(-delta, 0);
			}
			else
			{
				if (column % 2 == 0) morph = FVector2D(0, delta);
				else morph = FVector2D(delta, -delta);
			}
			//create vertex
			pVertices.Emplace(FPatchVertex(pos, morph));
			//calc index
			if (row < RC - 1 && column < numCols - 1)
			{
				pIndices.Emplace(rowIdx + column);
				pIndices.Emplace(1 + rowIdx + column);
				pIndices.Emplace(nextIdx + column);
				

				if (column < numCols - 2)
				{
					pIndices.Emplace(nextIdx + column);
					pIndices.Emplace(1 + rowIdx + column);
					pIndices.Emplace(1 + nextIdx + column);
					

				}
			}
			index++;
		}
		rowIdx = nextIdx;
	}

I found a Solution.
It’s simple and doesn’t need much code. Just by checking if the Triangle was clockwise or counter clockwise i was able to find the Triangles wich were facing the wrong side.