Add Support for Geometry Node Cache #92890

Open
Jonas Dichelle wants to merge 14 commits from JonasDichelle/blender-asset-tracer:geonodes_support into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
6 changed files with 914 additions and 746 deletions
Showing only changes of commit 4f7af9b75e - Show all commits

View File

@ -3,6 +3,10 @@
This file logs the changes that are actually interesting to users (new features, This file logs the changes that are actually interesting to users (new features,
changed functionality, fixed bugs). changed functionality, fixed bugs).
# Version 1.19 (in development)
- Add support for tracing dynamic paint caches ([#92889](https://projects.blender.org/blender/blender-asset-tracer/pulls/92889)).
# Version 1.18 (2024-01-11) # Version 1.18 (2024-01-11)
- When logging that there is no reader implemented for a certain data-block type, the filepath of the blend file that contains that data-block is now included in the message ([#92885](https://projects.blender.org/blender/blender-asset-tracer/pulls/92885)). - When logging that there is no reader implemented for a certain data-block type, the filepath of the blend file that contains that data-block is now included in the message ([#92885](https://projects.blender.org/blender/blender-asset-tracer/pulls/92885)).

View File

@ -260,6 +260,7 @@ class Struct:
b"short": endian.read_short, b"short": endian.read_short,
b"uint64_t": endian.read_ulong, b"uint64_t": endian.read_ulong,
b"float": endian.read_float, b"float": endian.read_float,
b"int8_t": endian.read_int8,
} }
try: try:
simple_reader = simple_readers[dna_type.dna_type_id] simple_reader = simple_readers[dna_type.dna_type_id]

View File

@ -28,6 +28,7 @@ import typing
class EndianIO: class EndianIO:
# TODO(Sybren): note as UCHAR: struct.Struct = None and move actual structs to LittleEndianTypes # TODO(Sybren): note as UCHAR: struct.Struct = None and move actual structs to LittleEndianTypes
UCHAR = struct.Struct(b"<B") UCHAR = struct.Struct(b"<B")
SINT8 = struct.Struct(b"<b")
USHORT = struct.Struct(b"<H") USHORT = struct.Struct(b"<H")
USHORT2 = struct.Struct(b"<HH") # two shorts in a row USHORT2 = struct.Struct(b"<HH") # two shorts in a row
SSHORT = struct.Struct(b"<h") SSHORT = struct.Struct(b"<h")
@ -62,6 +63,14 @@ class EndianIO:
def write_char(cls, fileobj: typing.IO[bytes], value: int): def write_char(cls, fileobj: typing.IO[bytes], value: int):
return cls._write(fileobj, cls.UCHAR, value) return cls._write(fileobj, cls.UCHAR, value)
@classmethod
def read_int8(cls, fileobj: typing.IO[bytes]):
return cls._read(fileobj, cls.SINT8)
@classmethod
def write_int8(cls, fileobj: typing.IO[bytes], value: int):
return cls._write(fileobj, cls.SINT8, value)
@classmethod @classmethod
def read_ushort(cls, fileobj: typing.IO[bytes]): def read_ushort(cls, fileobj: typing.IO[bytes]):
return cls._read(fileobj, cls.USHORT) return cls._read(fileobj, cls.USHORT)
@ -207,6 +216,7 @@ class EndianIO:
""" """
return { return {
b"char": cls.write_char, b"char": cls.write_char,
b"int8": cls.write_int8,
b"ushort": cls.write_ushort, b"ushort": cls.write_ushort,
b"short": cls.write_short, b"short": cls.write_short,
b"uint": cls.write_uint, b"uint": cls.write_uint,
@ -222,6 +232,7 @@ class LittleEndianTypes(EndianIO):
class BigEndianTypes(LittleEndianTypes): class BigEndianTypes(LittleEndianTypes):
UCHAR = struct.Struct(b">B") UCHAR = struct.Struct(b">B")
SINT8 = struct.Struct(b">b")
USHORT = struct.Struct(b">H") USHORT = struct.Struct(b">H")
USHORT2 = struct.Struct(b">HH") # two shorts in a row USHORT2 = struct.Struct(b">HH") # two shorts in a row
SSHORT = struct.Struct(b">h") SSHORT = struct.Struct(b">h")

View File

@ -46,6 +46,7 @@ eModifierType_WeightVGEdit = 36
eModifierType_WeightVGMix = 37 eModifierType_WeightVGMix = 37
eModifierType_WeightVGProximity = 38 eModifierType_WeightVGProximity = 38
eModifierType_Ocean = 39 eModifierType_Ocean = 39
eModifierType_DynamicPaint = 40
eModifierType_MeshCache = 46 eModifierType_MeshCache = 46
eModifierType_MeshSequenceCache = 52 eModifierType_MeshSequenceCache = 52
eModifierType_Fluid = 56 eModifierType_Fluid = 56

View File

@ -320,6 +320,39 @@ def modifier_cloth(
) )
@mod_handler(cdefs.eModifierType_DynamicPaint)
def modifier_dynamic_paint(
ctx: ModifierContext, modifier: blendfile.BlendFileBlock, block_name: bytes
) -> typing.Iterator[result.BlockUsage]:
my_log = log.getChild("modifier_dynamic_paint")
canvas_settings = modifier.get_pointer(b"canvas")
if canvas_settings is None:
my_log.debug(
"Modifier %r (%r) has no canvas_settings",
modifier[b"modifier", b"name"],
block_name,
)
return
surfaces = canvas_settings.get_pointer((b"surfaces", b"first"))
for surf_idx, surface in enumerate(blendfile.iterators.listbase(surfaces)):
surface_block_name = block_name + b".canvas_settings.surfaces[%d]" % (surf_idx)
point_cache = surface.get_pointer(b"pointcache")
if point_cache is None:
my_log.debug(
"Surface %r (%r) has no pointcache",
surface[b"surface", b"name"],
surface_block_name,
)
continue
yield from _walk_point_cache(
ctx, surface_block_name, modifier.bfile, point_cache, cdefs.PTCACHE_EXT
)
@mod_handler(cdefs.eModifierType_Nodes) @mod_handler(cdefs.eModifierType_Nodes)
def modifier_nodes( def modifier_nodes(
ctx: ModifierContext, modifier: blendfile.BlendFileBlock, block_name: bytes ctx: ModifierContext, modifier: blendfile.BlendFileBlock, block_name: bytes

1594
poetry.lock generated

File diff suppressed because it is too large Load Diff