Changeset View
Changeset View
Standalone View
Standalone View
tests/python/modifiers.py
- This file was added.
| # ##### BEGIN GPL LICENSE BLOCK ##### | |||||
| # | |||||
| # This program is free software; you can redistribute it and/or | |||||
| # modify it under the terms of the GNU General Public License | |||||
| # as published by the Free Software Foundation; either version 2 | |||||
| # of the License, or (at your option) any later version. | |||||
| # | |||||
| # This program is distributed in the hope that it will be useful, | |||||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| # GNU General Public License for more details. | |||||
| # | |||||
| # You should have received a copy of the GNU General Public License | |||||
| # along with this program; if not, write to the Free Software Foundation, | |||||
| # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||||
| # | |||||
| # ##### END GPL LICENSE BLOCK ##### | |||||
| # <pep8 compliant> | |||||
| import bpy | |||||
| import os | |||||
| import sys | |||||
| from random import shuffle, seed | |||||
| seed(0) | |||||
| sys.path.append(os.path.dirname(os.path.realpath(__file__))) | |||||
| from modules.mesh_test import ModifierTest, ModifierSpec | |||||
| def main(): | |||||
| all_modifiers = [ | |||||
brecht: This list seems unused, so can be removed?
It's going to go out of date quickly. | |||||
| 'MESH_CACHE', 'UV_PROJECT', 'UV_WARP', 'VERTEX_WEIGHT_EDIT', 'VERTEX_WEIGHT_MIX', 'VERTEX_WEIGHT_PROXIMITY', | |||||
| 'ARRAY', 'BEVEL', 'BOOLEAN', 'BUILD', 'DECIMATE', 'EDGE_SPLIT', 'MASK', 'MIRROR', 'MULTIRES', 'REMESH', 'SCREW', | |||||
| 'SKIN', 'SOLIDIFY', 'SUBSURF', 'TRIANGULATE', 'WIREFRAME', 'ARMATURE', 'CAST', 'CURVE', 'DISPLACE', 'HOOK', | |||||
| 'LAPLACIANSMOOTH', 'LAPLACIANDEFORM', 'LATTICE', 'MESH_DEFORM', 'SHRINKWRAP', 'SIMPLE_DEFORM', 'SMOOTH', 'WARP', | |||||
| 'WAVE', 'CLOTH', 'COLLISION', 'DYNAMIC_PAINT', 'EXPLODE', 'FLUID_SIMULATION', 'OCEAN', 'PARTICLE_INSTANCE', | |||||
| 'PARTICLE_SYSTEM', 'SMOKE', 'SOFT_BODY', 'SURFACE ' | |||||
| ] | |||||
| def get_generate_modifiers_list(test_object_name, randomize=False): | |||||
Done Inline ActionsStyle: no space before or after brackets. brecht: Style: no space before or after brackets. | |||||
| """ | |||||
| Construct a list of 'Generate' modifiers with default parameters. | |||||
| :param test_object_name: str - name of test object. Some modifiers like boolean need an extra parameter beside | |||||
| the default one. E.g. boolean needs object, mask needs vertex group etc... | |||||
| The extra parameter name will be <test_object_name>_<modifier_type> | |||||
| :param randomize: bool - if True shuffle the list of modifiers. | |||||
| :return: list of 'Generate' modifiers with default parameters. | |||||
| """ | |||||
| boolean_test_object = bpy.data.objects[test_object_name + "_boolean"] | |||||
| generate_modifiers = [ | |||||
| ModifierSpec('array', 'ARRAY', {}, True), | |||||
| ModifierSpec('bevel', 'BEVEL', {}, True), | |||||
| ModifierSpec('boolean', 'BOOLEAN', {'object': boolean_test_object}, True), | |||||
| ModifierSpec('build', 'BUILD', {'frame_start': 0, 'frame_duration': 1}, True), | |||||
| ModifierSpec('decimate', 'DECIMATE', {}, True), | |||||
| ModifierSpec('edge split', 'EDGE_SPLIT', {}, True), | |||||
| # mask can effectively delete the mesh since the vertex group need to be updated after each | |||||
| # applied modifier. Needs to be tested separately. | |||||
| # ModifierSpec('mask', 'MASK', {'vertex_group': mask_vertex_group}, False), | |||||
| ModifierSpec('mirror', 'MIRROR', {}, True), | |||||
| ModifierSpec('multires', 'MULTIRES', {}, True), | |||||
| # remesh can also cause an empty mesh. Skip. | |||||
| # ModifierSpec('remesh', 'REMESH', {}, True), | |||||
| # ModifierSpec('screw', 'SCREW', {}, True), # screw can make the test very slow. Skipping for now. | |||||
| # ModifierSpec('skin', 'SKIN', {}, True), # skin is not reproducible . | |||||
| ModifierSpec('solidify', 'SOLIDIFY', {}, True), | |||||
| ModifierSpec('subsurf', 'SUBSURF', {}, True), | |||||
| ModifierSpec('triangulate', 'TRIANGULATE', {}, True), | |||||
| ModifierSpec('wireframe', 'WIREFRAME', {}, True) | |||||
| ] | |||||
| if randomize: | |||||
| shuffle(generate_modifiers) | |||||
| return generate_modifiers | |||||
| mask_first_list = get_generate_modifiers_list("testCubeMaskFirst", randomize=True) | |||||
| mask_vertex_group = "testCubeMaskFirst" + "_mask" | |||||
| mask_first_list.insert(0, ModifierSpec('mask', 'MASK', {'vertex_group': mask_vertex_group}, True)) | |||||
| tests = [ | |||||
| ["testCube", "expectedCube", get_generate_modifiers_list("testCube")], | |||||
| ["testCubeRandom", "expectedCubeRandom", get_generate_modifiers_list("testCubeRandom", randomize=True)], | |||||
| ["testCubeSkin", "expectedCubeSkin", [ModifierSpec('skin', 'SKIN', {'branch_smoothing': 1}, True)]], | |||||
| ["testCubeMaskFirst", "expectedCubeMaskFirst", mask_first_list] | |||||
| ] | |||||
| modifiers_test = ModifierTest(tests) | |||||
| command = list(sys.argv) | |||||
| for i, cmd in enumerate(command): | |||||
| if cmd == "--run_all_tests": | |||||
| modifiers_test.run_all_tests() | |||||
| break | |||||
| elif cmd == "--run_test": | |||||
| index = int(command[i + 1]) | |||||
| modifiers_test.run_test(index) | |||||
| break | |||||
| if __name__ == "__main__": | |||||
| main() | |||||
This list seems unused, so can be removed?
It's going to go out of date quickly.