Skip to content

Fix hair fitting crash on Blender 5.x: uint8 cnts wrap under NumPy 2 (NEP-50) - #2

Merged
seenbuklee merged 1 commit into
seenbuklee:downloaderfrom
hr1juldey:blender5-hair-fix
Nov 15, 2026
Merged

seenbuklee merged 1 commit into
seenbuklee:downloaderfrom
hr1juldey:blender5-hair-fix

Conversation

@hr1juldey

Copy link
Copy Markdown

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

…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.
@seenbuklee
seenbuklee merged commit 1df2cc5 into seenbuklee:downloader Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants