Allow inverted near far for inverted depth fp32 (#509)

* removed assertion for inverted near far

* added extra assertion

* adding checks for ratio too small or far and near plane too close to each other

* using comparing macro

* PR feedback
This commit is contained in:
Marco Giordano 2020-06-24 15:45:20 +01:00 committed by GitHub
parent 2c7ee50ef4
commit c96cd57efc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -117,10 +117,11 @@ impl<S: BaseFloat> From<PerspectiveFov<S>> for Matrix4<S> {
"The vertical field of view cannot be greater than a half turn, found: {:?}",
persp.fovy
);
assert!(
persp.aspect > S::zero(),
"The aspect ratio cannot be below zero, found: {:?}",
persp.aspect
abs_diff_ne!(persp.aspect.abs(), S::zero()),
"The absolute aspect ratio cannot be zero, found: {:?}",
persp.aspect.abs()
);
assert!(
persp.near > S::zero(),
@ -133,8 +134,8 @@ impl<S: BaseFloat> From<PerspectiveFov<S>> for Matrix4<S> {
persp.far
);
assert!(
persp.far > persp.near,
"The far plane cannot be closer than the near plane, found: far: {:?}, near: {:?}",
abs_diff_ne!(persp.far, persp.near),
"The far plane and near plane are too close, found: far: {:?}, near: {:?}",
persp.far,
persp.near
);