Fix issue packing lamps with non-IES 'storage'

Lamp/light nodes might have a `storage` property that might point to an
IES texture node (which has the expected `filepath`), but not always.
The latter now no longer crashes BAT.

This fixes https://projects.blender.org/blender/blender-asset-tracer/pulls/92883
This commit is contained in:
Sybren A. Stüvel 2023-12-14 11:36:55 +01:00
parent 81ea8296da
commit 61dc5b8a23
2 changed files with 9 additions and 1 deletions

View File

@ -5,6 +5,8 @@ changed functionality, fixed bugs).
# Version 1.17 (in development)
- Fix issue packing lamps with non-IES 'storage' (File as Flamenco [issue #104269](https://projects.blender.org/studio/flamenco/issues/104269)).
# Version 1.16 (2023-11-02)
- Add `BlendFileBlock.raw_data()` and `.as_string()` functions. These functions interpret the data in a `BlendFileBlock` as either `bytes` or `string`. This can be used to obtain the contents of a `char*` (instead of the more common embedded `char[N]` array).

View File

@ -226,5 +226,11 @@ def lamp(block: blendfile.BlendFileBlock) -> typing.Iterator[result.BlockUsage]:
storage = node.get_pointer(b"storage")
if not storage:
continue
path, field = storage.get(b"filepath", return_field=True)
# A storage block of `NodeShaderTexIES` type has a `filepath`, but not
# all types that can be pointed to by the `storage` pointer do.
path, field = storage.get(b"filepath", return_field=True, default=None)
if path is None:
continue
yield result.BlockUsage(block, path, path_full_field=field)