use re_log_types::EntityPath;
use re_renderer::{renderer::TexturedRect, QueueableDrawData};
use re_types::components::DepthMeter;
use re_viewer_context::{ImageInfo, SpaceViewSystemExecutionError};
#[derive(Clone)]
pub enum PickableRectSourceData {
Image {
image: ImageInfo,
depth_meter: Option<DepthMeter>,
},
Video,
ErrorPlaceholder,
}
pub struct PickableTexturedRect {
pub ent_path: EntityPath,
pub textured_rect: TexturedRect,
pub source_data: PickableRectSourceData,
}
impl PickableTexturedRect {
pub fn resolution(&self) -> [u32; 2] {
self.textured_rect.colormapped_texture.width_height()
}
pub fn to_draw_data(
render_ctx: &re_renderer::RenderContext,
rects: &[Self],
) -> Result<QueueableDrawData, SpaceViewSystemExecutionError> {
let rectangles = rects
.iter()
.map(|image| image.textured_rect.clone())
.collect::<Vec<_>>();
match re_renderer::renderer::RectangleDrawData::new(render_ctx, &rectangles) {
Ok(draw_data) => Ok(draw_data.into()),
Err(err) => Err(SpaceViewSystemExecutionError::DrawDataCreationError(
Box::new(err),
)),
}
}
}