mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 12:43:34 +00:00
21b78b5990
# Objective Several of our APIs (namely gizmos and bounding) use isometries on current Bevy main. This is nicer than separate properties in a lot of cases, but users have still expressed usability concerns. One problem is that in a lot of cases, you only care about e.g. translation, so you end up with this: ```rust gizmos.cross_2d( Isometry2d::from_translation(Vec2::new(-160.0, 120.0)), 12.0, FUCHSIA, ); ``` The isometry adds quite a lot of length and verbosity, and isn't really that relevant since only the translation is important here. It would be nice if you could use the translation directly, and only supply an isometry if both translation and rotation are needed. This would make the following possible: ```rust gizmos.cross_2d(Vec2::new(-160.0, 120.0), 12.0, FUCHSIA); ``` removing a lot of verbosity. ## Solution Implement `From<Vec2>` and `From<Rot2>` for `Isometry2d`, and `From<Vec3>`, `From<Vec3A>`, and `From<Quat>` for `Isometry3d`. These are lossless conversions that fit the semantics of `From`. This makes the proposed API possible! The methods must now simply take an `impl Into<IsometryNd>`, and this works: ```rust gizmos.cross_2d(Vec2::new(-160.0, 120.0), 12.0, FUCHSIA); ``` |
||
---|---|---|
.. | ||
2d_shapes.rs | ||
2d_viewport_to_world.rs | ||
bloom_2d.rs | ||
bounding_2d.rs | ||
cpu_draw.rs | ||
custom_gltf_vertex_attribute.rs | ||
mesh2d.rs | ||
mesh2d_alpha_mode.rs | ||
mesh2d_arcs.rs | ||
mesh2d_manual.rs | ||
mesh2d_vertex_color_texture.rs | ||
move_sprite.rs | ||
pixel_grid_snap.rs | ||
rotation.rs | ||
sprite.rs | ||
sprite_animation.rs | ||
sprite_flipping.rs | ||
sprite_sheet.rs | ||
sprite_slice.rs | ||
sprite_tile.rs | ||
text2d.rs | ||
texture_atlas.rs | ||
transparency_2d.rs | ||
wireframe_2d.rs |