Consider f64 epsilon for add_weighted portions.

This patch also degrade assert! to debug_assert! since crash reports don't show
us useful information so far (no assertion messages at all).
This commit is contained in:
Hiroyuki Ikezoe 2017-07-11 08:42:27 +09:00
parent 4b91014b14
commit 0d43281fad

View file

@ -2272,9 +2272,11 @@ impl Animatable for MatrixDecomposed3D {
/// https://drafts.csswg.org/css-transforms/#interpolation-of-decomposed-3d-matrix-values /// https://drafts.csswg.org/css-transforms/#interpolation-of-decomposed-3d-matrix-values
fn add_weighted(&self, other: &Self, self_portion: f64, other_portion: f64) fn add_weighted(&self, other: &Self, self_portion: f64, other_portion: f64)
-> Result<Self, ()> { -> Result<Self, ()> {
assert!(self_portion + other_portion == 1.0f64 || use std::f64;
other_portion == 1.0f64,
"add_weighted should only be used for interpolating or accumulating transforms"); debug_assert!((self_portion + other_portion - 1.0f64).abs() <= f64::EPSILON ||
other_portion == 1.0f64,
"add_weighted should only be used for interpolating or accumulating transforms");
let mut sum = *self; let mut sum = *self;