tinygltf
tinygltf copied to clipboard
Refactor toplevel section parsing and remove duplicate code
Introduce a new function ParseSection(…), which handles populating the toplevel GLTF arrays. This removes a bunch of duplicated code. Use a variadic template to facilitate passing additional arguments, that don’t fit the common signature. See Buffer or Mesh.
Refactor object parsing functions (ParseBuffer(), &c.) into a set of overloaded functions ParseObject(…). That way we can invoke them without knowning the actual type.
Pass the TinyGLTF context to the parser functions, so we can actually use it.
To keep the changeset size in check, this deals with all toplevel objects but Image, which is more involved and requires a closer look.
Also, add some getters and fix minor const-correctness issues.
I don't like variadic template, which makes C++ code difficult to read and debug, and code refactoring is a trivial thing, so won't merge this PR