mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
style: Avoid getting zero normalized vector of rotate3d for animations.
If we have a rotate axis whose length is extremely large, we will get an infinite value, and its normalized vector is a zero vector, instead of an unit vector, i.e. (x/inf, y/inf, z/inf) == (0, 0, 0). The solution is: we scale the vector, so the length becomes a finite value, and we could get a valid unit vector. Therefore, we use a different normalization method, robust_normalize(). Bug: 1467277 Reviewed-by: hiro
This commit is contained in:
parent
0c0ffef1a5
commit
3a0c8fc760
1 changed files with 1 additions and 1 deletions
|
@ -569,7 +569,7 @@ pub fn get_normalized_vector_and_angle<T: Zero>(
|
|||
// rotation to not be applied, so we use identity matrix (i.e. rotate3d(0, 0, 1, 0)).
|
||||
(0., 0., 1., T::zero())
|
||||
} else {
|
||||
let vector = vector.normalize();
|
||||
let vector = vector.robust_normalize();
|
||||
(vector.x, vector.y, vector.z, angle)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue