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.
Showing only changes of commit 9d4b2159ba - Show all commits

View File

@ -166,7 +166,6 @@ class BlendFile:
break
if block.code == b"DNA1":
# for i in range(block.count):
self.decode_structs(block)
else:
self.fileobj.seek(block.size, os.SEEK_CUR)
@ -351,7 +350,6 @@ class BlendFile:
else:
dna_size = dna_type.size * dna_name.array_size
# For other fields, proceed as usual
field = dna.Field(dna_type, dna_name, dna_size, dna_offset)
dna_struct.append_field(field)
dna_offset += dna_size
@ -472,12 +470,6 @@ class BlendFileBlock:
self.addr_old = blockheader[2]
self.sdna_index = blockheader[3]
self.count = blockheader[4]
# if self.count > 1:
# self.size = self.size // self.count
# if self.count > 1:
# print(self.count)
# print("size is 144")
self.file_offset = bfile.fileobj.tell()
def __repr__(self) -> str:
@ -766,35 +758,6 @@ class BlendFileBlock:
continue
yield dereferenced
def iter_array_from_pointer(
self, path: dna.FieldPath, array_size: int
) -> typing.Iterator["BlendFileBlock"]:
"""Dereference pointers from an array field.
:param path: The array-of-pointers field.
:param array_size: Number of items in the array. If None, the
on-disk size of the DNA field is divided by the pointer size to
obtain the array size.
"""
if array_size == 0:
return
array = self.get_pointer(path)
array_ptr = self.get(path)
assert array_ptr is not None
item_size = array.size // array_size
for i in range(array_size):
print(i)
address = array_ptr + (item_size * i)
print(address)
if address == 0:
continue
dereferenced = self.bfile.dereference_pointer(address)
yield dereferenced
def iter_fixed_array_of_pointers(
self, path: dna.FieldPath
) -> typing.Iterator["BlendFileBlock"]:
@ -831,29 +794,6 @@ class BlendFileBlock:
continue
yield dereferenced
def iter_bakes(self, array_size: int) -> typing.Iterator["BlendFileBlock"]:
"""Iterate over an array of NodesModifierBake pointers with known size."""
path = (
b"bakes" # Assuming 'bakes' is the DNA field name for the array of pointers
)
if array_size == 0:
return
array = self.get_pointer(path)
assert array and array.code == b"DATA", "Expected DATA block, got {}".format(
array.code.decode()
)
file_offset = array.file_offset
ps = self.bfile.header.pointer_size
for i in range(array_size):
address = self.bfile.read_pointer_at(file_offset + ps * i)
if address:
dereferenced = self.bfile.dereference_pointer(address)
if dereferenced:
yield dereferenced
def __getitem__(self, path: dna.FieldPath):
return self.get(path)