예제 #1
0
os.environ["BLENDER_VRM_USE_TEST_EXPORTER_VERSION"] = "true"

expected_path, temp_dir_path = sys.argv[sys.argv.index("--") + 1 :]

bpy.ops.object.select_all(action="SELECT")
bpy.ops.object.delete()
while bpy.data.collections:
    bpy.data.collections.remove(bpy.data.collections[0])

bpy.ops.icyp.make_basic_armature()
bpy.ops.vrm.model_validate()

actual_path = os.path.join(temp_dir_path, "basic_armature.vrm")
bpy.ops.export_scene.vrm(filepath=actual_path)

float_tolerance = 0.000001
diffs = vrm_diff(
    pathlib.Path(actual_path).read_bytes(),
    pathlib.Path(expected_path).read_bytes(),
    float_tolerance,
)
diffs_str = "\n".join(diffs)

assert (
    len(diffs) == 0
), f"""Exceeded the VRM diff threshold::{float_tolerance:19.17f} for basic armature operator
left ={actual_path}
right={expected_path}
{diffs_str}"""
actual_out_path = os.path.join(temp_dir_path, os.path.basename(in_path))
bpy.ops.export_scene.vrm(filepath=actual_out_path)
actual_out_bytes = pathlib.Path(actual_out_path).read_bytes()

system = platform.system()
if system == "Darwin":
    float_tolerance = 0.0005
elif system == "Linux":
    float_tolerance = 0.0006
else:
    float_tolerance = 0.000001

if (update_vrm_dir and in_path.endswith(".vrm")
        and in_path != expected_out_path
        and not vrm_diff(actual_out_bytes,
                         pathlib.Path(in_path).read_bytes(), float_tolerance)):
    if os.path.exists(expected_out_path):
        fix_stderr_encoding()
        raise Exception(
            f"""The input and the output are same. The output file is unnecessary.
input ={in_path}
output={expected_out_path}
""")
    sys.exit(0)

try:
    diffs = vrm_diff(actual_out_bytes,
                     pathlib.Path(expected_out_path).read_bytes(),
                     float_tolerance)
except FileNotFoundError:
    if update_vrm_dir:
예제 #3
0
#!/usr/bin/env python3
"""
# noqa: INP001
"""

import sys
from os.path import dirname
from pathlib import Path

sys.path.insert(0, dirname(dirname(__file__)))

# pylint: disable=wrong-import-position;
from io_scene_vrm.importer.vrm_load import vrm_diff  # noqa: E402

# pylint: enable=wrong-import-position;

if __name__ == "__main__":
    float_tolerance = sys.float_info.epsilon
    if len(sys.argv) == 4:
        float_tolerance = float(sys.argv[3])
    diffs = vrm_diff(
        Path(sys.argv[1]).read_bytes(),
        Path(sys.argv[2]).read_bytes(), float_tolerance)
    for diff in diffs:
        print(diff)
    sys.exit(1 if diffs else 0)