gltf: Use the new ShapeKey.points with faster foreach_get/set #105134

Closed
Thomas Barlow wants to merge 1 commits from Mysteryem/blender-addons:shape_key_points_gltf into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
2 changed files with 3 additions and 3 deletions

View File

@ -871,14 +871,14 @@ class PrimitiveCreator:
def __get_positions(self): def __get_positions(self):
self.locs = np.empty(len(self.blender_mesh.vertices) * 3, dtype=np.float32) self.locs = np.empty(len(self.blender_mesh.vertices) * 3, dtype=np.float32)
source = self.key_blocks[0].relative_key.data if self.key_blocks else self.blender_mesh.vertices source = self.key_blocks[0].relative_key.points if self.key_blocks else self.blender_mesh.vertices
source.foreach_get('co', self.locs) source.foreach_get('co', self.locs)
self.locs = self.locs.reshape(len(self.blender_mesh.vertices), 3) self.locs = self.locs.reshape(len(self.blender_mesh.vertices), 3)
self.morph_locs = [] self.morph_locs = []
for key_block in self.key_blocks: for key_block in self.key_blocks:
vs = np.empty(len(self.blender_mesh.vertices) * 3, dtype=np.float32) vs = np.empty(len(self.blender_mesh.vertices) * 3, dtype=np.float32)
key_block.data.foreach_get('co', vs) key_block.points.foreach_get('co', vs)
vs = vs.reshape(len(self.blender_mesh.vertices), 3) vs = vs.reshape(len(self.blender_mesh.vertices), 3)
self.morph_locs.append(vs) self.morph_locs.append(vs)

View File

@ -370,7 +370,7 @@ def do_primitives(gltf, mesh_idx, skin_idx, mesh, ob):
ob.shape_key_add(name=sk_name) ob.shape_key_add(name=sk_name)
key_block = mesh.shape_keys.key_blocks[sk_name] key_block = mesh.shape_keys.key_blocks[sk_name]
key_block.data.foreach_set('co', squish(sk_vert_locs[sk_i])) key_block.points.foreach_set('co', squish(sk_vert_locs[sk_i]))
sk_i += 1 sk_i += 1