mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
Cleanup: Reorganize remesh tests
Pull Request: https://projects.blender.org/blender/blender/pulls/154639
This commit is contained in:
parent
029354e372
commit
deaca53501
3 changed files with 59 additions and 29 deletions
|
|
@ -1390,6 +1390,11 @@ endif()
|
|||
# ------------------------------------------------------------------------------
|
||||
|
||||
if(TEST_SRC_DIR_EXISTS)
|
||||
add_blender_test(
|
||||
bl_voxel_remesh
|
||||
--python ${CMAKE_CURRENT_LIST_DIR}/sculpt_paint/voxel_remesh_test.py
|
||||
)
|
||||
|
||||
add_blender_test(
|
||||
bl_sculpt_mask
|
||||
--python ${CMAKE_CURRENT_LIST_DIR}/sculpt_paint/mask_test.py
|
||||
|
|
|
|||
|
|
@ -19,35 +19,6 @@ 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 [])
|
||||
|
|
|
|||
54
tests/python/sculpt_paint/voxel_remesh_test.py
Normal file
54
tests/python/sculpt_paint/voxel_remesh_test.py
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
# SPDX-FileCopyrightText: 2025 Blender Authors
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
__all__ = (
|
||||
"main",
|
||||
)
|
||||
|
||||
import os
|
||||
import unittest
|
||||
import sys
|
||||
|
||||
import bpy
|
||||
|
||||
"""
|
||||
blender -b --factory-startup --python tests/python/sculpt_paint/voxel_remesh_test.py
|
||||
"""
|
||||
|
||||
sys.path.append(os.path.dirname(os.path.realpath(__file__)))
|
||||
|
||||
|
||||
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 [])
|
||||
unittest.main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue