bevy/crates/bevy_reflect/src
Joona Aalto a9f061e909
Add Capsule2d primitive (#11585)
# 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](https://en.wikipedia.org/wiki/Stadium_(geometry))), but
those might be less obvious to game devs. For reference, Godot has
[`CapsuleShape2D`](https://docs.godotengine.org/en/stable/classes/class_capsuleshape2d.html).
I can rename it if others think the geometrically correct name is better
though.

---

## Changelog

- Renamed `Capsule` to `Capsule3d`
- Added `Capsule2d` with `Bounded2d` implemented

---------

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
2024-01-29 17:52:04 +00:00
..
enums Remove unnecessary path prefixes (#10749) 2023-11-28 23:43:40 +00:00
impls Add Capsule2d primitive (#11585) 2024-01-29 17:52:04 +00:00
path Fix some nightly warnings (#9672) 2023-09-02 18:35:06 +00:00
serde Replace or document ignored doctests (#11040) 2024-01-01 16:50:56 +00:00
array.rs Reorder impl to be the same as the trait (#11076) 2023-12-24 17:43:55 +00:00
fields.rs reflect: TypePath part 2 (#8768) 2023-10-09 19:33:03 +00:00
from_reflect.rs reflect: TypePath part 2 (#8768) 2023-10-09 19:33:03 +00:00
lib.rs bevy_reflect: Type parameter bounds (#9046) 2024-01-28 16:24:03 +00:00
list.rs Remove unnecessary path prefixes (#10749) 2023-11-28 23:43:40 +00:00
map.rs Reorder impl to be the same as the trait (#11076) 2023-12-24 17:43:55 +00:00
reflect.rs delete methods deprecated in 0.12 (#10693) 2023-11-24 16:15:47 +00:00
std_traits.rs fix nightly clippy warnings (#6395) 2022-10-28 21:03:01 +00:00
struct_trait.rs Reorder impl to be the same as the trait (#11076) 2023-12-24 17:43:55 +00:00
tuple_struct.rs Reorder impl to be the same as the trait (#11076) 2023-12-24 17:43:55 +00:00
tuple.rs Reorder impl to be the same as the trait (#11076) 2023-12-24 17:43:55 +00:00
type_info.rs Remove unnecessary path prefixes (#10749) 2023-11-28 23:43:40 +00:00
type_path.rs Replace or document ignored doctests (#11040) 2024-01-01 16:50:56 +00:00
type_registry.rs Enable the unsafe_op_in_unsafe_fn lint (#11591) 2024-01-28 23:18:11 +00:00
utility.rs Removed once_cell (#10079) 2023-10-12 10:20:07 +00:00