bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Add `Capsule2d` primitive

Open Jondolf opened this issue 5 months ago • 2 comments

Objective

Currently, the Capsule primitive is technically dimension-agnostic in that it implements both Primitive2d and Primitive3d. This seems good on paper, but it can often be useful to have separate 2D and 3D versions of primitives.

For example, one might want a two-dimensional capsule mesh. We can't really implement both 2D and 3D meshing for the same type using the upcoming Meshable trait (see #11431). We also currently don't implement Bounded2d for Capsule, see https://github.com/bevyengine/bevy/pull/11336#issuecomment-1890797788.

Having 2D and 3D separate at a type level is more explicit, and also more consistent with the existing primitives, as there are no other types that implement both Primitive2d and Primitive3d at the same time.

Solution

Rename Capsule to Capsule3d and add Capsule2d. Capsule2d implements Bounded2d.

For now, I went for Capsule2d for the sake of consistency and clarity. Mathematically the more accurate term would be Stadium or Pill (see Wikipedia), but those might be less obvious to game devs. For reference, Godot has CapsuleShape2D. I can rename it if others think the geometrically correct name is better though.


Changelog

  • Renamed Capsule to Capsule3d
  • Added Capsule2d with Bounded2d implemented

Jondolf avatar Jan 28 '24 20:01 Jondolf

It looks like your PR is a breaking change, but you didn't provide a migration guide.

Could you add some context on what users should update when this change get released in a new version of Bevy? It will be used to help writing the migration guide for the version. Putting it after a ## Migration Guide will help it get automatically picked up by our tooling.

github-actions[bot] avatar Jan 28 '24 20:01 github-actions[bot]

Much prefer Capsule2D: the more geometrically correct terms are much less intuitive. If users complain we can add doc aliases.

Edit: oh you're way ahead of me. Figures :p You have a great eye for details like this.

alice-i-cecile avatar Jan 28 '24 20:01 alice-i-cecile

@jondolf a couple of issues following the merge; let me know when you have it fixed up.

alice-i-cecile avatar Jan 29 '24 16:01 alice-i-cecile

Should be fixed @alice-i-cecile

Jondolf avatar Jan 29 '24 17:01 Jondolf