Skip to content

Commit

Permalink
Pass in the arguments another way
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Mar 27, 2023
1 parent c60f9e7 commit 44cffaa
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 12 deletions.
3 changes: 2 additions & 1 deletion crates/re_renderer/examples/depth_cloud.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,10 @@ impl RenderDepthClouds {

let world_from_obj = glam::Mat4::from_scale(glam::Vec3::splat(*scale));

let size_boost_in_points_for_outlines = 2.5;
let depth_cloud_draw_data = DepthCloudDrawData::new(
re_ctx,
size_boost_in_points_for_outlines,
&[DepthCloud {
world_from_obj,
depth_camera_intrinsics: *intrinsics,
Expand All @@ -182,7 +184,6 @@ impl RenderDepthClouds {
depth_data: depth.data.clone(),
colormap: re_renderer::ColorMap::ColorMapTurbo,
outline_mask_id: Default::default(),
size_boost_in_points_for_outlines: 2.5,
}],
)
.unwrap();
Expand Down
9 changes: 2 additions & 7 deletions crates/re_renderer/src/renderer/depth_cloud.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ mod gpu_data {
depth_data,
colormap,
outline_mask_id,
size_boost_in_points_for_outlines: _,
} = depth_cloud;

let user_depth_from_texture_value = match depth_data {
Expand Down Expand Up @@ -167,9 +166,6 @@ pub struct DepthCloud {

/// Option outline mask id preference.
pub outline_mask_id: OutlineMaskPreference,

/// Boosts the size of the points by the given amount of ui-points for the purpose of drawing outlines.
pub size_boost_in_points_for_outlines: f32,
}

#[derive(Clone)]
Expand All @@ -191,6 +187,7 @@ impl DrawData for DepthCloudDrawData {
impl DepthCloudDrawData {
pub fn new(
ctx: &mut RenderContext,
size_boost_in_points_for_outlines: f32,
depth_clouds: &[DepthCloud],
) -> Result<Self, ResourceManagerError> {
crate::profile_function!();
Expand Down Expand Up @@ -288,9 +285,7 @@ impl DepthCloudDrawData {
ctx,
"PointCloudDrawData::DrawDataUniformBuffer_outline_mask".into(),
gpu_data::DrawDataUniformBuffer {
size_boost_in_points: depth_cloud
.size_boost_in_points_for_outlines
.into(),
size_boost_in_points: size_boost_in_points_for_outlines.into(),
end_padding: Default::default(),
},
),
Expand Down
1 change: 1 addition & 0 deletions crates/re_viewer/src/ui/view_spatial/scene/picking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ pub fn picking(
points,
meshes,
depth_clouds: _, // no picking for depth clouds yet
depth_cloud_size_boost_in_points_for_outlines: _,
any_outlines: _,
} = primitives;

Expand Down
7 changes: 6 additions & 1 deletion crates/re_viewer/src/ui/view_spatial/scene/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ pub struct SceneSpatialPrimitives {
pub points: PointCloudBuilder<InstancePathHash>,

pub meshes: Vec<MeshSource>,

pub depth_clouds: Vec<DepthCloud>,
pub depth_cloud_size_boost_in_points_for_outlines: f32,

pub any_outlines: bool,
}
Expand All @@ -36,7 +38,7 @@ const AXIS_COLOR_Y: Color32 = Color32::from_rgb(0, 240, 0);
const AXIS_COLOR_Z: Color32 = Color32::from_rgb(80, 80, 255);

const SIZE_BOOST_IN_POINTS_FOR_LINE_OUTLINES: f32 = 1.5;
pub const SIZE_BOOST_IN_POINTS_FOR_POINT_OUTLINES: f32 = 2.5;
const SIZE_BOOST_IN_POINTS_FOR_POINT_OUTLINES: f32 = 2.5;

impl SceneSpatialPrimitives {
pub fn new(re_ctx: &mut re_renderer::RenderContext) -> Self {
Expand All @@ -50,6 +52,7 @@ impl SceneSpatialPrimitives {
.size_boost_in_points_for_outlines(SIZE_BOOST_IN_POINTS_FOR_POINT_OUTLINES),
meshes: Default::default(),
depth_clouds: Default::default(),
depth_cloud_size_boost_in_points_for_outlines: SIZE_BOOST_IN_POINTS_FOR_POINT_OUTLINES,
any_outlines: false,
}
}
Expand All @@ -69,6 +72,7 @@ impl SceneSpatialPrimitives {
points,
meshes,
depth_clouds,
depth_cloud_size_boost_in_points_for_outlines: _,
any_outlines: _,
} = &self;

Expand All @@ -90,6 +94,7 @@ impl SceneSpatialPrimitives {
points,
meshes,
depth_clouds: _, // no bbox for depth clouds
depth_cloud_size_boost_in_points_for_outlines: _,
any_outlines: _,
} = self;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,6 @@ impl ImagesPart {
depth_data: data,
colormap,
outline_mask_id: entity_highlight.overall,
size_boost_in_points_for_outlines:
crate::ui::view_spatial::scene::primitives::SIZE_BOOST_IN_POINTS_FOR_POINT_OUTLINES,
});

Ok(())
Expand Down
9 changes: 8 additions & 1 deletion crates/re_viewer/src/ui/view_spatial/ui_renderer_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,14 @@ fn create_and_fill_view_builder(
view_builder.setup_view(render_ctx, target_config)?;

view_builder
.queue_draw(&DepthCloudDrawData::new(render_ctx, &primitives.depth_clouds).unwrap())
.queue_draw(
&DepthCloudDrawData::new(
render_ctx,
primitives.depth_cloud_size_boost_in_points_for_outlines,
&primitives.depth_clouds,
)
.unwrap(),
)
.queue_draw(&MeshDrawData::new(render_ctx, &primitives.mesh_instances()).unwrap())
.queue_draw(&primitives.line_strips.to_draw_data(render_ctx))
.queue_draw(&primitives.points.to_draw_data(render_ctx)?)
Expand Down

0 comments on commit 44cffaa

Please sign in to comment.