bevy/examples/2d
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
..
2d_gizmos.rs Drawing Primitives with Gizmos (#11072) 2024-02-02 21:13:03 +00:00
2d_shapes.rs Implement meshing for Capsule2d (#11639) 2024-02-03 18:03:43 +00:00
2d_viewport_to_world.rs Add example for Camera::viewport_to_world (#7179) 2023-09-11 18:52:11 +00:00
bloom_2d.rs Fix missed explicit conversions in examples (#11261) 2024-01-09 00:44:24 +00:00
bounding_2d.rs Add example for bounding volumes and intersection tests (#11666) 2024-02-03 17:11:01 +00:00
custom_gltf_vertex_attribute.rs Reorder impl to be the same as the trait (#11076) 2023-12-24 17:43:55 +00:00
mesh2d.rs Fix missed explicit conversions in examples (#11261) 2024-01-09 00:44:24 +00:00
mesh2d_manual.rs RenderAssetPersistencePolicy → RenderAssetUsages (#11399) 2024-01-30 13:22:10 +00:00
mesh2d_vertex_color_texture.rs Fix missed explicit conversions in examples (#11261) 2024-01-09 00:44:24 +00:00
move_sprite.rs Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
pixel_grid_snap.rs Fix missed explicit conversions in examples (#11261) 2024-01-09 00:44:24 +00:00
rotation.rs Update winit dependency to 0.29 (#10702) 2023-12-21 07:40:47 +00:00
sprite.rs Update color and naming for consistency (#10367) 2023-11-04 02:09:23 +00:00
sprite_flipping.rs Update color and naming for consistency (#10367) 2023-11-04 02:09:23 +00:00
sprite_sheet.rs Texture Atlas rework (#5103) 2024-01-16 13:59:08 +00:00
sprite_slice.rs Sprite slicing and tiling (#10588) 2024-01-15 15:40:06 +00:00
sprite_tile.rs Sprite slicing and tiling (#10588) 2024-01-15 15:40:06 +00:00
text2d.rs Rename TextAlignment to JustifyText. (#10854) 2023-12-05 03:00:41 +00:00
texture_atlas.rs Allow TextureAtlasBuilder in AssetLoader (#11548) 2024-01-27 16:16:44 +00:00
transparency_2d.rs Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00