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 Squircle primitive #13652

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Conversation

lynn-lumen
Copy link
Contributor

Objective

Solution

  • Added a Squircle primitive to bevy_math. The chosen squircle is based on the superellipse.
  • Implemented gizmos for squircles
    • squircles use rectangles and rhombuses internally if the shapes are sufficiently similar.
    • The resolution of the squircle can be configured by calling .resolution() on the builder

Additional information

The gizmos implementation may seem overcomplicated, but the following images may clarify why an implementation like this is needed:
superellipses

  • The left squircles use samples that are equally spaced by angle.
  • The center squircles use samples interpolated between the left and right (this is the solution I ended up using)
  • The right squircles use samples that have equally spaced normal vectors, i.e. the normal vector rotates by the same amount between each sampled point.
  • All squircles have a resolution of 32

@alice-i-cecile alice-i-cecile added C-Feature A new feature, making something new possible A-UI Graphical user interfaces, styles, layouts, and widgets A-Math Fundamental domain-agnostic mathematical operations M-Needs-Release-Note Work that should be called out in the blog due to impact S-Needs-Review Needs reviewer attention (from anyone!) to move forward X-Contentious There are nontrivial implications that should be thought through D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes labels Jun 3, 2024
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

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

Docs are great, I quite like the code implementation, and I agree with your choice of gizmo drawing technique, cursed as it is.

My one concern centers around utility. This is a UI-centric addition, but there's no way to use this in UIs currently, and it's not clear how users would do so. Are there other game dev uses to consider? Should we merge this anyways and tackle adding rounded corner support using squircles in a follow-up?

@BD103 BD103 added A-Gizmos Visual editor and debug gizmos and removed A-UI Graphical user interfaces, styles, layouts, and widgets labels Jun 3, 2024
@lynn-lumen
Copy link
Contributor Author

Should we merge this anyways and tackle adding rounded corner support using squircles in a follow-up?

Yeah, I would prefer that to be in a follow up, since that would be a completely new solution touching at least one more crate

Co-authored-by: Alice Cecile <[email protected]>
@NthTensor NthTensor added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Aug 24, 2024
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Aug 26, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 26, 2024
@alice-i-cecile
Copy link
Member

@lynn-lumen looks like this needs some love with the recent changes on main.

@rparrett
Copy link
Contributor

rparrett commented Aug 27, 2024

Is there a variation of this type of shape that would have "symmetrical curvature" even when width and height are not equal?

To crudely illustrate: https://www.desmos.com/calculator/r4mzfslt8m

As-is, this seems less useful than it could be.

@alice-i-cecile alice-i-cecile removed the X-Contentious There are nontrivial implications that should be thought through label Aug 27, 2024
@alice-i-cecile alice-i-cecile added the X-Controversial There is active debate or serious implications around merging this PR label Aug 27, 2024
@alice-i-cecile
Copy link
Member

Bumping to controversial: I'm not actually sold on how useful this is. Maybe the UI designers know something I don't, but this doesn't seem to be a meaningful improvement over rounded corners.

@lynn-lumen
Copy link
Contributor Author

There seems to be an issue with access_kit_macos which prohibits building bevy. I have filed an issue #14956

@alice-i-cecile alice-i-cecile added S-Needs-SME Decision or review from an SME is required and removed S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it labels Sep 22, 2024
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-Feature A new feature, making something new possible D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes M-Needs-Release-Note Work that should be called out in the blog due to impact S-Needs-SME Decision or review from an SME is required X-Controversial There is active debate or serious implications around merging this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Squircle / Superellipse for UI / Gizmos / Mesh
5 participants