(self, viewport, screen_pos)
return selected_body_id, grab_world_pos
Shoots a ray from the specified viewport position into the scene.
Shoots a ray from the specified viewport position into the scene.
Shoots a ray from the specified viewport position into the scene .
def raycast(self, viewport, screen_pos):
    """Shoots a ray from the specified viewport position into the scene."""
    if not self.is_initialized:
      return -1, None
    viewport_pos = viewport.screen_to_inverse_viewport(screen_pos)
    grab_world_pos = np.empty(3, dtype=np.double)
    selected_geom_id_arr = np.intc([-1])
    selected_skin_id_arr = np.intc([-1])
    selected_body_id = mjlib.mjv_select(
        self._model.ptr,
        self._data.ptr,
        self._options.visualization.ptr,
        viewport.aspect_ratio,
        viewport_pos[0],
        viewport_pos[1],
        self._scene.ptr,
        grab_world_pos,
        selected_geom_id_arr,
        selected_skin_id_arr)
    del selected_geom_id_arr, selected_skin_id_arr  # Unused.
    if selected_body_id < 0:
      selected_body_id = _INVALID_BODY_INDEX
      grab_world_pos = None
    return selected_body_id, grab_world_pos
def raycast ( self , viewport , screen_pos ) : if not self . is_initialized : return - 1 , None viewport_pos = viewport . screen_to_inverse_viewport ( screen_pos ) grab_world_pos = np . empty ( 3 , dtype = np . double ) selected_geom_id_arr = np . intc ( [ - 1 ] ) selected_skin_id_arr = np . intc ( [ - 1 ] ) selected_body_id = mjlib . mjv_select ( self . _model . ptr , self . _data . ptr , self . _options . visualization . ptr , viewport . aspect_ratio , viewport_pos [ 0 ] , viewport_pos [ 1 ] , self . _scene . ptr , grab_world_pos , selected_geom_id_arr , selected_skin_id_arr ) del selected_geom_id_arr , selected_skin_id_arr # Unused. if selected_body_id < 0 : selected_body_id = _INVALID_BODY_INDEX grab_world_pos = None return selected_body_id , grab_world_pos