Using exceptions to indicate errors from "hot" code paths does
incur non-trivial overhead. Instead, report errors using oldskool
method of returning error messages.
Conceptually similar to OBJ importer, this one reads input file in
chunks (64kb), and then parses lines (header or ascii ply files)
or reads binary data from that, refilling the buffer as necessary.
Pure parsing performance is about 2x faster (tested on a Mac).
- Was assuming that positions/normals/UVs are floats and colors are
bytes.
- Was assuming that faces are always byte list size and int32 indices.
- Was assuming that edge vertex indices are always int32.
Added a bunch of tests that cover the above, that were returning
wrong data or crashing previously.
It should now be faster too, due to reading not one property at a time,
but whole row or list at a time.
Also the whole code is merged together between ascii and binary into
ply_import_data.cc/hh, since it shares most of the "figure out
property indices" logic.
There's also a test case with big endian binary file; coverage of
that was completely non-existent before.
- Was not handling type alias names (float32, uint32, int8 etc.),
- Was assuming that elements always follow in this order: vertex,
face, edge. This is common but not always the case.
- Was not handling whitespace that is not literal ASCII space character
(but e.g. a tab instead).
- Was not checking for partially present properties (e.g. if just "nx"
is present but not "ny" and "nz", it was still assuming whole
normal is there).
- Was assuming that positions/normals/UVs are always floats, and colors
are always uchars. But e.g. positions are sometimes doubles,
or colors are floats. Now that is handled.
Added a bunch of tests that cover the above, that were returning
wrong data or crashing previously.
It's now faster too, due to no longer splitting each input line
into a vector of std::string objects.
Instead of loading dummy .blend file and importing a ply file
into that, test only the "read ply file and import into a PlyData
object" bit.
Also rename the PLY import suite/fixture name to start with "ply_"
so that it's the same prefix as for export tests.