Fix T55542: BAT doesn't pack smoke cache
This commit is contained in:
parent
893c1f2231
commit
4e1c2d1bbb
@ -39,6 +39,7 @@ eModifierType_Displace = 14
|
||||
eModifierType_UVProject = 15
|
||||
eModifierType_ParticleSystem = 19
|
||||
eModifierType_Fluidsim = 26
|
||||
eModifierType_Smokesim = 31
|
||||
eModifierType_WeightVGEdit = 36
|
||||
eModifierType_WeightVGMix = 37
|
||||
eModifierType_WeightVGProximity = 38
|
||||
@ -58,7 +59,10 @@ PTCACHE_DISK_CACHE = 64
|
||||
PTCACHE_EXTERNAL = 512
|
||||
|
||||
# BKE_pointcache.h
|
||||
PTCACHE_FILE_PTCACHE = 0
|
||||
PTCACHE_FILE_OPENVDB = 1
|
||||
PTCACHE_EXT = b'.bphys'
|
||||
PTCACHE_EXT_VDB = b'.vdb'
|
||||
PTCACHE_PATH = b'blendcache_'
|
||||
|
||||
# BKE_node.h
|
||||
|
||||
@ -127,7 +127,8 @@ def modifier_image(ctx: ModifierContext, modifier: blendfile.BlendFileBlock, blo
|
||||
def _walk_point_cache(ctx: ModifierContext,
|
||||
block_name: bytes,
|
||||
bfile: blendfile.BlendFile,
|
||||
pointcache: blendfile.BlendFileBlock):
|
||||
pointcache: blendfile.BlendFileBlock,
|
||||
extension: bytes):
|
||||
flag = pointcache[b'flag']
|
||||
if flag & cdefs.PTCACHE_DISK_CACHE:
|
||||
# See ptcache_path() in pointcache.c
|
||||
@ -140,7 +141,7 @@ def _walk_point_cache(ctx: ModifierContext,
|
||||
cdefs.PTCACHE_PATH,
|
||||
bfile.filepath.stem.encode(),
|
||||
name,
|
||||
cdefs.PTCACHE_EXT)
|
||||
extension)
|
||||
bpath = bpathlib.BlendPath(path)
|
||||
yield result.BlockUsage(pointcache, bpath, path_full_field=field,
|
||||
is_sequence=True, block_name=block_name)
|
||||
@ -162,7 +163,7 @@ def modifier_particle_system(ctx: ModifierContext, modifier: blendfile.BlendFile
|
||||
if pointcache is None:
|
||||
return
|
||||
|
||||
yield from _walk_point_cache(ctx, block_name, modifier.bfile, pointcache)
|
||||
yield from _walk_point_cache(ctx, block_name, modifier.bfile, pointcache, cdefs.PTCACHE_EXT)
|
||||
|
||||
|
||||
@mod_handler(cdefs.eModifierType_Fluidsim)
|
||||
@ -189,4 +190,27 @@ def modifier_fluid_sim(ctx: ModifierContext, modifier: blendfile.BlendFileBlock,
|
||||
# (in Blender's source there is a point_cache pointer, but it's NULL in my test)
|
||||
pointcache = modifier.get_pointer(b'point_cache')
|
||||
if pointcache:
|
||||
yield from _walk_point_cache(ctx, block_name, modifier.bfile, pointcache)
|
||||
yield from _walk_point_cache(ctx, block_name, modifier.bfile, pointcache, cdefs.PTCACHE_EXT)
|
||||
|
||||
|
||||
@mod_handler(cdefs.eModifierType_Smokesim)
|
||||
def modifier_smoke_sim(ctx: ModifierContext, modifier: blendfile.BlendFileBlock, block_name: bytes) \
|
||||
-> typing.Iterator[result.BlockUsage]:
|
||||
my_log = log.getChild('modifier_smoke_sim')
|
||||
|
||||
domain = modifier.get_pointer(b'domain')
|
||||
if domain is None:
|
||||
my_log.debug('Modifier %r (%r) has no domain',
|
||||
modifier[b'modifier', b'name'], block_name)
|
||||
return
|
||||
|
||||
pointcache = domain.get_pointer(b'point_cache')
|
||||
if pointcache is None:
|
||||
return
|
||||
|
||||
format = domain.get(b'cache_file_format')
|
||||
extensions = {
|
||||
cdefs.PTCACHE_FILE_PTCACHE: cdefs.PTCACHE_EXT,
|
||||
cdefs.PTCACHE_FILE_OPENVDB: cdefs.PTCACHE_EXT_VDB
|
||||
}
|
||||
yield from _walk_point_cache(ctx, block_name, modifier.bfile, pointcache, extensions[format])
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
tests/blendfiles/T55542-smoke/smoke_cache.blend
Normal file
BIN
tests/blendfiles/T55542-smoke/smoke_cache.blend
Normal file
Binary file not shown.
BIN
tests/blendfiles/T55542-smoke/smoke_cache_vdb.blend
Normal file
BIN
tests/blendfiles/T55542-smoke/smoke_cache_vdb.blend
Normal file
Binary file not shown.
@ -405,6 +405,23 @@ class ProgressTest(AbstractPackTest):
|
||||
self.assertGreaterEqual(cb.transfer_progress.call_count, 2,
|
||||
'transfer_progress() should be called at least once per asset')
|
||||
|
||||
def test_smoke_cache(self):
|
||||
# The smoke cache uses a glob to indicate which files to pack.
|
||||
cb = mock.Mock(progress.Callback)
|
||||
infile = self.blendfiles / 'T55542-smoke/smoke_cache.blend'
|
||||
with pack.Packer(infile, self.blendfiles, self.tpath) as packer:
|
||||
packer.progress_cb = cb
|
||||
packer.strategise()
|
||||
packer.execute()
|
||||
|
||||
# We should have all the *.bphys files now.
|
||||
count = len(list((self.tpath / 'T55542-smoke/blendcache_smoke_cache').glob('*.bphys')))
|
||||
self.assertEqual(10, count)
|
||||
|
||||
# Physics files + smoke_cache.blend + pack_info.txt
|
||||
self.assertGreaterEqual(cb.transfer_progress.call_count, 12,
|
||||
'transfer_progress() should be called at least once per asset')
|
||||
|
||||
|
||||
class AbortTest(AbstractPackTest):
|
||||
def test_abort_strategise(self):
|
||||
|
||||
@ -176,6 +176,18 @@ class DepsTest(AbstractTracerTest):
|
||||
b'//blendcache_particle/43756265_*.bphys', True),
|
||||
})
|
||||
|
||||
def test_smoke(self):
|
||||
# This file has an empty name for the cache, which should result in some hex magic
|
||||
# to create a name. See ptcache_filename() in pointcache.c.
|
||||
self.assert_deps('T55542-smoke/smoke_cache.blend', {
|
||||
b'OBSmoke Domain.modifiers[0]': Expect('PointCache', 'name[64]', None, None,
|
||||
b'//blendcache_smoke_cache/536D6F6B6520446F6D61696E_*.bphys', True),
|
||||
})
|
||||
self.assert_deps('T55542-smoke/smoke_cache_vdb.blend', {
|
||||
b'OBSmoke Domain.modifiers[0]': Expect('PointCache', 'name[64]', None, None,
|
||||
b'//blendcache_smoke_cache_vdb/536D6F6B6520446F6D61696E_*.vdb', True),
|
||||
})
|
||||
|
||||
def test_mesh_cache(self):
|
||||
self.assert_deps('meshcache-user.blend', {
|
||||
b'OBPlane.modifiers[0]': Expect('MeshCacheModifierData', 'filepath[1024]', None, None,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user