Add option to mjspec for creating a texture directly from a buffer.
PiperOrigin-RevId: 662186527 Change-Id: I469c876681d52964ac971c0bb2ec3517224d3a3d
This commit is contained in:
committed by
Copybara-Service
parent
20cae556ee
commit
851bb6eef4
@@ -146,6 +146,24 @@ def _ptr_binding_code(
|
||||
self.{fullvarname}->push_back(py::cast<{vartype}>(val));
|
||||
}}
|
||||
}}, py::return_value_policy::reference_internal);"""
|
||||
elif vartype == 'mjBuffer': # C++ buffer -> Python list
|
||||
return f"""\
|
||||
{classname}.def_property(
|
||||
"{varname}",
|
||||
[]({rawclassname}& self) -> py::list {{
|
||||
py::list list;
|
||||
for (auto val : *self.{fullvarname}) {{
|
||||
list.append(val);
|
||||
}}
|
||||
return list;
|
||||
}},
|
||||
[]({rawclassname}& self, py::object rhs) {{
|
||||
self.{fullvarname}->clear();
|
||||
self.{fullvarname}->reserve(py::len(rhs));
|
||||
for (auto val : rhs) {{
|
||||
self.{fullvarname}->push_back(py::cast<const std::byte>(val));
|
||||
}}
|
||||
}}, py::return_value_policy::reference_internal);"""
|
||||
elif vartype == 'mjStringVec': # C++ vector of strings -> Python list
|
||||
return f"""\
|
||||
{classname}.def_property(
|
||||
|
||||
Reference in New Issue
Block a user