Replace mj_makeEmptyFileVFS in Python bindings with mj_addBufferVFS.

PiperOrigin-RevId: 609383859
Change-Id: Ib23ee49e803630a2895a471e9a3ed8b33551cbb9
This commit is contained in:
Kyle Bayes
2024-02-22 08:35:42 -08:00
committed by Copybara-Service
parent 0ae9ba37f9
commit 109f2d7119
+5 -5
View File
@@ -20,6 +20,7 @@
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <exception>
#include <ios>
#include <iostream>
#include <memory>
@@ -28,6 +29,7 @@
#include <string>
#include <string_view>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <vector>
@@ -323,13 +325,11 @@ static raw::MjModel* LoadModelFileImpl(
});
mj_defaultVFS(vfs.get());
for (const auto& asset : assets) {
const int vfs_error = InterceptMjErrors(mj_makeEmptyFileVFS)(
vfs.get(), asset.name, asset.content_size);
const int vfs_error = InterceptMjErrors(mj_addBufferVFS)(
vfs.get(), asset.name, asset.content, asset.content_size);
if (vfs_error) {
throw py::value_error("assets dict is too big");
}
std::memcpy(vfs->filedata[vfs->nfile - 1],
asset.content, asset.content_size);
}
}
@@ -630,7 +630,7 @@ MjDataWrapper::MjWrapper(MjDataWrapper&& other)
#define MJ_M(x) (x)
#undef X
contact(MjContactList(ptr_->contact, NConMax(ptr_), &ptr_->ncon,owner_)),
contact(MjContactList(ptr_->contact, NConMax(ptr_), &ptr_->ncon, owner_)),
#define X(dtype, var, dim0, dim1) var(InitPyArray(ptr_->var, owner_)),
MJDATA_VECTOR