pub struct MjViewerCpp<M: Deref<Target = MjModel> + Clone> { /* private fields */ }Expand description
Wrapper around the C++ implementation of MujoCo viewer.
If you don’t need the side UI, we recommend you use the Rust-native viewer crate::viewer::MjViewer instead.
§Safety
Calls to MjViewerCpp::render must be done only on the main thread!
For convenience MjViewerCpp implements both Send and Sync, however that is meant only for
syncing the viewer.
Additionally, to allow certain flexibility while still maintaining
compatibility with the C++ code, MjViewerCpp keeps internal pointers to mjModel and mjData,
which are wrapped inside MjModel and MjData, respectively.
This technically allows model and data to be modified
while the viewer keeps a pointer to them (their wrapped pointers).
Undefined behavior should not occur, however caution is advised as this is a violation
of the Rust’s borrowing rules.
Implementations§
Source§impl<M: Deref<Target = MjModel> + Clone> MjViewerCpp<M>
impl<M: Deref<Target = MjModel> + Clone> MjViewerCpp<M>
pub fn running(&self) -> bool
pub fn user_scn_mut(&mut self) -> &mut MjvScene<M>
Sourcepub fn launch_passive(model: M, data: &MjData<M>, max_user_geom: usize) -> Self
pub fn launch_passive(model: M, data: &MjData<M>, max_user_geom: usize) -> Self
Launches a wrapper around MuJoCo’s C++ viewer. The max_user_geom parameter
defines how much space will be allocated for additional, user-defined visual-only geoms.
It can thus be set to 0 if no additional geoms will be drawn by the user.
Unlike the Rust-native viewer (crate::viewer::MjViewer), this also accepts a data parameter.
Additionally, this just returns a MjViewerCpp instance directly, without result
as the initialization may fail internally in C++ anyway, which we have no way of checking.
§Safety
See MjViewerCpp’s note.
Sourcepub fn __raw(&self) -> *mut mujoco_Simulate
pub fn __raw(&self) -> *mut mujoco_Simulate
Returns the underlying C++ binding object of the viewer.
Trait Implementations§
impl<M: Deref<Target = MjModel> + Clone> Send for MjViewerCpp<M>
impl<M: Deref<Target = MjModel> + Clone> Sync for MjViewerCpp<M>
Auto Trait Implementations§
impl<M> Freeze for MjViewerCpp<M>
impl<M> RefUnwindSafe for MjViewerCpp<M>where
M: RefUnwindSafe,
impl<M> Unpin for MjViewerCpp<M>
impl<M> UnwindSafe for MjViewerCpp<M>where
M: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.