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

pick nits from example bounding_2d #12563

Merged
merged 2 commits into from
Mar 22, 2024

Conversation

awwsmm
Copy link
Contributor

@awwsmm awwsmm commented Mar 19, 2024

Objective

  • went through bounding_2d example with a fine-toothed comb and found two small issues

Solution

  • pulled "draw a small filled-in circle" logic into a function
  • removed impotent addition of aabb / circle origin (identically Vec2(0.0, 0.0))

Comment on lines +287 to +291
fn draw_filled_circle(gizmos: &mut Gizmos, position: Vec2, color: Srgba) {
for r in [1., 2., 3.] {
gizmos.circle_2d(position, r, color);
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously, this logic appeared in two places. I pulled it into a function with a name that explains what it's trying to do.

Comment on lines -353 to +359
aabb_cast.ray.ray.origin
+ *aabb_cast.ray.ray.direction * toi
+ aabb_cast.aabb.center(),
aabb_cast.ray.ray.origin + *aabb_cast.ray.ray.direction * toi,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

aabb_cast.aabb.center() is always Vec2(0.0, 0.0), and so adding it here has no effect on the position of the rendered rect_2d

Comment on lines -384 to +388
circle_cast.ray.ray.origin
+ *circle_cast.ray.ray.direction * toi
+ circle_cast.circle.center(),
circle_cast.ray.ray.origin + *circle_cast.ray.ray.direction * toi,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ditto for this circle_2d

@alice-i-cecile alice-i-cecile added C-Examples An addition or correction to our examples A-Gizmos Visual editor and debug gizmos A-Math Fundamental domain-agnostic mathematical operations labels Mar 19, 2024
@Jondolf Jondolf added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Mar 21, 2024
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Mar 21, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 21, 2024
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Mar 22, 2024
Merged via the queue into bevyengine:main with commit 70d8ce7 Mar 22, 2024
26 checks passed
@awwsmm awwsmm deleted the example-bounding_2d-nits branch March 22, 2024 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Gizmos Visual editor and debug gizmos A-Math Fundamental domain-agnostic mathematical operations C-Examples An addition or correction to our examples S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants