-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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 and impl Primitives #10580
Add and impl Primitives #10580
Conversation
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.
Thanks, looks very nice overall! I left some notes on consistency and docs, and also on frusta.
A viewing frustum would probably be more useful for rendering, feedback from others would be nice. ConicalFrustum
also feels somewhat niche, but I have no objection against including it.
@@ -127,6 +172,13 @@ pub struct Triangle2d { | |||
} | |||
impl Primitive2d for Triangle2d {} | |||
|
|||
impl Triangle2d { | |||
/// Create a new `Triangle2d` from a list of Vertices | |||
pub fn new(vertices: [Vec2; 3]) -> Self { |
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.
It'd be nice to have a method that takes points a
, b
and c
instead. Taking an array doesn't feel quite as intuitive in my opinion, although it's almost the same.
Not sure which one of them should be new
, but the other method could be either from_points
or from_array
based on what is chosen.
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 would prefer this to be the new, and not include from_array
at all.
/// A conical frustum can be created | ||
/// by slicing off a section of a cone. | ||
#[derive(Clone, Copy, Debug)] | ||
pub struct ConicalFrustum { |
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 also nice to have, but if we also want primitives to be used for rendering, a viewing frustum would be more useful. For rendering, it would be defined by an aspect-ratio, fov and the near and far planes, but maybe that's a bit too rendering-specific for primitives? More opinions on this would be useful.
If we add a viewing frustum though, it should probably be done in a separate PR since it'd touch on rendering code too and be a bit more controversial.
If we want to support different types of frusta, then perhaps a polygonal frustum with a regular polygon as a base could also be useful?
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.
@superdump also briefly touched on this here: #10466 (comment)
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.
Yep, we should split rendering frustra into a different PR.
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.
Rendering frustum most likely belongs in the bounding PR. Might be good to create some helper later to create a primitive shape you can render from the 6 plane representation (which is not exactly most convinient way to render them)
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.
New shapes look great! I left some guidance on the parameterization of them.
More constructors is helpful, but we shouldn't have trivial ones, aka those that simply duplicate public fields.
Consistency with other primitive docs Co-authored-by: Joona Aalto <[email protected]>
Clarify documentation of Cone Co-authored-by: Joona Aalto <[email protected]>
Clarify Torus documentation 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.
Thanks for your patience :) Only a couple more nits left!
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.
Remaining items:
new
constructorTriangle2d
that takes points a, b and c.- Same constructor, but for
Triangle3d
- Iterator-based constructor for
Polygon<N>
.
But maybe it should be added? |
Ah, got it. Let's do that in a different PR! |
Should I still have another constructor that takes a slice of 3 |
I believe not: #10580 (comment) |
Remaining Items should be completed 👍 |
Update Polyline constructor documentation Co-authored-by: Joona Aalto <[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.
Last comments, just a few small doc things
} | ||
} | ||
|
||
/// A cone primitive. |
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.
As @NiseVoid suggested (#10580 (comment)), maybe we should mention where the origin of the cone should be so that different integrations have consistent representations?
If the options are the base and apex (tip), the base is more intuitive for me personally. I view cones like Wikipedia's description:
a three-dimensional geometric shape that tapers smoothly from a flat base (frequently, though not necessarily, circular) to a point called the apex or vertex.
Co-authored-by: Joona Aalto <[email protected]>
Co-authored-by: Joona Aalto <[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.
LGTM, thanks for your patience! The cone origin thing (#10580 (comment)) would be nice to reach a consensus on, but it's not a blocker for me in terms of this PR.
# Add and implement constructors for Primitives - Adds more Primitive types and adds a constructor for almost all of them - Works towards finishing bevyengine#10572 ## Solution - Created new primitives - Torus - Conical Frustum - Cone - Ellipse - Implemented constructors (`Primitive::new`) for almost every single other primitive. --------- Co-authored-by: Joona Aalto <[email protected]> Co-authored-by: Alice Cecile <[email protected]>
Add and implement constructors for Primitives
Solution
Primitive::new
) for almost every single other primitive.