Bug in DeIndexer sample


I noticed a bug in the deindexer sample. It works if the accessors look like

               <input semantic="VERTEX" source="#Cone01-obj-vertex" offset="0"></input>
               <input semantic="NORMAL" source="#Cone01-obj-normal" offset="1"></input>
               <input semantic="TEXCOORD" source="#Cone01-obj-mapchan-1" offset="2" set="1"></input>

but if it looks like

               <input semantic="VERTEX" source="#Cone01-obj-vertex" offset="0"></input>
               <input semantic="NORMAL" source="#Cone01-obj-normal" offset="0"></input>
               <input semantic="TEXCOORD" source="#Cone01-obj-mapchan-1" offset="1" set="1"></input>

then the code fails, because the maximum offset (1) is not identical to the number of inputs (3). It fails at this line:

	myVertexIndex.indices[k] = thisTriangles->getP()->getValue()[currentTriangleIndex + k];

Here it needs to access something like

myVertexIndex.indices[k] = thisTriangles->getP()->getValue()[currentTriangleIndex + inputs[k].offset];

Without it the app crashes. You get this kind of offsets when you are exporting with the 3ds max exporter with tangents/binormals turned on for example.


Hello Matthias,

The Deindexer is just a sample. It was never meant to handle all the different COLLADA cases that could be thrown at it.

Thank you for this fix. I will add it to the deindexer sample soon.


Ahh ok, if it’s just a sample then I don’t care :slight_smile: I built up on it to make our collada-to-custom-format converter and ran into that bug.
Actually there are many more lines like the one I’ve shown that need to be changed, almost all the indices + offsets are wrong. If I had a version without our own code in-between I could send the file to you, but with all the code in-between it will make it even harder for you to fix.
You could also just add a notice somewhere that the deindexer has this restriction and then leave it as is. The DeIndexer is a very good example by the way and I am sure a lot of people need it!