Skip to content

Commit

Permalink
Merge pull request #983 from fpdotmonkey/projection-compatibility
Browse files Browse the repository at this point in the history
Provide feature parity for `Projection` with Godot
  • Loading branch information
Bromeon authored Dec 18, 2024
2 parents c8ba45d + cbf9206 commit 3c56b3f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions godot-core/src/builtin/projection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ impl Projection {
/// added to the first and second values of the final column respectively.
///
/// _Godot equivalent: `Projection.jitter_offseted()`_
#[doc(alias = "jitter_offseted")]
#[must_use]
pub fn jitter_offset(&self, offset: Vector2) -> Self {
Self::from_cols(
Expand Down Expand Up @@ -502,6 +503,19 @@ impl Mul<Vector4> for Projection {
}
}

impl std::ops::Index<Vector4Axis> for Projection {
type Output = Vector4;

fn index(&self, index: Vector4Axis) -> &Self::Output {
match index {
Vector4Axis::X => &self.cols[0],
Vector4Axis::Y => &self.cols[1],
Vector4Axis::Z => &self.cols[2],
Vector4Axis::W => &self.cols[3],
}
}
}

impl ApproxEq for Projection {
fn approx_eq(&self, other: &Self) -> bool {
for i in 0..4 {
Expand Down

0 comments on commit 3c56b3f

Please sign in to comment.