Move MjrRect pybind11 definition to structs.cc.
mjrRect is a common type that will be re-used across different rendering APIs, not just mjr_ APIs. PiperOrigin-RevId: 882620060 Change-Id: I7f77ac9298c52c454d94c46379ff5270fd833f26
This commit is contained in:
committed by
Copybara-Service
parent
b294d15558
commit
7f437810fd
@@ -158,25 +158,6 @@ PYBIND11_MODULE(_render, pymodule) {
|
||||
// for MjWrapper types and therefore generates prettier docstrings.
|
||||
py::module::import("mujoco._structs");
|
||||
|
||||
py::class_<raw::MjrRect> mjrRect(pymodule, "MjrRect");
|
||||
mjrRect.def(py::init([](int left, int bottom, int width, int height) {
|
||||
return raw::MjrRect{left, bottom, width, height};
|
||||
}),
|
||||
py::arg("left"), py::arg("bottom"), py::arg("width"),
|
||||
py::arg("height"));
|
||||
mjrRect.def("__copy__",
|
||||
[](const raw::MjrRect& other) { return raw::MjrRect(other); });
|
||||
mjrRect.def("__deepcopy__", [](const raw::MjrRect& other, py::dict) {
|
||||
return raw::MjrRect(other);
|
||||
});
|
||||
DefineStructFunctions(mjrRect);
|
||||
#define X(var) mjrRect.def_readwrite(#var, &raw::MjrRect::var)
|
||||
X(left);
|
||||
X(bottom);
|
||||
X(width);
|
||||
X(height);
|
||||
#undef X
|
||||
|
||||
py::class_<MjrContextWrapper> mjrContext(pymodule, "MjrContext");
|
||||
mjrContext.def(py::init<>());
|
||||
mjrContext.def(py::init<const MjModelWrapper&, int>());
|
||||
|
||||
@@ -898,6 +898,27 @@ This is useful for example when the MJB is not available as a file on disk.)"));
|
||||
X(tolrange);
|
||||
#undef X
|
||||
|
||||
|
||||
// ==================== MJRRECT ==============================================
|
||||
py::class_<raw::MjrRect> mjrRect(m, "MjrRect");
|
||||
mjrRect.def(py::init([](int left, int bottom, int width, int height) {
|
||||
return raw::MjrRect{left, bottom, width, height};
|
||||
}),
|
||||
py::arg("left"), py::arg("bottom"), py::arg("width"),
|
||||
py::arg("height"));
|
||||
mjrRect.def("__copy__",
|
||||
[](const raw::MjrRect& other) { return raw::MjrRect(other); });
|
||||
mjrRect.def("__deepcopy__", [](const raw::MjrRect& other, py::dict) {
|
||||
return raw::MjrRect(other);
|
||||
});
|
||||
DefineStructFunctions(mjrRect);
|
||||
#define X(var) mjrRect.def_readwrite(#var, &raw::MjrRect::var)
|
||||
X(left);
|
||||
X(bottom);
|
||||
X(width);
|
||||
X(height);
|
||||
#undef X
|
||||
|
||||
// ==================== MJVPERTURB ===========================================
|
||||
py::class_<MjvPerturbWrapper> mjvPerturb(m, "MjvPerturb");
|
||||
mjvPerturb.def(py::init<>());
|
||||
|
||||
Reference in New Issue
Block a user