Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure same intersection bounds are always used #218

Merged
merged 5 commits into from
Jun 27, 2024

Conversation

Hoodad
Copy link
Contributor

@Hoodad Hoodad commented Jun 25, 2024

Checklist

  • I have read the Contributor Guide
  • I have read and agree to the Code of Conduct
  • I have added a description of my changes and why I'd like them included in the section below

Description of Changes

This ensures the bounds for a frame_rect is always the same when checking for intersection in puffin_egui.

Also removed unnecessary call to response.hovered().

Related Issues

Fixes #217

@Hoodad Hoodad requested review from emilk and TimonPost as code owners June 25, 2024 14:06
@@ -689,7 +689,7 @@ impl ProfilerUi {
};

let frame_rect = Rect::from_min_max(
Pos2::new(x, rect.top()),
Pos2::new(x - 0.5 * frame_spacing, rect.top() + 0.5 * frame_spacing),
Pos2::new(x + frame_width, rect.bottom()),
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could maybe move the expand2 up to here, like:

Suggested change
);
)
.expand2(vec2(0.5 * frame_spacing, 0.0))

but inlining the expansion is probably fine too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean instead of doing the subtraction and addition on line 692?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right - my impression was that this inlined the equivalent of doing the .expand2 which was removed where checking if the mouse_pos is contained in the frame.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I can change that, I also noticed the addition is wrong as it adds to the Y component of the min position. So changing to .expand2 seems like a good solution 👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but on second glance maybe not - this now just expands the min position not the max position, so expand2 wouldn't be equivalent.

Copy link
Contributor Author

@Hoodad Hoodad Jun 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function not expanding max is what's wrong that I mentioned in my comment above, I'm fixing that as well.
Edit: It should expand both min and max. And when rendering the frame rect should be shrunken to not create a solid chunk of rects. (Something I also noticed now with correct expansion)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I realized afterwards that the bars were getting filled out visually if I tried using expand2 up-front and yeah the follow up to reduce the visual rect makes sense

Copy link
Contributor

@rib rib left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left a nit comment about maybe moving the previous expand2 up, but either way this looks good to me 👍

@Hoodad Hoodad requested a review from rib June 26, 2024 15:00
@Hoodad Hoodad changed the title This ensures that the same bounds are always used Ensure same intersection bounds are always used Jun 26, 2024
Copy link
Contributor

@rib rib left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me.

I tested with the self profiling and clicking the left/right pixels seems to work as expected now and the bars are still visually spaced like they were before.

@Hoodad Hoodad merged commit af98035 into main Jun 27, 2024
6 checks passed
@Hoodad Hoodad deleted the hoodad/always-use-the-same-intersection-test branch June 27, 2024 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot click the left or right most pixel of an frame_rect in puffin_egui
2 participants