Skip to content

Commit

Permalink
Provide feature parity for Projection with Godot
Browse files Browse the repository at this point in the history
The only missing feature was indexing, which I did in a type-safe
manner.

This was a part of the December 2024 Mini Hackathon.
  • Loading branch information
fpdotmonkey committed Dec 18, 2024
1 parent c8ba45d commit cbf9206
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 cbf9206

Please sign in to comment.