Add support for per-face texture coordinates in the PLY decoder.
This PR adds support to the PlyDecoder for decoding texture coordinates from the texcoord property of the face element.
PLY files can support a single vertex with different texture coordinates per face. Since Draco expects texture coordinates to be stored per-vertex, this implementation chooses the last set of texture coordinates found for each vertex. For many users this should not be an issue. Where it is a problem, it's no worse than not having texture coordinate support at all.
Draco doesn't really expect texture coordinates to be stored per-vertex. In fact all non-position attributes are usually stored per-corner (so each corner of a single vertex can have a different attribute value). Given that, we would prefer to have a solution that would decode the texture coordinates properly. The solution in this PR would probably lead to even more confusion and hard-to-track bugs down the line.
Draco doesn't really expect texture coordinates to be stored per-vertex. In fact all non-position attributes are usually stored per-corner (so each corner of a single vertex can have a different attribute value). Given that, we would prefer to have a solution that would decode the texture coordinates properly. The solution in this PR would probably lead to even more confusion and hard-to-track bugs down the line.
Am I correct in thinking that would require a more substantial rewrite of the PlyDecoder to use point mapping rather than identity mapping, or is there a shortcut I'm missing?
Draco doesn't really expect texture coordinates to be stored per-vertex. In fact all non-position attributes are usually stored per-corner (so each corner of a single vertex can have a different attribute value). Given that, we would prefer to have a solution that would decode the texture coordinates properly. The solution in this PR would probably lead to even more confusion and hard-to-track bugs down the line.
Am I correct in thinking that would require a more substantial rewrite of the PlyDecoder to use point mapping rather than identity mapping, or is there a shortcut I'm missing?
Not necessarily. The easiest way would be to use Mesh::AddAttributeWithConnectivity() method. It would allow you to specify mapping between corners and attribute values and it would automatically update the point mapping. That method is currently defined within #ifdef DRACO_TRANSCODER_SUPPORTED but it can be probably moved out if needed.
Not necessarily. The easiest way would be to use Mesh::AddAttributeWithConnectivity() method. It would allow you to specify mapping between corners and attribute values and it would automatically update the point mapping. That method is currently defined within #ifdef DRACO_TRANSCODER_SUPPORTED but it can be probably moved out if needed.
Thanks for your patience. I tried using Mesh::AddAttributeWithConnectivity(), but it doesn't work, either failing at IsAddressValid() in ConvertTypedValue() or crashing later. I suspect this is because the other attributes used by the PLY decoder are identity-mapped, and using a mix of identity-mapped and point-mapped attributes doesn't work. Does that make sense?
I've pushed a commit here with my (non-working) code, in case you are able to spot something I'm missing.