-
-
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 ramp primitive #11790
Add ramp primitive #11790
Conversation
I like the ramp, but the cone should be in a separate PR. Meshing for cones isn't quite as trivial. From what I can see, the cone here uses duplicate vertices for the tip. This is problematic for a few reasons, but the most evident one is perhaps that it can produce visible creases. A previous PR used your approach and has some discussion on this: #10298 My original primitive meshing PR (#11007) has meshing for both cones and conical frusta. It uses the alternative approach of a single vertex for the tip with an "invalid" normal so that it doesn't contribute to the shading. From what I know, this is the only way we currently have for making a perfectly smooth cone mesh. The code for that is here: https://github.com/bevyengine/bevy/pull/11007/files#diff-e7b7f96e4d538ed02ad300fdb7a47d0c7d355ca437ee0c6c5f678e6de81001bb |
Oh wow, I didn't know normals could be used like that. I'll remove the |
Could ramp also be represented by a more general triangular prism? |
It could be, but I don't think it should be. The issue with that is that these shapes are preferably simple. If we would implement a general prism, we would probably want it to be a prism with a regular base (as in a regular n-gon). The ramp always has one 90° corner though and can as such not be such a prism. |
Was referring to https://docs.godotengine.org/en/stable/classes/class_prismmesh.html a ramp would basically be a prism with left_to_right set to 0.0, is just a thought, the problem with wedges is that they don't have to be parallel, and prism is a subclass, and ramps are a subclass of prisms |
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 adding this! I know this has changed a lot since the initial post, but bear with me here.
I do have some questions. First, why are we making a specific shape for triangular prisms instead of just extruding our 2d shapes? I feel that either we should do "general right prisms" or we should do "ramps", and this is sort of a weird middle-ground.
Second, I was confused by the example in 3d_shapes
. The base seems to be an irregular triangle, which I was not expecting from the code. Are we sure that's correct?
The current implementation allows for any kind of triangle as the base of the prism. I am not sure what the difference between a "general right prism" and a "ramp" would be though. However, assuming both are triangular prisms, both of them are possible with this implementation. Currently, both right-angled-triangles as well as any other triangle can be used as the base shape, which brings us closer to what other engines like Godot allow, but which is not what the original RFC is describing. I would personally be in favour of adding a ramp and maybe a wedge shape as described in #11786. This would probably be good, because most users will probably want to use
Yes, this is correct. The |
I was asking about right prisms not right triangle bases. As in a prism that is not oblique. |
Ok, after a bit of discussion with the author I'd like to suggest reverting this back to just plain-old-ramps. While I would like to see an arbitrary prism primitive, I find the For general prisms, it seems like it would be nicer to add the ability to extrude our (compact) 2d primitives into 3d primitives. Lets leave that for possible follow up. |
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.
Looks good to me.
Co-Authored-By: NiseVoid <NiseVoid@users.noreply.github.com>
Co-Authored-By: NiseVoid <NiseVoid@users.noreply.github.com> Co-Authored-By: Joona Aalto <jondolf.dev@gmail.com>
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 pretty content with this. I'm not sure on the direction the ramp should be facing, but that might just be preference.
It would be good to add the ramp gizmo to the math/render_primitives
example, but I'm fine leaving that to a follow-up.
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 really prefer the extrusion abstraction in #13270. Does this still need to exist with that in place? A ramp is just a triangular prism, right?
IMO we should close this out and add then add convenience methods to construct ramp-like extruded triangles, rather than extending the set of primitives. I'm not fully confident this would be adequate though: so please let me know if I've missed something.
Agreed. |
Objective
Solution
Ramp
tobevy_math
and implemented traits forRamp
.Changelog
Ramp
:Default
,Meshable
,impl_reflect!
,Bounded3d
and forGizmos
:impl GizmoPrimitive3d<Ramp> for Gizmos