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

Generate new constants for 2D View Coordinates #6178

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace rerun.components;
// TODO(#3384)
/*
enum ViewDir: byte {
Unused = 0,
Up = 1,
Down = 2,
Right = 3,
Expand All @@ -29,6 +30,7 @@ enum ViewDir: byte {
/// down, and the Z axis points forward.
///
/// The following constants are used to represent the different directions:
/// * Unused = 0
/// * Up = 1
/// * Down = 2
/// * Right = 3
Expand Down
8 changes: 8 additions & 0 deletions crates/re_types/src/archetypes/view_coordinates_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ impl ViewCoordinates {
define_coordinates!("X=Right, Y=Back, Z=Down", RBD => (Right, Back, Down));
define_coordinates!("X=Back, Y=Down, Z=Right", BDR => (Back, Down, Right));
define_coordinates!("X=Back, Y=Right, Z=Down", BRD => (Back, Right, Down));
define_coordinates!("X=Up, Y=Left, Z=Unused", UL => (Up, Left, Unused));
define_coordinates!("X=Left, Y=Up, Z=Unused", LU => (Left, Up, Unused));
define_coordinates!("X=Up, Y=Right, Z=Unused", UR => (Up, Right, Unused));
define_coordinates!("X=Right, Y=Up, Z=Unused", RU => (Right, Up, Unused));
define_coordinates!("X=Down, Y=Left, Z=Unused", DL => (Down, Left, Unused));
define_coordinates!("X=Left, Y=Down, Z=Unused", LD => (Left, Down, Unused));
define_coordinates!("X=Down, Y=Right, Z=Unused", DR => (Down, Right, Unused));
define_coordinates!("X=Right, Y=Down, Z=Unused", RD => (Right, Down, Unused));
define_coordinates!("X=Up, Y=Right, Z=Forward", RIGHT_HAND_X_UP => (Up, Right, Forward));
define_coordinates!("X=Down, Y=Right, Z=Back", RIGHT_HAND_X_DOWN => (Down, Right, Back));
define_coordinates!("X=Right, Y=Up, Z=Back", RIGHT_HAND_Y_UP => (Right, Up, Back));
Expand Down
1 change: 1 addition & 0 deletions crates/re_types/src/components/view_coordinates.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 18 additions & 8 deletions crates/re_types/src/components/view_coordinates_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ impl ViewCoordinates {
pub fn sanity_check(&self) -> Result<(), String> {
let mut dims = [false; 3];
for dir in self.0 {
let dim = match ViewDir::try_from(dir)? {
ViewDir::Up | ViewDir::Down => 0,
ViewDir::Right | ViewDir::Left => 1,
ViewDir::Forward | ViewDir::Back => 2,
};
dims[dim] = true;
if let Some(dim) = match ViewDir::try_from(dir)? {
ViewDir::Up | ViewDir::Down => Some(0),
ViewDir::Right | ViewDir::Left => Some(1),
ViewDir::Forward | ViewDir::Back => Some(2),
ViewDir::Unused => None,
} {
dims[dim] = true;
}
}
if dims == [true; 3] {
Ok(())
Expand Down Expand Up @@ -139,7 +141,7 @@ impl ViewCoordinates {
Some(ViewDir::Forward) => [0.0, 0.0, 1.0],
// TODO(jleibs): Is there a better value to return here?
// this means the ViewCoordinates aren't valid.
None => [0.0, 0.0, 0.0],
_ => [0.0, 0.0, 0.0],
}
}

Expand Down Expand Up @@ -175,7 +177,7 @@ impl ViewCoordinates {
Some(ViewDir::Forward) => [0.0, 0.0, -1.0],
// TODO(jleibs): Is there a better value to return here?
// this means the ViewCoordinates aren't valid.
None => [0.0, 0.0, 0.0],
_ => [0.0, 0.0, 0.0],
}
}

Expand Down Expand Up @@ -319,6 +321,14 @@ impl ViewCoordinates {
define_coordinates!("X=Right, Y=Back, Z=Down", RBD => (Right, Back, Down));
define_coordinates!("X=Back, Y=Down, Z=Right", BDR => (Back, Down, Right));
define_coordinates!("X=Back, Y=Right, Z=Down", BRD => (Back, Right, Down));
define_coordinates!("X=Up, Y=Left, Z=Unused", UL => (Up, Left, Unused));
define_coordinates!("X=Left, Y=Up, Z=Unused", LU => (Left, Up, Unused));
define_coordinates!("X=Up, Y=Right, Z=Unused", UR => (Up, Right, Unused));
define_coordinates!("X=Right, Y=Up, Z=Unused", RU => (Right, Up, Unused));
define_coordinates!("X=Down, Y=Left, Z=Unused", DL => (Down, Left, Unused));
define_coordinates!("X=Left, Y=Down, Z=Unused", LD => (Left, Down, Unused));
define_coordinates!("X=Down, Y=Right, Z=Unused", DR => (Down, Right, Unused));
define_coordinates!("X=Right, Y=Down, Z=Unused", RD => (Right, Down, Unused));
define_coordinates!("X=Up, Y=Right, Z=Forward", RIGHT_HAND_X_UP => (Up, Right, Forward));
define_coordinates!("X=Down, Y=Right, Z=Back", RIGHT_HAND_X_DOWN => (Down, Right, Back));
define_coordinates!("X=Right, Y=Up, Z=Back", RIGHT_HAND_Y_UP => (Right, Up, Back));
Expand Down
4 changes: 4 additions & 0 deletions crates/re_types/src/view_coordinates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/// The six cardinal directions for 3D view-space and image-space.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ViewDir {
Unused = 0,
Up = 1,
Down = 2,
Right = 3,
Expand All @@ -17,6 +18,7 @@ impl TryFrom<u8> for ViewDir {
#[inline]
fn try_from(i: u8) -> Result<Self, String> {
match i {
0 => Ok(Self::Unused),
1 => Ok(Self::Up),
2 => Ok(Self::Down),
3 => Ok(Self::Right),
Expand Down Expand Up @@ -61,6 +63,7 @@ impl ViewDir {
#[inline]
pub fn short(&self) -> &'static str {
match self {
Self::Unused => "",
Self::Up => "U",
Self::Down => "D",
Self::Right => "R",
Expand All @@ -74,6 +77,7 @@ impl ViewDir {
#[inline]
pub fn long(&self) -> &'static str {
match self {
Self::Unused => "Unused",
Self::Up => "Up",
Self::Down => "Down",
Self::Right => "Right",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions rerun_cpp/src/rerun/archetypes/view_coordinates.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions rerun_cpp/src/rerun/archetypes/view_coordinates_ext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,30 @@ namespace rerun {
/// X=Back, Y=Right, Z=Down
RERUN_SDK_EXPORT static const rerun::archetypes::ViewCoordinates BRD;

/// X=Up, Y=Left, Z=Unused
RERUN_SDK_EXPORT static const rerun::archetypes::ViewCoordinates UL;

/// X=Left, Y=Up, Z=Unused
RERUN_SDK_EXPORT static const rerun::archetypes::ViewCoordinates LU;

/// X=Up, Y=Right, Z=Unused
RERUN_SDK_EXPORT static const rerun::archetypes::ViewCoordinates UR;

/// X=Right, Y=Up, Z=Unused
RERUN_SDK_EXPORT static const rerun::archetypes::ViewCoordinates RU;

/// X=Down, Y=Left, Z=Unused
RERUN_SDK_EXPORT static const rerun::archetypes::ViewCoordinates DL;

/// X=Left, Y=Down, Z=Unused
RERUN_SDK_EXPORT static const rerun::archetypes::ViewCoordinates LD;

/// X=Down, Y=Right, Z=Unused
RERUN_SDK_EXPORT static const rerun::archetypes::ViewCoordinates DR;

/// X=Right, Y=Down, Z=Unused
RERUN_SDK_EXPORT static const rerun::archetypes::ViewCoordinates RD;

/// X=Up, Y=Right, Z=Forward
RERUN_SDK_EXPORT static const rerun::archetypes::ViewCoordinates RIGHT_HAND_X_UP;

Expand Down Expand Up @@ -308,6 +332,22 @@ namespace rerun {
ViewCoordinates(rerun::components::ViewCoordinates::BDR);
const ViewCoordinates ViewCoordinates::BRD =
ViewCoordinates(rerun::components::ViewCoordinates::BRD);
const ViewCoordinates ViewCoordinates::UL =
ViewCoordinates(rerun::components::ViewCoordinates::UL);
const ViewCoordinates ViewCoordinates::LU =
ViewCoordinates(rerun::components::ViewCoordinates::LU);
const ViewCoordinates ViewCoordinates::UR =
ViewCoordinates(rerun::components::ViewCoordinates::UR);
const ViewCoordinates ViewCoordinates::RU =
ViewCoordinates(rerun::components::ViewCoordinates::RU);
const ViewCoordinates ViewCoordinates::DL =
ViewCoordinates(rerun::components::ViewCoordinates::DL);
const ViewCoordinates ViewCoordinates::LD =
ViewCoordinates(rerun::components::ViewCoordinates::LD);
const ViewCoordinates ViewCoordinates::DR =
ViewCoordinates(rerun::components::ViewCoordinates::DR);
const ViewCoordinates ViewCoordinates::RD =
ViewCoordinates(rerun::components::ViewCoordinates::RD);
const ViewCoordinates ViewCoordinates::RIGHT_HAND_X_UP =
ViewCoordinates(rerun::components::ViewCoordinates::RIGHT_HAND_X_UP);
const ViewCoordinates ViewCoordinates::RIGHT_HAND_X_DOWN =
Expand Down
26 changes: 26 additions & 0 deletions rerun_cpp/src/rerun/components/view_coordinates.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 57 additions & 0 deletions rerun_cpp/src/rerun/components/view_coordinates_ext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace rerun {
// <CODEGEN_COPY_TO_HEADER>

enum ViewDir : uint8_t {
Unused = 0,
Up = 1,
Down = 2,
Right = 3,
Expand Down Expand Up @@ -181,6 +182,30 @@ namespace rerun {
/// X=Back, Y=Right, Z=Down
RERUN_SDK_EXPORT static const rerun::components::ViewCoordinates BRD;

/// X=Up, Y=Left, Z=Unused
RERUN_SDK_EXPORT static const rerun::components::ViewCoordinates UL;

/// X=Left, Y=Up, Z=Unused
RERUN_SDK_EXPORT static const rerun::components::ViewCoordinates LU;

/// X=Up, Y=Right, Z=Unused
RERUN_SDK_EXPORT static const rerun::components::ViewCoordinates UR;

/// X=Right, Y=Up, Z=Unused
RERUN_SDK_EXPORT static const rerun::components::ViewCoordinates RU;

/// X=Down, Y=Left, Z=Unused
RERUN_SDK_EXPORT static const rerun::components::ViewCoordinates DL;

/// X=Left, Y=Down, Z=Unused
RERUN_SDK_EXPORT static const rerun::components::ViewCoordinates LD;

/// X=Down, Y=Right, Z=Unused
RERUN_SDK_EXPORT static const rerun::components::ViewCoordinates DR;

/// X=Right, Y=Down, Z=Unused
RERUN_SDK_EXPORT static const rerun::components::ViewCoordinates RD;

/// X=Up, Y=Right, Z=Forward
RERUN_SDK_EXPORT static const rerun::components::ViewCoordinates RIGHT_HAND_X_UP;

Expand Down Expand Up @@ -416,6 +441,38 @@ namespace rerun {
rerun::components::ViewCoordinates::Back, rerun::components::ViewCoordinates::Right,
rerun::components::ViewCoordinates::Down
);
const ViewCoordinates ViewCoordinates::UL = ViewCoordinates(
rerun::components::ViewCoordinates::Up, rerun::components::ViewCoordinates::Left,
rerun::components::ViewCoordinates::Unused
);
const ViewCoordinates ViewCoordinates::LU = ViewCoordinates(
rerun::components::ViewCoordinates::Left, rerun::components::ViewCoordinates::Up,
rerun::components::ViewCoordinates::Unused
);
const ViewCoordinates ViewCoordinates::UR = ViewCoordinates(
rerun::components::ViewCoordinates::Up, rerun::components::ViewCoordinates::Right,
rerun::components::ViewCoordinates::Unused
);
const ViewCoordinates ViewCoordinates::RU = ViewCoordinates(
rerun::components::ViewCoordinates::Right, rerun::components::ViewCoordinates::Up,
rerun::components::ViewCoordinates::Unused
);
const ViewCoordinates ViewCoordinates::DL = ViewCoordinates(
rerun::components::ViewCoordinates::Down, rerun::components::ViewCoordinates::Left,
rerun::components::ViewCoordinates::Unused
);
const ViewCoordinates ViewCoordinates::LD = ViewCoordinates(
rerun::components::ViewCoordinates::Left, rerun::components::ViewCoordinates::Down,
rerun::components::ViewCoordinates::Unused
);
const ViewCoordinates ViewCoordinates::DR = ViewCoordinates(
rerun::components::ViewCoordinates::Down, rerun::components::ViewCoordinates::Right,
rerun::components::ViewCoordinates::Unused
);
const ViewCoordinates ViewCoordinates::RD = ViewCoordinates(
rerun::components::ViewCoordinates::Right, rerun::components::ViewCoordinates::Down,
rerun::components::ViewCoordinates::Unused
);
const ViewCoordinates ViewCoordinates::RIGHT_HAND_X_UP = ViewCoordinates(
rerun::components::ViewCoordinates::Up, rerun::components::ViewCoordinates::Right,
rerun::components::ViewCoordinates::Forward
Expand Down
16 changes: 16 additions & 0 deletions rerun_py/rerun_sdk/rerun/archetypes/view_coordinates_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ class ViewCoordinatesExt:
RBD: ViewCoordinates = None # type: ignore[assignment]
BDR: ViewCoordinates = None # type: ignore[assignment]
BRD: ViewCoordinates = None # type: ignore[assignment]
UL: ViewCoordinates = None # type: ignore[assignment]
LU: ViewCoordinates = None # type: ignore[assignment]
UR: ViewCoordinates = None # type: ignore[assignment]
RU: ViewCoordinates = None # type: ignore[assignment]
DL: ViewCoordinates = None # type: ignore[assignment]
LD: ViewCoordinates = None # type: ignore[assignment]
DR: ViewCoordinates = None # type: ignore[assignment]
RD: ViewCoordinates = None # type: ignore[assignment]
RIGHT_HAND_X_UP: ViewCoordinates = None # type: ignore[assignment]
RIGHT_HAND_X_DOWN: ViewCoordinates = None # type: ignore[assignment]
RIGHT_HAND_Y_UP: ViewCoordinates = None # type: ignore[assignment]
Expand Down Expand Up @@ -128,6 +136,14 @@ def deferred_patch_class(cls: Any) -> None:
cls.RBD = Component.RBD
cls.BDR = Component.BDR
cls.BRD = Component.BRD
cls.UL = Component.UL
cls.LU = Component.LU
cls.UR = Component.UR
cls.RU = Component.RU
cls.DL = Component.DL
cls.LD = Component.LD
cls.DR = Component.DR
cls.RD = Component.RD
cls.RIGHT_HAND_X_UP = Component.RIGHT_HAND_X_UP
cls.RIGHT_HAND_X_DOWN = Component.RIGHT_HAND_X_DOWN
cls.RIGHT_HAND_Y_UP = Component.RIGHT_HAND_Y_UP
Expand Down
1 change: 1 addition & 0 deletions rerun_py/rerun_sdk/rerun/components/view_coordinates.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading