-
Notifications
You must be signed in to change notification settings - Fork 66
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
Primitive Shapes #12
Primitive Shapes #12
Conversation
Can there be fixed point versions of these primitives for deterministic collision purposes? |
Did you mean a proposal for 2d and 3d geometric primitives? :) |
Although orthogonal to the representation of these geometric primitives, I presume it would be logical to include mesh generation support to all of these. As such, would it be preferred to distinguish between a geometric primitive and a mesh generator, or keep them together? That is to say either this: let bounding = bevy_geom::D3::Sphere;
// _and_
let mesh: Mesh = bevy_render::shape::Sphere::default().into(); Or let primitive = bevy_geom::D3::Sphere;
// optionally, if necessary
let mesh = primitive.make_mesh(); In my opinion, I believe that giving Note that |
Definitely agree. To keep the attached PRs small, I'll probably split this up:
Nice catch, I always forget about that with "2d" and "3d" 🙄. |
This should be feasible; we'd want to pair it with a change to the Transform system to support this too though. I'm genuinely unsure about how we should best split the alternative coordinate representations overall though. It could be done with generics, basic code duplication, feature flags, and external crate... |
I was about to say the same thing. I'm not sure I know what the best approach would be here. Some options in order of implementation difficulty:
|
I think this is the way to go; the scope is large, it cuts across quite a few domains and it deserves its own motivation. |
Is this the relevant issue from the main bevy repo? bevyengine/bevy#1680 |
I recently had a use case for drawing points/single pixels. Should this be considered a special case of... several things? But perhaps having a separate type (in both |
I think a separate type for points is better: the semantics are different, and the optimizations are very different. I'm also of the opinion that it's a valid geometric primitive too: it's used in a lot of different places in modelling and you can approximate stuff quickly by treating them as points. |
Co-authored-by: bjorn3 <[email protected]>
Co-authored-by: Alice Cecile <[email protected]>
Co-authored-by: Alice Cecile <[email protected]>
Co-authored-by: Alice Cecile <[email protected]>
Remove angle as a component
Merging 'bounding and collision' with 'where are the transforms'
Co-authored-by: Alice Cecile <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy with this RFC as it currently stands: I think it sets out a nice foundation to build on. There are small details to work out, such as what exactly the Meshable
trait should look like or the exact optimal representation for each of the shapes, but we can figure those out as we build and benchmark.
We're already starting to reimplement similar tools within the engine: I'd like to move forward with a unified design ASAP to avoid having to deduplicate later.
A few comments:
The problem I've encountered trying to implement my shapes library, at least following this RFC design (with many Maybe this doesn't need to be answered now! It can be subject to new RFCs. I don't think the "abstract" shapes proposed in the RFC are controversial at all, I like all the propositions everyone made here. Going from abstract shape to concrete mesh or line collection can be discussed in a new RFC. I'd even suggest that the way to handle contributions of new shapes should be discussed in some RFC. |
Removing torus as a primitive shape
@alice-i-cecile with so much churn on this RFC, I'd like to update my implementation attempt, and we can collect concrete feedback there. I have some thoughts on further modifications to the RFC, but at this point it's been reviewed so many times I don't think further review will be helpful unless we have an implementation to look at. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great addition.
Here is my stupid simple shapes library https://github.com/nicopap/bevy-cool-shapes/blob/main/bevy_cool_shapes/src/lib.rs . I use it to show outline gizmos on screen like here https://github.com/nicopap/bevy-cool-shapes/tree/main/bevy_cool_shapes_render |
Here's my thoughts:
Methods that would be valuable to me, and probably others:
A lot of interesting operations on shapes can be reduced to checking for intersections. |
# Objective Bevy users often want to create circles and other simple shapes. All the machinery is in place to accomplish this, and there are external crates that help. But when writing code for e.g. a new bevy example, it's not really possible to draw a circle without bringing in a new asset, writing a bunch of scary looking mesh code, or adding a dependency. In particular, this PR was inspired by this interaction in another PR: #3721 (comment) ## Solution This PR adds `shape::RegularPolygon` and `shape::Circle` (which is just a `RegularPolygon` that defaults to a large number of sides) ## Discussion There's a lot of ongoing discussion about shapes in <bevyengine/rfcs#12> and at least one other lingering shape PR (although it seems incomplete). That RFC currently includes `RegularPolygon` and `Circle` shapes, so I don't think that having working mesh generation code in the engine for those shapes would add much burden to an author of an implementation. But if we'd prefer not to add additional shapes until after that's sorted out, I'm happy to close this for now. ## Alternatives for users For any users stumbling on this issue, here are some plugins that will help if you need more shapes. https://github.com/Nilirad/bevy_prototype_lyon https://github.com/johanhelsing/bevy_smud https://github.com/Weasy666/bevy_svg https://github.com/redpandamonium/bevy_more_shapes https://github.com/ForesightMiningSoftwareCorporation/bevy_polyline
# Objective Bevy users often want to create circles and other simple shapes. All the machinery is in place to accomplish this, and there are external crates that help. But when writing code for e.g. a new bevy example, it's not really possible to draw a circle without bringing in a new asset, writing a bunch of scary looking mesh code, or adding a dependency. In particular, this PR was inspired by this interaction in another PR: bevyengine#3721 (comment) ## Solution This PR adds `shape::RegularPolygon` and `shape::Circle` (which is just a `RegularPolygon` that defaults to a large number of sides) ## Discussion There's a lot of ongoing discussion about shapes in <bevyengine/rfcs#12> and at least one other lingering shape PR (although it seems incomplete). That RFC currently includes `RegularPolygon` and `Circle` shapes, so I don't think that having working mesh generation code in the engine for those shapes would add much burden to an author of an implementation. But if we'd prefer not to add additional shapes until after that's sorted out, I'm happy to close this for now. ## Alternatives for users For any users stumbling on this issue, here are some plugins that will help if you need more shapes. https://github.com/Nilirad/bevy_prototype_lyon https://github.com/johanhelsing/bevy_smud https://github.com/Weasy666/bevy_svg https://github.com/redpandamonium/bevy_more_shapes https://github.com/ForesightMiningSoftwareCorporation/bevy_polyline
# Objective Bevy users often want to create circles and other simple shapes. All the machinery is in place to accomplish this, and there are external crates that help. But when writing code for e.g. a new bevy example, it's not really possible to draw a circle without bringing in a new asset, writing a bunch of scary looking mesh code, or adding a dependency. In particular, this PR was inspired by this interaction in another PR: bevyengine#3721 (comment) ## Solution This PR adds `shape::RegularPolygon` and `shape::Circle` (which is just a `RegularPolygon` that defaults to a large number of sides) ## Discussion There's a lot of ongoing discussion about shapes in <bevyengine/rfcs#12> and at least one other lingering shape PR (although it seems incomplete). That RFC currently includes `RegularPolygon` and `Circle` shapes, so I don't think that having working mesh generation code in the engine for those shapes would add much burden to an author of an implementation. But if we'd prefer not to add additional shapes until after that's sorted out, I'm happy to close this for now. ## Alternatives for users For any users stumbling on this issue, here are some plugins that will help if you need more shapes. https://github.com/Nilirad/bevy_prototype_lyon https://github.com/johanhelsing/bevy_smud https://github.com/Weasy666/bevy_svg https://github.com/redpandamonium/bevy_more_shapes https://github.com/ForesightMiningSoftwareCorporation/bevy_polyline
Co-authored-by: TimJentzsch <[email protected]>
This RFC is all but merged at this point, with multiple ongoing PRs implementing parts of it already in flight and all of the open discussions have been resolved. @cart does this still need further review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is indeed in a good spot. Thanks to everyone for the reviews and iteration!
Maybe the |
# Objective Bevy users often want to create circles and other simple shapes. All the machinery is in place to accomplish this, and there are external crates that help. But when writing code for e.g. a new bevy example, it's not really possible to draw a circle without bringing in a new asset, writing a bunch of scary looking mesh code, or adding a dependency. In particular, this PR was inspired by this interaction in another PR: bevyengine#3721 (comment) ## Solution This PR adds `shape::RegularPolygon` and `shape::Circle` (which is just a `RegularPolygon` that defaults to a large number of sides) ## Discussion There's a lot of ongoing discussion about shapes in <bevyengine/rfcs#12> and at least one other lingering shape PR (although it seems incomplete). That RFC currently includes `RegularPolygon` and `Circle` shapes, so I don't think that having working mesh generation code in the engine for those shapes would add much burden to an author of an implementation. But if we'd prefer not to add additional shapes until after that's sorted out, I'm happy to close this for now. ## Alternatives for users For any users stumbling on this issue, here are some plugins that will help if you need more shapes. https://github.com/Nilirad/bevy_prototype_lyon https://github.com/johanhelsing/bevy_smud https://github.com/Weasy666/bevy_svg https://github.com/redpandamonium/bevy_more_shapes https://github.com/ForesightMiningSoftwareCorporation/bevy_polyline
What is "Plane2d"? As far as I'm aware, 2d world has only 1 plane (the world itself). I feel like it should be either renamed, or removed completely in favor of |
RENDERED
A proposal for 2d and 3d geometric primitives as lightweight interoperability types.