From 65b84a97de6c6edc2208ff9617aaecbf2f18229f Mon Sep 17 00:00:00 2001 From: Sean Kim Date: Wed, 16 Apr 2025 07:01:24 +0200 Subject: [PATCH] Tests: Add tests for `object.voxel_remesh` Pull Request: https://projects.blender.org/blender/blender/pulls/137378 --- tests/python/bl_object.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/python/bl_object.py b/tests/python/bl_object.py index 63078b14c29..30c68a503cf 100644 --- a/tests/python/bl_object.py +++ b/tests/python/bl_object.py @@ -19,6 +19,35 @@ class ClosestPointOnMeshTest(unittest.TestCase): self.assertEqual(ret_val[1], Vector((0.0, 0.0, 1.0))) +class RemeshTest(unittest.TestCase): + def setUp(self): + bpy.ops.wm.read_factory_settings(use_empty=True) + bpy.ops.ed.undo_push() + + bpy.ops.mesh.primitive_cube_add() + bpy.ops.sculpt.sculptmode_toggle() + + def test_operator_remeshes_basic_cube(self): + """Test that using the operator with default settings creates a mesh with the expected amount of vertices.""" + mesh = bpy.context.object.data + mesh.remesh_voxel_size = 0.1 + + ret_val = bpy.ops.object.voxel_remesh() + + self.assertEqual({'FINISHED'}, ret_val) + + num_vertices = mesh.attributes.domain_size('POINT') + self.assertEqual(num_vertices, 2648) + + def test_operator_doesnt_run_with_0_voxel_size(self): + """Test that using the operator returns an error to the user with a voxel size of 0.""" + mesh = bpy.context.object.data + mesh.remesh_voxel_size = 0 + + with self.assertRaises(RuntimeError): + bpy.ops.object.voxel_remesh() + + if __name__ == '__main__': import sys sys.argv = [__file__] + (sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else [])