Repository navigation
Fix hair fitting crash on Blender 5.x: uint8 cnts wrap under NumPy 2 (NEP-50) - #2
Merged
Merged
Conversation
…NEP-50 Hairstyle .npz files store per-particle key counts as uint8. In update_hair(), 'pos += cnt' and the slice bounds 'morphed[pos:pos+cnt+1]' inherit that dtype. Under NumPy 1.x these promoted to int64 silently; under NumPy 2 (Blender 5.x - Python 3.13 only has NumPy 2.x wheels) NEP-50 keeps uint8, so once cumulative pos crosses 255 (~7 particles of cnt=36) the arithmetic wraps (uint8(250)+61=55), slices become empty, and marr[0] raises IndexError: index 0 is out of bounds for axis 0 with size 0. All 20 bundled Vitruvian hairstyle npz files verified internally consistent (len(data)==sum(cnt)) - this is purely dtype arithmetic. Fix: cast cnts to int64 at load. Verified end-to-end headless on Blender 5.2: Vitruvian + Bob hairstyle + finalize CA + rigify, zero exceptions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
One-line fix: hairstyle npz 'cnt' arrays are uint8; under NumPy 2 (Blender 5.x / py3.13 has only numpy 2 wheels) 'pos += cnt' and slice bounds keep the dtype and wrap at 256, producing empty slices -> IndexError in update_hair. Cast to int64 at load. Repro, measurements and the 20-npz consistency audit available. (Note: the finalize CA fix and the name_to_obj children-resolution that master still lacks are already correct on this branch - this PR only adds the hair fix.)