Fix nalgebra-glm tests.

This commit is contained in:
Sébastien Crozet 2021-08-08 13:05:13 +02:00
parent 85074398d0
commit 6165ac8dbf
3 changed files with 6 additions and 7 deletions

View File

@ -507,7 +507,7 @@ pub fn sign<T: Number, const D: usize>(x: &TVec<T, D>) -> TVec<T, D> {
///
/// This is useful in cases where you would want a threshold function with a smooth transition.
/// This is equivalent to: `let result = clamp((x - edge0) / (edge1 - edge0), 0, 1); return t * t * (3 - 2 * t);` Results are undefined if `edge0 >= edge1`.
pub fn smoothstep<T: Number>(edge0: T, edge1: T, x: T) -> T {
pub fn smoothstep<T: RealNumber>(edge0: T, edge1: T, x: T) -> T {
let _3 = T::from_subset(&3.0f64);
let _2 = T::from_subset(&2.0f64);
let t = na::clamp((x - edge0) / (edge1 - edge0), T::zero(), T::one());

View File

@ -1,5 +1,6 @@
use crate::aliases::{TMat3, TMat4, TVec2, TVec3};
use crate::traits::Number;
use crate::RealNumber;
/// Build planar projection matrix along normal axis and right-multiply it to `m`.
pub fn proj2d<T: Number>(m: &TMat3<T>, normal: &TVec2<T>) -> TMat3<T> {
@ -26,7 +27,7 @@ pub fn proj<T: Number>(m: &TMat4<T>, normal: &TVec3<T>) -> TMat4<T> {
}
/// Builds a reflection matrix and right-multiply it to `m`.
pub fn reflect2d<T: Number>(m: &TMat3<T>, normal: &TVec2<T>) -> TMat3<T> {
pub fn reflect2d<T: RealNumber>(m: &TMat3<T>, normal: &TVec2<T>) -> TMat3<T> {
let mut res = TMat3::identity();
{
@ -38,7 +39,7 @@ pub fn reflect2d<T: Number>(m: &TMat3<T>, normal: &TVec2<T>) -> TMat3<T> {
}
/// Builds a reflection matrix, and right-multiply it to `m`.
pub fn reflect<T: Number>(m: &TMat4<T>, normal: &TVec3<T>) -> TMat4<T> {
pub fn reflect<T: RealNumber>(m: &TMat4<T>, normal: &TVec3<T>) -> TMat4<T> {
let mut res = TMat4::identity();
{

View File

@ -2,7 +2,7 @@ use approx::AbsDiffEq;
use num::{Bounded, Signed};
use na::Scalar;
use simba::scalar::{ClosedAdd, ClosedMul, ClosedSub, RealField, SupersetOf};
use simba::scalar::{ClosedAdd, ClosedMul, ClosedSub, RealField};
use std::cmp::PartialOrd;
/// A number that can either be an integer or a float.
@ -16,7 +16,6 @@ pub trait Number:
+ AbsDiffEq<Epsilon = Self>
+ Signed
+ Bounded
+ SupersetOf<f64>
{
}
@ -29,8 +28,7 @@ impl<
+ ClosedMul
+ AbsDiffEq<Epsilon = Self>
+ Signed
+ Bounded
+ SupersetOf<f64>,
+ Bounded,
> Number for T
{
}