mdl.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include "WallpaperEngine/Render/Objects/PuppetClipping.h"
  2. #include "WallpaperEngine/Render/Objects/PuppetMeshFile.h"
  3. #include "WallpaperEngine/Render/Objects/PuppetRig.h"
  4. #include <tuple>
  5. #include <vector>
  6. using namespace WallpaperEngine::Render::Objects;
  7. extern "C" int LLVMFuzzerTestOneInput (const uint8_t* bytes, size_t size) {
  8. const std::vector<char> data (reinterpret_cast<const char*> (bytes), reinterpret_cast<const char*> (bytes) + size);
  9. const auto mesh = readPuppetMeshFile (data);
  10. try {
  11. std::ignore = readMdlvMeshes (data);
  12. } catch (const std::exception&) { }
  13. if (!mesh.has_value ()) {
  14. return 0;
  15. }
  16. try {
  17. auto clipping = PuppetClipping::read (data, mesh->indexEnd, mesh->version, mesh->indices.size ());
  18. if (clipping.has_value ()) {
  19. clipping->build (mesh->indices);
  20. }
  21. } catch (const std::exception&) { }
  22. if (mesh->skeleton < data.size () && !mesh->blendIndices.empty ()) {
  23. try {
  24. PuppetRig rig;
  25. rig.load (data, mesh->sections, mesh->meshCount, "fuzz");
  26. rig.addSceneLayers ({});
  27. for (int i = 0; i < 4; i++) {
  28. rig.updatePose (glm::mat4 (1.0f));
  29. }
  30. } catch (const std::exception&) { }
  31. }
  32. return 0;
  33. }