assimp/assimp — pull request #237 by frederikaalund (2014-03-14 13:49:01+00:00)
Title: Added support for heterogenous metadata on aiNode

The `aiNode`'s member `mMetadata` can now store heterogenous data types. Before this commit, all metadata entries were of type `aiString`.

This commit consists of the following changes:
* Re-wrote `metadata.h` to support heterogenous data. Metadata entries are now logically a tuple (`aiString` key, `aiType` type, `void*` data) though the memory layout is different for performance reasons (keys are stored in a separate array to increase locality for searches).
* Amended the FBX and IFC loaders to support the new metadata structure.

Metadata is now retrieved using the function `	template bool Get( const aiString& key, T& value )`. Said function assigns the metadata stored with `key` to `value` *iff* the metadata was originally stored using type `T`. The function returns `true` if the metadata was successfully retrieved and false otherwise.

Internally, the enum `aiType` is used to map data to type at runtime.

Note that I have *not* provided a C interface. However, I have strived to stay C compatible so that a C interface can easily be added in a later commit. I have made use of overloads and templates only for my own convenience. It should be straightforward to stamp out functions such as `bool GetAsFloat( const aiString* key, float* value )` etc. Likewise, all of the implementation's use of templated and overloaded logic can be expanded into the C equivalents if need be.

Currently, the `aiType` enum looks like this:
`enum aiType
{
AI_BOOL = 0,
AI_INT = 1,
AI_UINT64 = 2,
AI_FLOAT = 3,
AI_AISTRING = 4,
AI_AIVECTOR3D = 5,

FORCE_32BIT = INT_MAX
};`

Additional entries can be added as they become relevant. The current loaders that support metadata (FBX and IFC) uses a subset of the above types.

Lastly, I realize that this commit breaks the existing API. However, as metadata is still a new feature of Assimp I reckon that only few people used the old metadata API anyhow. I'm very open to any suggestions that you might have to improve the metadata handling! Be it in the API, the logic, or otherwise.