openfl / away3d

An open source, real-time 3D engine for OpenFL
Apache License 2.0
208 stars 35 forks source link

Ensure material names are unique. #29

Closed player-03 closed 5 years ago

player-03 commented 5 years ago

Asset3DLibrary indexes meshes and materials based only on their names. If you have a mesh and a material with the same name, one must overwrite the other. This code usually sets the material name to decomposeID[1], even though decomposeID[1] is the name of the mesh it's attached to. Instant cache collision.

Not that everything this function acts on gets cached. I haven't dug through the code enough to figure out all the details, I just know that ColorMaterials do end up getting cached, so this matters for them.

Finally, something that applies to every material: if the user picked a name for a material, Away3D should use that name. Replacing the material name with the mesh name is just discarding useful information. If they didn't pick one, that's when it makes sense to use the mesh's name (plus a suffix for uniqueness).