Skip to content

Instantly share code, notes, and snippets.

@iondune
Created February 5, 2017 07:04
Show Gist options
  • Select an option

  • Save iondune/83d9a0599625dc946427171443c08639 to your computer and use it in GitHub Desktop.

Select an option

Save iondune/83d9a0599625dc946427171443c08639 to your computer and use it in GitHub Desktop.
How to build index data for clipmaps with degenerate triangles.
// Standard LL
IndexData.push_back(x + 0 + (GeometrySize + 1) * (y + 1));
IndexData.push_back(x + 1 + (GeometrySize + 1) * (y + 1));
IndexData.push_back(x + 0 + (GeometrySize + 1) * (y + 0));
// Standard UR
IndexData.push_back(x + 1 + (GeometrySize + 1) * (y + 1));
IndexData.push_back(x + 1 + (GeometrySize + 1) * (y + 0));
IndexData.push_back(x + 0 + (GeometrySize + 1) * (y + 0));
// Bridge Up
if (TopEdge && IsEven(x))
{
IndexData.push_back(x + 1 + (GeometrySize + 1) * (y + 0));
IndexData.push_back(x + 2 + (GeometrySize + 1) * (y + 0));
IndexData.push_back(x + 0 + (GeometrySize + 1) * (y + 0));
}
// Bridge Down
if (BottomEdge && IsEven(x))
{
IndexData.push_back(x + 0 + (GeometrySize + 1) * (y + 1));
IndexData.push_back(x + 2 + (GeometrySize + 1) * (y + 1));
IndexData.push_back(x + 1 + (GeometrySize + 1) * (y + 1));
}
// Bridge Left
if (LeftEdge && IsEven(y))
{
IndexData.push_back(x + 0 + (GeometrySize + 1) * (y + 2));
IndexData.push_back(x + 0 + (GeometrySize + 1) * (y + 1));
IndexData.push_back(x + 0 + (GeometrySize + 1) * (y + 0));
}
// Bridge Right
if (RightEdge && IsEven(y))
{
IndexData.push_back(x + 1 + (GeometrySize + 1) * (y + 2));
IndexData.push_back(x + 1 + (GeometrySize + 1) * (y + 0));
IndexData.push_back(x + 1 + (GeometrySize + 1) * (y + 1));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment