glTF-Blender-IO icon indicating copy to clipboard operation
glTF-Blender-IO copied to clipboard

No more miss cache on vertex group

Open julienduroure opened this issue 2 years ago • 8 comments

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

julienduroure avatar Dec 24 '21 09:12 julienduroure

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)

julienduroure avatar Dec 25 '21 22:12 julienduroure

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'

scurest avatar Dec 25 '21 23:12 scurest

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 )

julienduroure avatar Dec 28 '21 14:12 julienduroure

It uses a tuple of names for the material slots, just do that.

scurest avatar Dec 28 '21 14:12 scurest

  • 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

julienduroure avatar Dec 28 '21 15:12 julienduroure

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).

scurest avatar Dec 28 '21 15:12 scurest

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

julienduroure avatar Dec 28 '21 16:12 julienduroure

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

julienduroure avatar Mar 15 '22 17:03 julienduroure

This was solved by e4ccc2ec39da0a336cf7597415597b4fe7ded928 a long time ago, closing

julienduroure avatar Mar 14 '24 18:03 julienduroure