make_texanim_reverse.py 824 B

12345678910111213141516171819202122
  1. #!/usr/bin/env python3
  2. """Copies the texture animation probe scene (texanim/probe of the live comparison tests) with the detached animations
  3. running backwards, for the coverage runs (coverage_testscenes.sh).
  4. Usage: make_texanim_reverse.py <texanim probe dir> <out dir>"""
  5. import json, os, shutil, sys
  6. source, out = sys.argv[1:3]
  7. shutil.rmtree(out, ignore_errors=True)
  8. shutil.copytree(source, out)
  9. path = os.path.join(out, "scene.json")
  10. scene = json.load(open(path))
  11. changed = 0
  12. for item in scene["objects"]:
  13. visible = item.get("visible")
  14. if isinstance(visible, dict) and "script" in visible:
  15. visible["script"] = visible["script"].replace("t[4].rate = 2;", "t[4].rate = -2; t[5].rate = -0.5;")
  16. changed += 1
  17. json.dump(scene, open(path, "w"), indent=1)
  18. print("ok" if changed else "no script found")