1

This is question for Direct3D 10 or OpenGL 3.2 / GLES 3.0 and primitive restart.

I'm trying to look at a way to convert an indexed array containing degenerated triangles strip to an other indexed array with degenerated indices replaced by 0xFFFF (indexed triangle strip converted by nvTriStrip).

for example I have

Indexed list 0, 1, 2, 2, 3, 3, 4, 5, 6

to

0, 1, 2, 0xFFFF, 3, 4, 5, 6

but I want to keep the 'winding order', because removing just an index is not enough.

I've tried the way like

bool isRestarting = true;
vector<GLushort> newindices; // Optimized with primitive restart
vector<GLushort> indices; // The original indices
int i = 0;
for (; i < indices.size();)
{
   if (i < indices.size() - 4 && indices[i+0] == indices[i+1] && indices[i+2] == indices[i+3])
   {
      // Looks degenerated
      newindices.push_back(indices[i+0]);
      newindices.push_back(0xFFFF);
      newindices.push_back(indices[i+2]); // Winding changes!
      isRestarting = true;
      i+=4;

   }
   else if (isRestarting)
   {
      // Restarting the primitive.
      newindices.push_back(indices[i+2]);
      newindices.push_back(indices[i+1]);
      newindices.push_back(indices[i+0]);
      isRestarting = false;
      i+=3;
   }
   else
   {
      newindices.push_back(indices[i]); 
      i++;
   }
}

But I'm losing the winding informations.

What are you suggesting, based from this snippet of code, which seems not works properly.

Ross Ridge
  • 38,414
  • 7
  • 81
  • 112
  • What makes you think removing vertex isn't enough? By the first look, it is. If you change vertex order, you'll break a strip. – keltar Jul 22 '14 at 03:43
  • If you remove one index, the winding order is reversed. But if you remove two indices, it is reversed twice and thus not changed. The `if(isRestarting)` part does not make sense to me. – Nico Schertler Jul 22 '14 at 06:24

0 Answers0