bevy/examples/ecs
Joona Aalto 21b78b5990
Implement From translation and rotation for isometries (#15733)
# 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);
```
2024-10-08 16:09:28 +00:00
..
change_detection.rs Track source location in change detection (#14034) 2024-07-30 12:02:38 +00:00
component_hooks.rs Simpler lint fixes: makes ci lints work but disables a lint for now (#15376) 2024-09-24 11:42:59 +00:00
custom_query_param.rs Simpler lint fixes: makes ci lints work but disables a lint for now (#15376) 2024-09-24 11:42:59 +00:00
custom_schedule.rs Simpler lint fixes: makes ci lints work but disables a lint for now (#15376) 2024-09-24 11:42:59 +00:00
dynamic.rs Rename init_component & friends (#15454) 2024-09-26 22:47:28 +00:00
ecs_guide.rs Add example enum Component usage to ecs_guide (#13777) 2024-06-25 12:57:11 +00:00
event.rs Created an EventMutator for when you want to mutate an event before reading (#13818) 2024-07-08 14:53:06 +00:00
fallible_params.rs Fix QuerySingle -> Single missed in example (#15667) 2024-10-05 22:24:03 +00:00
fixed_timestep.rs Unify FixedTime and Time while fixing several problems (#8964) 2023-10-16 01:57:55 +00:00
generic_system.rs Add insert_state to App. (#11043) 2023-12-21 14:09:24 +00:00
hierarchy.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
iter_combinations.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
nondeterministic_system_order.rs Fix non-functional nondeterministic_system_order example (#10719) 2023-11-25 21:13:35 +00:00
observer_propagation.rs Bubbling observers traversal should use query data (#15385) 2024-09-23 18:08:36 +00:00
observers.rs Implement From translation and rotation for isometries (#15733) 2024-10-08 16:09:28 +00:00
one_shot_systems.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
parallel_query.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
removal_detection.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
run_conditions.rs Simpler lint fixes: makes ci lints work but disables a lint for now (#15376) 2024-09-24 11:42:59 +00:00
send_and_receive_events.rs Simpler lint fixes: makes ci lints work but disables a lint for now (#15376) 2024-09-24 11:42:59 +00:00
startup_system.rs Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
system_closure.rs Allow tuples and single plugins in add_plugins, deprecate add_plugin (#8097) 2023-06-21 20:51:03 +00:00
system_param.rs Inverse missing_docs logic (#11676) 2024-02-03 21:40:55 +00:00
system_piping.rs Simpler lint fixes: makes ci lints work but disables a lint for now (#15376) 2024-09-24 11:42:59 +00:00
system_stepping.rs Remove stepping from default features (#12847) 2024-04-03 19:16:02 +00:00