Lesson Learnt

Today, i learnt a valuable lesson during index creation of a triMesh. Always check which index is refering to. Especially in loops!!!



So instead of an i++, do an i+=4 to create many quads :slight_smile:



Took me 2 days to figure out too!



If in doubt, do a sysout :stuck_out_tongue:



DP

"DarkProphet" wrote:
If in doubt, do a sysout
What would we do without sysout? :D

Actually, I advise avoiding any index[i*4] = … type of work. What I do is:


  int base4 = 0;
  for (...) {
     index[base4 + 0] = vertex0;
     index[base4 + 1] = vertex1;
     index[base4 + 2] = vertex2;
     index[base4 + 3] = vertex3;
     base4 += 4;
  }



easier to read & maintain & if you cut & paste you don't screw things up.

Actually, I advise avoiding any index[i*4] = ... type of work.


I dont do that! I do "i += 3" it works betta ;)