Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Direction3dA and move direction types out of primitives #12018

Merged
merged 8 commits into from
Feb 26, 2024

Conversation

Jondolf
Copy link
Contributor

@Jondolf Jondolf commented Feb 20, 2024

Objective

Split up from #12017, add an aligned version of Direction3d for SIMD, and move direction types out of primitives.

Solution

Add Direction3dA and move direction types into a new direction module.


Migration Guide

The Direction2d, Direction3d, and InvalidDirectionError types have been moved out of bevy::math::primitives.

Before:

use bevy::math::primitives::Direction3d;

After:

use bevy::math::Direction3d;

@Jondolf Jondolf added C-Feature A new feature, making something new possible A-Math Fundamental domain-agnostic mathematical operations labels Feb 20, 2024
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add the changed path to a Migration Guide section please?

@alice-i-cecile alice-i-cecile added the M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide label Feb 21, 2024
Copy link
Contributor

It looks like your PR is a breaking change, but you didn't provide a migration guide.

Could you add some context on what users should update when this change get released in a new version of Bevy?
It will be used to help writing the migration guide for the version. Putting it after a ## Migration Guide will help it get automatically picked up by our tooling.

@Jondolf
Copy link
Contributor Author

Jondolf commented Feb 21, 2024

Done 👍

Copy link
Contributor

@IQuick143 IQuick143 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't noticed any mistakes, I think this is ready to merge.

crates/bevy_math/src/bounding/bounded2d/primitive_impls.rs Outdated Show resolved Hide resolved

// Make sure the result is normalized.
// This can fail for non-unit quaternions.
debug_assert!(rotated.is_normalized());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be good to provide an assertion message?
Probably not a blocker, I think it's already pretty clear.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it'd be good to have a message since I've seen this confuse some people already. Probably in a follow-up though; I didn't want to make any changes to the direction types in this PR since that's not the focus here

}
}

impl std::ops::Neg for Direction2d {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direction2d should also implement Mul<f32> -> Vec2.
Although we can do that in another PR (I think we should do a PR that adds Add<DirectionNd> -> VecN as well, but that's beyond this PR.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that add implementation makes much sense honestly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it does as an escape hatch from APIs that return a Direction even when the user wants to do vector arithmetic (like Transforms). The current solution is usually a bunch of Derefs, but I've heard feedback that they make the syntax uglier. (But I understand the controversy on this API.)

@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Feb 26, 2024
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Feb 26, 2024
Merged via the queue into bevyengine:main with commit 9bd6cc0 Feb 26, 2024
24 checks passed
msvbg pushed a commit to msvbg/bevy that referenced this pull request Feb 26, 2024
…engine#12018)

# Objective

Split up from bevyengine#12017, add an aligned version of `Direction3d` for SIMD,
and move direction types out of `primitives`.

## Solution

Add `Direction3dA` and move direction types into a new `direction`
module.

---

## Migration Guide

The `Direction2d`, `Direction3d`, and `InvalidDirectionError` types have
been moved out of `bevy::math::primitives`.

Before:

```rust
use bevy::math::primitives::Direction3d;
```

After:

```rust
use bevy::math::Direction3d;
```

---------

Co-authored-by: Alice Cecile <[email protected]>
msvbg pushed a commit to msvbg/bevy that referenced this pull request Feb 26, 2024
…engine#12018)

# Objective

Split up from bevyengine#12017, add an aligned version of `Direction3d` for SIMD,
and move direction types out of `primitives`.

## Solution

Add `Direction3dA` and move direction types into a new `direction`
module.

---

## Migration Guide

The `Direction2d`, `Direction3d`, and `InvalidDirectionError` types have
been moved out of `bevy::math::primitives`.

Before:

```rust
use bevy::math::primitives::Direction3d;
```

After:

```rust
use bevy::math::Direction3d;
```

---------

Co-authored-by: Alice Cecile <[email protected]>
@Jondolf Jondolf deleted the simd-direction-3d branch February 27, 2024 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Math Fundamental domain-agnostic mathematical operations C-Feature A new feature, making something new possible M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants