Add <stem>/model.xml search path to mjz_decoder.
PiperOrigin-RevId: 952128127 Change-Id: I8a514297d84026a6028b2416e43df9b5a2a92bbb
This commit is contained in:
committed by
Copybara-Service
parent
b6ab11dc6b
commit
1a5af23558
+2
-2
@@ -152,8 +152,8 @@ Compiler
|
|||||||
- Fixed loading of :ref:`.mjz <MJZArchives>` archives in :ref:`simulate<saSimulate>`: the archive was unmounted
|
- Fixed loading of :ref:`.mjz <MJZArchives>` archives in :ref:`simulate<saSimulate>`: the archive was unmounted
|
||||||
before model compilation, so assets failed to load. Failures in the :ref:`mjz <MJZArchives>` decoder now emit a
|
before model compilation, so assets failed to load. Failures in the :ref:`mjz <MJZArchives>` decoder now emit a
|
||||||
warning with the underlying error instead of the generic "could not decode content" message.
|
warning with the underlying error instead of the generic "could not decode content" message.
|
||||||
- The :ref:`mjz <MJZArchives>` decoder now searches for ``model.xml`` at the root of the archive as a fallback if the
|
- The :ref:`mjz <MJZArchives>` decoder now searches for ``model.xml`` and ``<stem>/model.xml`` as a fallback if
|
||||||
archive-named XML is not found.
|
``<stem>.xml`` and ``<stem>/<stem>.xml`` are not found.
|
||||||
- Added support for resource writing via :ref:`mju_writeResource` and the ``write`` callback in
|
- Added support for resource writing via :ref:`mju_writeResource` and the ``write`` callback in
|
||||||
:ref:`mjpResourceProvider`.
|
:ref:`mjpResourceProvider`.
|
||||||
|
|
||||||
|
|||||||
@@ -89,15 +89,17 @@ class ZipArchiveProvider : public mjpResourceProvider {
|
|||||||
|
|
||||||
// Look for the root XML model in the archive. We try the following
|
// Look for the root XML model in the archive. We try the following
|
||||||
// locations:
|
// locations:
|
||||||
// 1. [archive_name].xml at the root of the archive.
|
// 1. [archive_name].xml
|
||||||
// 2. [archive_name]/[archive_name].xml inside a subdirectory.
|
// 2. [archive_name]/[archive_name].xml
|
||||||
// 3. model.xml at the root of the archive (common zipped MJCF pattern).
|
// 3. model.xml
|
||||||
|
// 4. [archive_name]/model.xml
|
||||||
const std::filesystem::path path(name_);
|
const std::filesystem::path path(name_);
|
||||||
const std::string stem = path.stem().string();
|
const std::string stem = path.stem().string();
|
||||||
std::vector<std::string> candidates = {
|
std::vector<std::string> candidates = {
|
||||||
(path / stem).generic_string() + ".xml",
|
(path / stem).generic_string() + ".xml",
|
||||||
(path / stem / stem).generic_string() + ".xml",
|
(path / stem / stem).generic_string() + ".xml",
|
||||||
(path / "model").generic_string() + ".xml",
|
(path / "model").generic_string() + ".xml",
|
||||||
|
(path / stem / "model").generic_string() + ".xml",
|
||||||
};
|
};
|
||||||
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user