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

Added to Blender 4.1.0 in blender/blender@7d77caab9b, ShapeKey.points
gives optimized access to shape key points data (meshes/lattices) when
accessed with #foreach_get and #foreach_set.

This patch updates gltf to use ShapeKey.points, speeding up accessing
shape key data with #foreach_get/#foreach_set about 100 times on average
because gltf is using compatible buffers.


Best I can tell, squish(sk_vert_locs[sk_i]) will result in a C-contiguous buffer in this case and therefore will be compatible. If the goal of squish is to ensure a compatible 1D buffer, it may be better to use np.ndarray.ravel() instead of np.ndarray.reshape() because ravel() also ensures the result is contiguous.

Added to Blender 4.1.0 in blender/blender@7d77caab9b, ShapeKey.points gives optimized access to shape key points data (meshes/lattices) when accessed with #foreach_get and #foreach_set. This patch updates gltf to use ShapeKey.points, speeding up accessing shape key data with #foreach_get/#foreach_set about 100 times on average because gltf is using compatible buffers. --- Best I can tell, `squish(sk_vert_locs[sk_i])` will result in a C-contiguous buffer in this case and therefore will be compatible. If the goal of `squish` is to ensure a compatible 1D buffer, it may be better to use `np.ndarray.ravel()` instead of `np.ndarray.reshape()` because `ravel()` also ensures the result is contiguous.
Thomas Barlow added 1 commit 2024-01-17 14:49:23 +01:00
Added to Blender 4.1.0 in ??????????, ShapeKey.points gives optimized
access to shape key points data (meshes/lattices) when accessed with
#foreach_get and #foreach_set.
Author
Member

This PR should be fine as it is now, but I'm holding off on removing the WIP for a bit while I investigate why, out of the models I was profiling with, one of the heavier model's with large meshes and lots of shape keys takes 40s to export, both before and after.

Edit: That model exports in just under 6 seconds if I disable shape key normals. When exporting shape key normals, the slow access to shape key normals and the extra size and extra sorts (though np.unique) of the PrimitiveCreator.dots array take about 31s. I think I have workarounds for both to reduce that 31s by quite a bit. I'll try and put some code and additional PRs together.

This PR should be fine as it is now, but I'm holding off on removing the WIP for a bit while I investigate why, out of the models I was profiling with, one of the heavier model's with large meshes and lots of shape keys takes 40s to export, both before and after. Edit: That model exports in just under 6 seconds if I disable shape key normals. When exporting shape key normals, the slow access to shape key normals and the extra size and extra sorts (though `np.unique`) of the `PrimitiveCreator.dots` array take about 31s. I think I have workarounds for both to reduce that 31s by quite a bit. I'll try and put some code and additional PRs together.
Thomas Barlow changed title from WIP: gltf: Use the new ShapeKey.points with faster foreach_get/set to gltf: Use the new ShapeKey.points with faster foreach_get/set 2024-01-24 04:52:57 +01:00
Member

Hello,

Let's close this PR, and continue discussion on PR you submitted in upstream repository:
https://github.com/KhronosGroup/glTF-Blender-IO/pull/2125

Hello, Let's close this PR, and continue discussion on PR you submitted in upstream repository: https://github.com/KhronosGroup/glTF-Blender-IO/pull/2125
Julien Duroure closed this pull request 2024-01-31 03:15:30 +01:00

Pull request closed

Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#105134
No description provided.