glTF-Blender-IO
glTF-Blender-IO copied to clipboard
No more miss cache on vertex group
Vertex groups are now stored in mesh data, no more on object. So we can remove all code linked to avoid miss cache because of vertex group.
We will now be able to always pass vertex group to mesh extraction, this will now be possible to solve/enhance some exporter part where this was needed (This will solve #900, and is required for #747). This will solve some part of #1245
Not that simple. Seems
bpy.data.objects['Cube'].vertex_groups == bpy.data.objects['Cube.001'].vertex_groups
returns False, even if you instanciate Cube.001 from Cube (Alt+D)
You can still tell what object you got it from so it makes sense they aren't equal
>>> D.objects['Cube'].vertex_groups.id_data
bpy.data.objects['Cube']
>>> D.objects['Cube.001'].vertex_groups.id_data
bpy.data.objects['Cube.001']
But the exporter only cares about the list of names, and those do appear to be shared.
>>> D.objects['Cube'].vertex_groups[0].name = 'Razz'
>>> D.objects['Cube.001'].vertex_groups[0].name
'Razz'
But the exporter only cares about the list of names, and those do appear to be shared.
Current master is not using name for vertex group, as this is a collection of vertex group.
I think we still need a way to pass vertex groups to the function without create a miss cache. Using a custom cache could be the proper way (we start implement some custom cache - but not yet for meshes - in #1378 )
It uses a tuple of names for the material slots, just do that.
- Materials can be retrieved from mesh, but vertex group can't, so we can pass only a tuple of vertex group names
- Using name leads to errors (even for materials) in case of multiple linked file with same names. This is changed in #1378
Materials cannot be retrieved from the mesh because they can be overridden at the object level. That is why they are passed down to begin with.
Vertex groups are not IDs and cannot clash like materials can. Vertex groups have no cache relevance since they are part of the mesh and the mesh is already part of the cache key (theoretically).
Materials cannot be retrieved from the mesh because they can be overridden at the object level. That is why they are passed down to begin with.
What I mean here is that, even if materials are linked to object instead of mesh, we still can access materials using mesh.materials['name']. So name of materials is sufficient to get materials in gather_mesh function. Where this is not the case for vertex groups, where API is on object, and object is not pass as gather_mesh parameter
Vertex groups have no cache relevance since they are part of the mesh and the mesh is already part of the cache key (theoretically)
So let's using a custom cache where vertex groups are parameter of the function, but not used in cache key
After merge of #1378, VertexGroups are no more part of the cache key. Setting vertex_groups to None before calling gather_mesh should now be removed, not more relevant
This was solved by e4ccc2ec39da0a336cf7597415597b4fe7ded928 a long time ago, closing