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

Add a bounding box gizmo #8468

Merged
merged 6 commits into from
Apr 24, 2023

Conversation

tim-blackbird
Copy link
Contributor

@tim-blackbird tim-blackbird commented Apr 22, 2023

Objective

Add a bounding box gizmo

Screenshot from 2023-04-22 23-49-40

Changes

  • Added the AabbGizmo component that will draw the Aabb component on that entity.
  • Added an option to draw all bounding boxes in a scene on the GizmoConfig resource.
  • Added TransformPoint trait to generalize over the point transformation methods on various transform types (e.g Transform and GlobalTransform).
  • Changed the Gizmos::cuboid method to accept an impl TransformPoint instead of separate translation, rotation, and scale.

@alice-i-cecile alice-i-cecile added C-Feature A new feature, making something new possible A-Rendering Drawing game state to the screen A-Gizmos Visual editor and debug gizmos labels Apr 22, 2023
@alice-i-cecile alice-i-cecile added this to the 0.11 milestone Apr 22, 2023
@IceSentry
Copy link
Contributor

Adding it to the scene_viewer is a great idea, but I think it would be nice as a standalone example too. Or maybe just use it in the gizmo example?

Copy link
Contributor

@nicopap nicopap left a comment

Choose a reason for hiding this comment

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

Yes please, this is very welcome. A future improvement could be to do the same with the Node struct.

@mockersf
Copy link
Member

the difference between a bounding box and a cuboid is not clear enough, why do we need both?

@tim-blackbird
Copy link
Contributor Author

tim-blackbird commented Apr 24, 2023

I've removed bounding_box and modified cuboid instead, and TransformPoint was moved to bevy_transform.

Copy link
Contributor

@nicopap nicopap left a comment

Choose a reason for hiding this comment

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

Widely useful, if this existed earlier it would have saved me a few headaches.

crates/bevy_gizmos/src/lib.rs Show resolved Hide resolved
@nicopap
Copy link
Contributor

nicopap commented Apr 24, 2023

I love the following function so much, I've definitively needed something similar in personal projects. Maybe it could be implemented as a From<Entity> for Color impl in a different PR.

fn color_from_entity(entity: Entity) -> Color {
let hue = entity.to_bits() as f32 * 100_000. % 360.;
Color::hsl(hue, 1., 0.5)
}

@alice-i-cecile alice-i-cecile 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 Apr 24, 2023
auto-merge was automatically disabled April 24, 2023 15:06

Head branch was pushed to by a user without write access

@alice-i-cecile alice-i-cecile added this pull request to the merge queue Apr 24, 2023
Merged via the queue into bevyengine:main with commit b5d24d8 Apr 24, 2023
@tim-blackbird tim-blackbird deleted the bounding-box-gizmo branch April 25, 2023 09:03
@nicopap nicopap mentioned this pull request Aug 9, 2023
57 tasks
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-Rendering Drawing game state to the screen C-Feature A new feature, making something new possible 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.

5 participants