From e05316edd4b1a27865727198a6a081713163fee2 Mon Sep 17 00:00:00 2001 From: jonasdichelle Date: Wed, 28 Aug 2024 12:58:53 +0200 Subject: [PATCH 1/2] added modifier walker for dynamic paint --- blender_asset_tracer/cdefs.py | 1 + .../trace/modifier_walkers.py | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/blender_asset_tracer/cdefs.py b/blender_asset_tracer/cdefs.py index 099a638..c5b7fd1 100644 --- a/blender_asset_tracer/cdefs.py +++ b/blender_asset_tracer/cdefs.py @@ -46,6 +46,7 @@ eModifierType_WeightVGEdit = 36 eModifierType_WeightVGMix = 37 eModifierType_WeightVGProximity = 38 eModifierType_Ocean = 39 +eModifierType_DynamicPaint = 40 eModifierType_MeshCache = 46 eModifierType_MeshSequenceCache = 52 eModifierType_Fluid = 56 diff --git a/blender_asset_tracer/trace/modifier_walkers.py b/blender_asset_tracer/trace/modifier_walkers.py index 12a0468..a813e80 100644 --- a/blender_asset_tracer/trace/modifier_walkers.py +++ b/blender_asset_tracer/trace/modifier_walkers.py @@ -22,6 +22,7 @@ The modifier_xxx() functions all yield result.BlockUsage objects for external files used by the modifiers. """ + import logging import typing @@ -317,3 +318,36 @@ def modifier_cloth( yield from _walk_point_cache( ctx, block_name, modifier.bfile, pointcache, cdefs.PTCACHE_EXT ) + + +@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 surface in blendfile.iterators.listbase(surfaces): + surface_block_name = block_name + b"%s.canvas_settings.surfaces[%d]" + 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 + ) -- 2.30.2 From bde361953b60a94f8d2f163cb145f6c2191bffb6 Mon Sep 17 00:00:00 2001 From: jonasdichelle Date: Thu, 29 Aug 2024 17:21:28 +0200 Subject: [PATCH 2/2] fixed block name --- blender_asset_tracer/trace/modifier_walkers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/blender_asset_tracer/trace/modifier_walkers.py b/blender_asset_tracer/trace/modifier_walkers.py index a813e80..597c287 100644 --- a/blender_asset_tracer/trace/modifier_walkers.py +++ b/blender_asset_tracer/trace/modifier_walkers.py @@ -337,8 +337,8 @@ def modifier_dynamic_paint( surfaces = canvas_settings.get_pointer((b"surfaces", b"first")) - for surface in blendfile.iterators.listbase(surfaces): - surface_block_name = block_name + b"%s.canvas_settings.surfaces[%d]" + 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( -- 2.30.2