diff --git a/doc/changelog.rst b/doc/changelog.rst index 95febfa0..54801221 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -152,8 +152,8 @@ Compiler - Fixed loading of :ref:`.mjz ` archives in :ref:`simulate`: the archive was unmounted before model compilation, so assets failed to load. Failures in the :ref:`mjz ` decoder now emit a warning with the underlying error instead of the generic "could not decode content" message. -- The :ref:`mjz ` decoder now searches for ``model.xml`` at the root of the archive as a fallback if the - archive-named XML is not found. +- The :ref:`mjz ` decoder now searches for ``model.xml`` and ``/model.xml`` as a fallback if + ``.xml`` and ``/.xml`` are not found. - Added support for resource writing via :ref:`mju_writeResource` and the ``write`` callback in :ref:`mjpResourceProvider`. diff --git a/src/xml/mjz/mjz_decoder.cc b/src/xml/mjz/mjz_decoder.cc index eaf6c7c4..4f504100 100644 --- a/src/xml/mjz/mjz_decoder.cc +++ b/src/xml/mjz/mjz_decoder.cc @@ -89,15 +89,17 @@ class ZipArchiveProvider : public mjpResourceProvider { // Look for the root XML model in the archive. We try the following // locations: - // 1. [archive_name].xml at the root of the archive. - // 2. [archive_name]/[archive_name].xml inside a subdirectory. - // 3. model.xml at the root of the archive (common zipped MJCF pattern). + // 1. [archive_name].xml + // 2. [archive_name]/[archive_name].xml + // 3. model.xml + // 4. [archive_name]/model.xml const std::filesystem::path path(name_); const std::string stem = path.stem().string(); std::vector candidates = { (path / stem).generic_string() + ".xml", (path / stem / stem).generic_string() + ".xml", (path / "model").generic_string() + ".xml", + (path / stem / "model").generic_string() + ".xml", }; bool found = false;