Repository: bevyengine/bevy
File: crates/bevy_sprite_render/src/tilemap_chunk/tile_orientation.rs (Rust)

Code before:
use core::fmt::Display;

use bevy_math::IVec2;
use bevy_reflect::{std_traits::ReflectDefault, Reflect};

/// The set of possible tile orientations.
/// These represent all possible results of mirroring the tile horizontally
/// and/or vertically, and/or rotation by 90 degree increments.
///
/// Rotation is measured counter-clockwise as elsewhere in Bevy.
///
/// The representation is a u8 value where the bits (from most significant to least
/// significant), represent:
///
/// - Bit 2: Mirroring the tile horizontally (left and right sides are swapped)
/// - Bit 1: Mirroring the tile vertically (top and bottom are swapped)
/// - Bit 0: Mirroring the tile diagonally (top-right and bottom-left corners are swapped)
///
/// The order in which the mirroring is performed matters - the tile is first mirrored
/// horizontally (if specified), then vertically, then finally diagonally.
///
/// Note that because different coordinate systems are used for UV mapping and Bevy
/// world coordinates, the code in each case is different (e.g. in UV maps, the y
/// component increases towards the bottom of the tile, in Bevy it increases towards the top).
///
/// The ordering of the enum starts from the default orientation (no rotation or mirroring),
/// then we have successive 90 degree counter-clockwise rotations. Then we have a tile
/// mirrored horizontally, and then the results of successive 90 degree counter-clockwise
/// rotations of the mirrored tile.
///
/// The enum values can be easily converted to the format used for tile indices in Tiled maps,
/// where bits 31, 30 and 29 correspond to bits 2, 1 and 0 of this enum's values.
/// So for a given enum value, we can just use `value << 29` to produce the bits required
/// in a Tiled index.
#[derive(Debug, Clone, Copy, Reflect, Default, PartialEq, Eq, Hash)]
#[reflect(Default, Clone, PartialEq, Hash)]
#[repr(u8)]
pub enum TileOrientation {
    #[default]
    Default = 0b000,
    Rotate90 = 0b011,
    Rotate180 = 0b110,
    Rotate270 = 0b101,
    MirrorH = 0b100,
    MirrorHRotate90 = 0b001,
    MirrorHRotate180 = 0b010,
    MirrorHRotate270 = 0b111,
}

Review comment (suggestion):
```suggestion
/// world coordinates, the ordering in which the mirroring is applied differs (e.g. in UV maps, the y
```

Just to be specific that the only thing that should be different is the ordering

Code after:
use core::fmt::Display;

use bevy_math::IVec2;
use bevy_reflect::{std_traits::ReflectDefault, Reflect};

/// The set of possible tile orientations.
/// These represent all possible results of mirroring the tile horizontally
/// and/or vertically, and/or rotation by 90 degree increments.
///
/// Rotation is measured counter-clockwise as elsewhere in Bevy.
///
/// The representation is a u8 value where the bits (from most significant to least
/// significant), represent:
///
/// - Bit 2: Mirroring the tile horizontally (left and right sides are swapped)
/// - Bit 1: Mirroring the tile vertically (top and bottom are swapped)
/// - Bit 0: Mirroring the tile diagonally (top-right and bottom-left corners are swapped)
///
/// The order in which the mirroring is performed matters - the tile is first mirrored
/// horizontally (if specified), then vertically, then finally diagonally, in the UV
/// coordinate system.
///
/// Note that different coordinate systems are used for UV mapping and Bevy world
/// coordinates (e.g. in UV maps, the y component increases towards the bottom of
/// the tile, in Bevy it increases towards the top). This means that the ordering
/// in which the mirroring is applied differs in different coordinate systems.
///
/// The ordering of the enum starts from the default orientation (no rotation or mirroring),
/// then we have successive 90 degree counter-clockwise rotations. Then we have a tile
/// mirrored horizontally, and then the results of successive 90 degree counter-clockwise
/// rotations of the mirrored tile.
///
/// The enum values can be easily converted to the format used for tile indices in [Tiled](https://www.mapeditor.org/) maps,
/// where bits 31, 30 and 29 correspond to bits 2, 1 and 0 of this enum's values.
/// So for a given enum value, we can just use `value << 29` to produce the bits required
/// in a Tiled index.
#[derive(Debug, Clone, Copy, Reflect, Default, PartialEq, Eq, Hash)]
#[reflect(Default, Clone, PartialEq, Hash)]
#[repr(u8)]
pub enum TileOrientation {
    #[default]
    Default = 0b000,
    Rotate90 = 0b011,
    Rotate180 = 0b110,
    Rotate270 = 0b101,
    MirrorH = 0b100,
    MirrorHRotate90 = 0b001,
    MirrorHRotate180 = 0b010,