Skip to content

Commit

Permalink
Set MSRV to 1.51
Browse files Browse the repository at this point in the history
Reason: --features on a workspace level is not supported before.
Further complicating CI scripts, while we already have Rust 1.57, is questionable.

Also removes the custom-built clamp(), which was introduced as f32::clamp() in Rust 1.50.
  • Loading branch information
Bromeon committed Dec 21, 2021
1 parent 6149c54 commit 9a4eb81
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 21 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/full-ci.yml
Expand Up @@ -105,7 +105,7 @@ jobs:
- rust: { toolchain: 'nightly' }
testflags: '-- --skip ui_tests'
- os: { id: ubuntu-latest, name: linux }
rust: { toolchain: '1.48', postfix: ' (msrv 1.48)' }
rust: { toolchain: '1.51', postfix: ' (msrv 1.51)' }
testflags: '-- --skip ui_tests'
runs-on: ${{ matrix.os.id }}
steps:
Expand Down Expand Up @@ -233,17 +233,21 @@ jobs:
fail-fast: false # cancel all jobs as soon as one fails?
matrix:
include:
# Latest Godot with different Rust versions
- rust: stable
godot: "3.4.1"
postfix: ''
- rust: nightly
godot: "3.4.1"
postfix: ' (nightly)'
- rust: '1.48'
- rust: '1.51'
godot: "3.4.1"
postfix: ' (msrv 1.48)'
postfix: ' (msrv 1.51)'

# Test with older engine version
# Note: headless versions of Godot <= 3.3 may crash with a bug, see feature description in lib.rs
- rust: stable
godot: "3.2"
godot: "3.3.1"
postfix: ''
build_args: '--features custom-godot'

Expand Down
18 changes: 1 addition & 17 deletions gdnative-core/src/core_types/geom/transform2d.rs
@@ -1,21 +1,5 @@
use crate::core_types::Vector2;

/// Clamp method for f32.
/// NOTE: This method was copied as-is from std. This was done to avoid compatibility issues
/// with newer rustc versions and should be removed in favor of f32::clamp once that is stable.
#[inline]
fn clamp(num: f32, min: f32, max: f32) -> f32 {
assert!(min <= max);
let mut x = num;
if x < min {
x = min;
}
if x > max {
x = max;
}
x
}

/// Affine 2D transform (2x3 matrix).
///
/// Represents transformations such as translation, rotation, or scaling.
Expand Down Expand Up @@ -228,7 +212,7 @@ impl Transform2D {
// slerp rotation
let v1 = Vector2::new(f32::cos(r1), f32::sin(r1));
let v2 = Vector2::new(f32::cos(r2), f32::sin(r2));
let dot = clamp(v1.dot(v2), -1.0, 1.0);
let dot = v1.dot(v2).clamp(-1.0, 1.0);

let v = if dot > 0.9995 {
//linearly interpolate to avoid numerical precision issues
Expand Down

0 comments on commit 9a4eb81

Please sign in to comment.