Skip to content

Commit e7e6bbe

Browse files
committed
remove unused user data from picking processor
1 parent 76654ad commit e7e6bbe

6 files changed

Lines changed: 10 additions & 28 deletions

File tree

crates/viewer/re_renderer/src/draw_phases/picking_layer.rs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ use parking_lot::Mutex;
2929
use smallvec::smallvec;
3030

3131
/// GPU retrieved & processed picking data result.
32-
pub struct PickingResult<T: 'static + Send + Sync> {
33-
/// User data supplied on picking request.
34-
pub user_data: T,
35-
32+
pub struct PickingResult {
3633
/// Picking rect supplied on picking request.
3734
/// Describes the area of the picking layer that was read back.
3835
pub rect: RectInt,
@@ -55,7 +52,7 @@ pub struct PickingResult<T: 'static + Send + Sync> {
5552
world_from_cropped_projection: glam::Mat4,
5653
}
5754

58-
impl<T: 'static + Send + Sync> PickingResult<T> {
55+
impl PickingResult {
5956
/// Returns the picked world position.
6057
///
6158
/// Panics if the position is outside of the picking rect.
@@ -81,13 +78,10 @@ impl<T: 'static + Send + Sync> PickingResult<T> {
8178
}
8279
}
8380

84-
type ReadbackBeltUserData = Box<dyn std::any::Any + Send + Sync>;
85-
8681
/// Type used as user data on the gpu readback belt.
8782
struct ReadbackBeltMetadata {
8883
picking_rect: RectInt,
8984
world_from_cropped_projection: glam::Mat4,
90-
user_data: ReadbackBeltUserData,
9185

9286
depth_readback_workaround_in_use: bool,
9387
}
@@ -184,7 +178,6 @@ impl PickingLayerProcessor {
184178
frame_uniform_buffer_content: &FrameUniformBuffer,
185179
enable_picking_target_sampling: bool,
186180
readback_identifier: GpuReadbackIdentifier,
187-
readback_user_data: ReadbackBeltUserData,
188181
) -> Self {
189182
let mut picking_target_usage =
190183
wgpu::TextureUsages::RENDER_ATTACHMENT | wgpu::TextureUsages::COPY_SRC;
@@ -292,7 +285,6 @@ impl PickingLayerProcessor {
292285
readback_identifier,
293286
Box::new(ReadbackBeltMetadata {
294287
picking_rect,
295-
user_data: readback_user_data,
296288
world_from_cropped_projection: cropped_projection_from_world.inverse(),
297289
depth_readback_workaround_in_use: depth_readback_workaround.is_some(),
298290
}),
@@ -390,15 +382,15 @@ impl PickingLayerProcessor {
390382
Ok(())
391383
}
392384

393-
/// Returns the latest available picking result for a given identifier and user data type.
385+
/// Returns the latest available picking result for a given identifier.
394386
///
395387
/// Ready data that hasn't been retrieved for more than a frame will be discarded.
396388
///
397-
/// See also [`crate::view_builder::ViewBuilder::schedule_picking_rect`]
398-
pub fn readback_result<T: 'static + Send + Sync>(
389+
/// See also [`crate::view_builder::ViewPickingConfiguration`]
390+
pub fn readback_result(
399391
ctx: &RenderContext,
400392
identifier: GpuReadbackIdentifier,
401-
) -> Option<PickingResult<T>> {
393+
) -> Option<PickingResult> {
402394
ctx.gpu_readback_belt
403395
.lock()
404396
.readback_newest_available(identifier, |data, metadata: Box<ReadbackBeltMetadata>| {
@@ -447,7 +439,6 @@ impl PickingLayerProcessor {
447439
Some(PickingResult {
448440
picking_id_data,
449441
picking_depth_data,
450-
user_data: *metadata.user_data.downcast::<T>().ok()?,
451442
rect: metadata.picking_rect,
452443
world_from_cropped_projection: metadata.world_from_cropped_projection,
453444
})

crates/viewer/re_renderer/src/view_builder.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,6 @@ pub struct ViewPickingConfiguration {
266266
/// Identifier to be passed to the readback result.
267267
pub readback_identifier: GpuReadbackIdentifier,
268268

269-
/// User data to be passed to the readback result.
270-
pub readback_user_data: Box<dyn std::any::Any + Send + Sync>,
271-
272269
/// Whether to draw a debug view of the picking layer when compositing the final view.
273270
pub show_debug_view: bool,
274271
}
@@ -561,7 +558,6 @@ impl ViewBuilder {
561558
&frame_uniform_buffer_content,
562559
picking_config.show_debug_view,
563560
picking_config.readback_identifier,
564-
picking_config.readback_user_data,
565561
);
566562

567563
if picking_config.show_debug_view {

crates/viewer/re_renderer_examples/picking.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl framework::Example for Picking {
100100
pixels_per_point: f32,
101101
) -> anyhow::Result<Vec<framework::ViewDrawResult>> {
102102
if let Some(picking_result) =
103-
PickingLayerProcessor::readback_result::<()>(re_ctx, READBACK_IDENTIFIER)
103+
PickingLayerProcessor::readback_result(re_ctx, READBACK_IDENTIFIER)
104104
{
105105
// Grab the middle pixel. usually we'd want to do something clever that snaps the closest object of interest.
106106
let picked_id = picking_result.picked_id(picking_result.rect.extent / 2);
@@ -128,7 +128,6 @@ impl framework::Example for Picking {
128128
glam::uvec2(picking_rect_size, picking_rect_size),
129129
),
130130
readback_identifier: READBACK_IDENTIFIER,
131-
readback_user_data: Box::new(()),
132131
show_debug_view: false,
133132
};
134133

crates/viewer/re_view_map/src/map_view.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,6 @@ fn handle_picking_and_ui_interactions(
457457
glam::uvec2(picking_rect_size, picking_rect_size),
458458
),
459459
readback_identifier: picking_readback_identifier,
460-
readback_user_data: Box::new(()),
461460
show_debug_view: ctx.app_options().show_picking_debug_overlay,
462461
})
463462
} else {
@@ -584,10 +583,8 @@ fn picking_gpu(
584583
) -> Option<InstancePathHash> {
585584
re_tracing::profile_function!();
586585

587-
let gpu_picking_result = re_renderer::PickingLayerProcessor::readback_result::<()>(
588-
render_ctx,
589-
gpu_readback_identifier,
590-
);
586+
let gpu_picking_result =
587+
re_renderer::PickingLayerProcessor::readback_result(render_ctx, gpu_readback_identifier);
591588

592589
if let Some(gpu_picking_result) = gpu_picking_result {
593590
// TODO(ab, andreas): the block inside this particular branch is so reusable, it should probably live on re_renderer! (on picking result?)

crates/viewer/re_view_spatial/src/picking.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ fn picking_gpu(
194194
re_tracing::profile_function!();
195195

196196
let gpu_picking_result =
197-
PickingLayerProcessor::readback_result::<()>(render_ctx, gpu_readback_identifier);
197+
PickingLayerProcessor::readback_result(render_ctx, gpu_readback_identifier);
198198

199199
if let Some(gpu_picking_result) = gpu_picking_result {
200200
// First, figure out where on the rect the cursor is by now.

crates/viewer/re_view_spatial/src/picking_ui.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ pub fn picking(
5555
glam::uvec2(picking_rect_size, picking_rect_size),
5656
),
5757
readback_identifier: query.view_id.gpu_readback_id(),
58-
readback_user_data: Box::new(()),
5958
show_debug_view: ctx.app_options().show_picking_debug_overlay,
6059
};
6160

0 commit comments

Comments
 (0)