Skip to content

Conversation

@lizelive
Copy link
Contributor

Objective

  • Dir2 had them
  • Dir3 should have them

Solution

  • Describe the solution used to achieve the objective above.

Testing

  • unit test

Showcase

This section is optional. If this PR does not include a visual change or does not add a new feature, you can delete this section.

  • Help others understand the result of this PR by showcasing your awesome work!
  • If this PR adds a new feature or public API, consider adding a brief pseudo-code snippet of it in action
  • If this PR includes a visual change, consider adding a screenshot, GIF, or video
    • If you want, you could even include a before/after comparison!
  • If the Migration Guide adequately covers the changes, you can delete this section

While a showcase should aim to be brief and digestible, you can use a toggleable section to save space on longer showcases:

Click to view showcase
println!("My super cool code.");

Copy link
Contributor

@ickshonpe ickshonpe left a comment

Choose a reason for hiding this comment

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

I don't like the Dir2 -> Dir3 conversion very much. The const fns for CompassQuadrant seem fine though, I think they should probably be split off into their own PR.

Comment on lines +114 to 124

/// Get the dir2 representing this direction
pub const fn to_dir2(self) -> Dir2 {
match self {
CompassQuadrant::North => Dir2::NORTH,
CompassQuadrant::East => Dir2::EAST,
CompassQuadrant::South => Dir2::SOUTH,
CompassQuadrant::West => Dir2::WEST,
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

These seem fine and could be split off into a separate PR as less controversial.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed

CompassOctant::West => Dir2::WEST,
CompassOctant::NorthWest => Dir2::NORTH_WEST,
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Same with these.

Comment on lines +563 to +571
/// from a dir2 representing a compass direction
/// per bevy space standard, Y is the up direction
/// so returns (x, 0, y)
#[inline]
pub const fn from_compass_dir(compass: Dir2) -> Self {
let v = compass.as_vec2();
Dir3(Vec3::new(v.x, 0.0, v.y))
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't really like this, I think it's too context dependent for bevy_math. It's very natural to assume thatDir2(Vec2 { x, y }) maps to Dir3(Vec3 { x, y, z: 0. }). These conversions should be left to users to implement themselves imo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bevy has a coordinate system. +Y is up. This is defined and documented. And this is in line with the compass type.

@alice-i-cecile alice-i-cecile added C-Usability A targeted quality-of-life change that makes Bevy easier to use A-Math Fundamental domain-agnostic mathematical operations S-Needs-Review Needs reviewer attention (from anyone!) to move forward X-Contentious There are nontrivial implications that should be thought through S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Nov 16, 2025
}
}

impl<T: Into<Dir2>> From<T> for Dir3 {
Copy link
Contributor

@ickshonpe ickshonpe Nov 28, 2025

Choose a reason for hiding this comment

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

It's not the explicit from_compass_dir constructor that's the problem I guess, but this blanket From impl. From's behaviour is meant to be obvious, but there are multiple natural interpretations here, and users often won't check the docs for From.

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-Usability A targeted quality-of-life change that makes Bevy easier to use S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged X-Contentious There are nontrivial implications that should be thought through

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants