Skip to content

Commit 28e08f6

Browse files
committed
Add vector constants.
1 parent 2766a4f commit 28e08f6

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

crates/processing_pyo3/src/math.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,11 @@ macro_rules! impl_py_vec {
504504
}
505505

506506
impl_py_vec!(PyVec2, "Vec2", 2, [(x, set_x, 0), (y, set_y, 1)], Vec2, extra {
507+
#[classattr] #[allow(non_snake_case)] fn ZERO() -> Self { Self(Vec2::ZERO) }
508+
#[classattr] #[allow(non_snake_case)] fn ONE() -> Self { Self(Vec2::ONE) }
509+
#[classattr] #[allow(non_snake_case)] fn X() -> Self { Self(Vec2::X) }
510+
#[classattr] #[allow(non_snake_case)] fn Y() -> Self { Self(Vec2::Y) }
511+
507512
fn angle(&self) -> f32 {
508513
self.0.y.atan2(self.0.x)
509514
}
@@ -543,6 +548,12 @@ impl_py_vec!(PyVec2, "Vec2", 2, [(x, set_x, 0), (y, set_y, 1)], Vec2, extra {
543548
});
544549

545550
impl_py_vec!(PyVec3, "Vec3", 3, [(x, set_x, 0), (y, set_y, 1), (z, set_z, 2)], Vec3, extra {
551+
#[classattr] #[allow(non_snake_case)] fn ZERO() -> Self { Self(Vec3::ZERO) }
552+
#[classattr] #[allow(non_snake_case)] fn ONE() -> Self { Self(Vec3::ONE) }
553+
#[classattr] #[allow(non_snake_case)] fn X() -> Self { Self(Vec3::X) }
554+
#[classattr] #[allow(non_snake_case)] fn Y() -> Self { Self(Vec3::Y) }
555+
#[classattr] #[allow(non_snake_case)] fn Z() -> Self { Self(Vec3::Z) }
556+
546557
fn cross(&self, other: &Self) -> Self {
547558
Self(self.0.cross(other.0))
548559
}
@@ -570,6 +581,13 @@ impl_py_vec!(
570581
[(x, set_x, 0), (y, set_y, 1), (z, set_z, 2), (w, set_w, 3)],
571582
Vec4,
572583
extra {
584+
#[classattr] #[allow(non_snake_case)] fn ZERO() -> Self { Self(Vec4::ZERO) }
585+
#[classattr] #[allow(non_snake_case)] fn ONE() -> Self { Self(Vec4::ONE) }
586+
#[classattr] #[allow(non_snake_case)] fn X() -> Self { Self(Vec4::X) }
587+
#[classattr] #[allow(non_snake_case)] fn Y() -> Self { Self(Vec4::Y) }
588+
#[classattr] #[allow(non_snake_case)] fn Z() -> Self { Self(Vec4::Z) }
589+
#[classattr] #[allow(non_snake_case)] fn W() -> Self { Self(Vec4::W) }
590+
573591
fn truncate(&self) -> PyVec3 {
574592
PyVec3(self.0.truncate())
575593
}

0 commit comments

Comments
 (0)