blender/tests/python/physics_fluid_cache.py
Tibo Stans e0bffa0a9a Fix #158108: Clear stale liquid mesh after failed cache load
When a liquid mesh cache file was missing or failed to load,
`MANTA::readMesh()` returned without clearing mesh data from the
previously loaded frame.

The stale mesh nodes, triangles, and velocities could then be reused as
valid geometry. This made direct frame jumps inconsistently show either
an older liquid surface or the fluid domain bounds, depending on the
previous evaluation state.

Clear the previous mesh data when the requested cache is unavailable or
fails to load, allowing evaluation to correctly fall back to the domain
geometry.

Pull Request: https://projects.blender.org/blender/blender/pulls/161305
2026-07-13 16:20:31 +02:00

43 lines
1.1 KiB
Python

# SPDX-FileCopyrightText: 2026 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later
import unittest
import bpy
def mesh_counts(mesh):
return (
len(mesh.vertices),
len(mesh.edges),
len(mesh.polygons),
)
class FluidCacheTest(unittest.TestCase):
def test_missing_mesh_cache_does_not_reuse_previous_frame(self):
scene = bpy.context.scene
domain = bpy.data.objects["Cube"]
original_counts = mesh_counts(domain.data)
# Frame 1 has a cached liquid surface.
scene.frame_set(1)
depsgraph = bpy.context.evaluated_depsgraph_get()
cached_counts = mesh_counts(domain.evaluated_get(depsgraph).data)
self.assertNotEqual(cached_counts, original_counts)
# Frame 2 intentionally has no liquid mesh cache.
scene.frame_set(2)
depsgraph = bpy.context.evaluated_depsgraph_get()
missing_cache_counts = mesh_counts(domain.evaluated_get(depsgraph).data)
self.assertEqual(missing_cache_counts, original_counts)
if __name__ == "__main__":
import sys
sys.argv = [__file__]
unittest.main()