Skip to content

Honor material creation when loading cached models - #160

Open
civilwarinfrance wants to merge 1 commit into
pywavefront:masterfrom
civilwarinfrance:fix/cache-create-materials
Open

civilwarinfrance wants to merge 1 commit into
pywavefront:masterfrom
civilwarinfrance:fix/cache-create-materials

Conversation

@civilwarinfrance

Copy link
Copy Markdown

create_materials=True lets OBJ parsing continue when a referenced material library is missing, but the cache loader accepts and then ignores that option. After a material file is removed, the same model loads normally without caching and raises OSError when loaded from an existing cache.

Retain the option in CacheLoader and skip unreadable material libraries when it is enabled, matching OBJ parsing. The existing vertex-buffer loader then supplies default materials for the missing definitions. Cached geometry and available material definitions stay intact. With the option disabled, the existing error remains. The README clarifies this behavior.

Regression tests create actual OBJ/MTL and compressed cache files, remove the first, second, or both material libraries, and compare cached geometry and material properties with uncached parsing. Controls cover intact libraries and the default error behavior.

Validation on Python 3.11.15/macOS:

  • Original loader: all three missing-library subcases fail; normal-cache and error controls pass.
  • Full suite: 94 passed, plus 5 passing subtests.
  • CI's required flake8 syntax/undefined-name check, new-test E/F check, and whitespace check pass.

Other Python versions and operating systems have not been run locally. No cache format change or dependencies. This is a reproduced code-inspection finding.

AI assistance was used to investigate, implement, and test this change.

Preserve create_materials in CacheLoader and tolerate missing material libraries consistently with OBJ parsing. Keep cached geometry and available material definitions intact.

AI assistance was used to investigate, implement, and test this change.
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