bevy/crates/bevy_math/src
Joona Aalto 9bad607df9
Implement meshing for Capsule2d (#11639)
# Objective

The `Capsule2d` primitive was added in #11585. It should support meshing
like the other 2D primitives.

## Solution

Implement meshing for `Capsule2d`.

It doesn't currently support "rings" like Bevy's `Capsule` shape (not
`Capsule3d`), but it does support resolution to control the number of
vertices used for one hemicircle. The total vertex count is two times
the resolution; if we allowed setting the full vertex count, odd numbers
would lead to uneven vertex counts for the top and bottom hemicircles
and produce potentially unwanted results.

The capsule looks like this (with UV visualization and wireframe) using
resolutions of 16, 8, and 3:

![Resolution
16](https://github.com/bevyengine/bevy/assets/57632562/feae22de-bdc5-438a-861f-848284b67a52)
![Resolution
8](https://github.com/bevyengine/bevy/assets/57632562/e95aab8e-793f-45ac-8a74-8be39f7626dd)
![Resolution of
3](https://github.com/bevyengine/bevy/assets/57632562/bcf01d23-1d8b-4cdb-966a-c9022a07c287)

The `2d_shapes` example now includes the capsule, so we also get one
more color of the rainbow 🌈

![New 2D shapes
example](https://github.com/bevyengine/bevy/assets/57632562/1c45b5f5-d26a-4e8c-8e8a-e106ab14d46e)
2024-02-03 18:03:43 +00:00
..
bounding Rename RayTest to RayCast (#11635) 2024-02-02 15:01:04 +00:00
primitives Implement meshing for Capsule2d (#11639) 2024-02-03 18:03:43 +00:00
rects Replace or document ignored doctests (#11040) 2024-01-01 16:50:56 +00:00
affine3.rs Automatic batching/instancing of draw commands (#9685) 2023-09-21 22:12:34 +00:00
aspect_ratio.rs Introduce AspectRatio struct (#10368) 2023-12-17 02:01:26 +00:00
cubic_splines.rs Remove Default impl for CubicCurve (#11335) 2024-01-14 04:40:37 +00:00
lib.rs Add geometric primitives to bevy_math::prelude (#11432) 2024-01-20 20:15:38 +00:00
ray.rs Split Ray into Ray2d and Ray3d and simplify plane construction (#10856) 2023-12-06 14:09:04 +00:00