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

Provide feature parity for Projection with Godot #983

Merged
merged 1 commit into from
Dec 18, 2024
Merged
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
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
Loading