Skip to content

Commit

Permalink
WIP: fix entity rect
Browse files Browse the repository at this point in the history
  • Loading branch information
grtlr committed Nov 19, 2024
1 parent f900aa8 commit d05e266
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions crates/viewer/re_space_view_graph/src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,17 @@ impl SpaceViewClass for GraphSpaceView {

let (new_world_bounds, response) = viewer.canvas(ui, |mut scene| {
for (entity, graph) in &graphs {
// We use the following to keep track of the bounding box over nodes in an entity.
let mut entity_rect = egui::Rect::NOTHING;

// Draw explicit nodes.
for node in graph.nodes_explicit() {
let pos = layout
.get(&node.index)
.unwrap_or(egui::Rect::ZERO); // TODO(grtlr): sometimes there just isn't any data.
// .expect("explicit node should be in layout");
let response = scene.explicit_node(pos.min, node);
entity_rect = entity_rect.union(response.rect);
layout.update(&node.index, response.rect);
}

Expand All @@ -182,6 +186,7 @@ impl SpaceViewClass for GraphSpaceView {
.unwrap_or(egui::Rect::ZERO); // TODO(grtlr): sometimes there just isn't any data.
// .expect("implicit node should be in layout");
let response = scene.implicit_node(current.min, node);
entity_rect = entity_rect.union(response.rect);
layout.update(&node.index, response.rect);
}

Expand All @@ -197,9 +202,8 @@ impl SpaceViewClass for GraphSpaceView {
}

// Draw entity rect.
let rect = layout.bounding_rect();
if rect.is_positive() {
let response = scene.entity(entity, rect, &query.highlights);
if entity_rect.is_positive() {
let response = scene.entity(entity, entity_rect, &query.highlights);

let instance_path = InstancePath::entity_all((*entity).clone());
ctx.select_hovered_on_click(
Expand Down

0 comments on commit d05e266

Please sign in to comment.