Skip to content

More robust gltf buffer memory views#145

Open
BlurryRoots wants to merge 1 commit into
Moguri:masterfrom
BlurryRoots:feature/gltf-memoryview-stride
Open

More robust gltf buffer memory views#145
BlurryRoots wants to merge 1 commit into
Moguri:masterfrom
BlurryRoots:feature/gltf-memoryview-stride

Conversation

@BlurryRoots
Copy link
Copy Markdown

It appears that the byteStride attribute is an element-level stride, not a byte-level slice step.
If we apply it as memoryview[::stride] it produces a non-C-contiguous view that will be rejected by struct.iter_unpack.
By introducing a get_buffer_stride method and using it with the calculated element_size depending on the scalar/vector size we can create a contiguous buffer from interleaved views.

Tested with provided pytests and their respective models.
Additionally tested with this (arguably cute) turtle https://sketchfab.com/3d-models/patsy-the-turtle-142e5d430b214ceba8510e47452bd910

Thanks for this nice loader.

introducing memory holes may corrupt contiguous space triggering errors like:
BufferError: memoryview: underlying buffer is not C-contiguous
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.

1 participant