mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
style: Move skew and rotation application to their own scope for clarity.
The skew resetting of temp I think fixes a bug in presence of skew in every direction, but again haven't double-checked. Bug: 1459403 Reviewed-by: hiro MozReview-Commit-ID: Bn93CoaG8Bu
This commit is contained in:
parent
66b8bd2829
commit
b199ca864a
1 changed files with 35 additions and 31 deletions
|
@ -2161,43 +2161,47 @@ impl From<MatrixDecomposed3D> for Matrix3D {
|
|||
% endfor
|
||||
|
||||
// Apply rotation
|
||||
let x = decomposed.quaternion.0;
|
||||
let y = decomposed.quaternion.1;
|
||||
let z = decomposed.quaternion.2;
|
||||
let w = decomposed.quaternion.3;
|
||||
{
|
||||
let x = decomposed.quaternion.0;
|
||||
let y = decomposed.quaternion.1;
|
||||
let z = decomposed.quaternion.2;
|
||||
let w = decomposed.quaternion.3;
|
||||
|
||||
// Construct a composite rotation matrix from the quaternion values
|
||||
// rotationMatrix is a identity 4x4 matrix initially
|
||||
let mut rotation_matrix = Matrix3D::identity();
|
||||
rotation_matrix.m11 = 1.0 - 2.0 * (y * y + z * z) as f32;
|
||||
rotation_matrix.m12 = 2.0 * (x * y + z * w) as f32;
|
||||
rotation_matrix.m13 = 2.0 * (x * z - y * w) as f32;
|
||||
rotation_matrix.m21 = 2.0 * (x * y - z * w) as f32;
|
||||
rotation_matrix.m22 = 1.0 - 2.0 * (x * x + z * z) as f32;
|
||||
rotation_matrix.m23 = 2.0 * (y * z + x * w) as f32;
|
||||
rotation_matrix.m31 = 2.0 * (x * z + y * w) as f32;
|
||||
rotation_matrix.m32 = 2.0 * (y * z - x * w) as f32;
|
||||
rotation_matrix.m33 = 1.0 - 2.0 * (x * x + y * y) as f32;
|
||||
// Construct a composite rotation matrix from the quaternion values
|
||||
// rotationMatrix is a identity 4x4 matrix initially
|
||||
let mut rotation_matrix = Matrix3D::identity();
|
||||
rotation_matrix.m11 = 1.0 - 2.0 * (y * y + z * z) as f32;
|
||||
rotation_matrix.m12 = 2.0 * (x * y + z * w) as f32;
|
||||
rotation_matrix.m13 = 2.0 * (x * z - y * w) as f32;
|
||||
rotation_matrix.m21 = 2.0 * (x * y - z * w) as f32;
|
||||
rotation_matrix.m22 = 1.0 - 2.0 * (x * x + z * z) as f32;
|
||||
rotation_matrix.m23 = 2.0 * (y * z + x * w) as f32;
|
||||
rotation_matrix.m31 = 2.0 * (x * z + y * w) as f32;
|
||||
rotation_matrix.m32 = 2.0 * (y * z - x * w) as f32;
|
||||
rotation_matrix.m33 = 1.0 - 2.0 * (x * x + y * y) as f32;
|
||||
|
||||
matrix = multiply(rotation_matrix, matrix);
|
||||
matrix = multiply(rotation_matrix, matrix);
|
||||
}
|
||||
|
||||
// Apply skew
|
||||
let mut temp = Matrix3D::identity();
|
||||
if decomposed.skew.2 != 0.0 {
|
||||
temp.m32 = decomposed.skew.2;
|
||||
matrix = multiply(temp, matrix);
|
||||
}
|
||||
{
|
||||
let mut temp = Matrix3D::identity();
|
||||
if decomposed.skew.2 != 0.0 {
|
||||
temp.m32 = decomposed.skew.2;
|
||||
matrix = multiply(temp, matrix);
|
||||
temp.m32 = 0.0;
|
||||
}
|
||||
|
||||
if decomposed.skew.1 != 0.0 {
|
||||
temp.m32 = 0.0;
|
||||
temp.m31 = decomposed.skew.1;
|
||||
matrix = multiply(temp, matrix);
|
||||
}
|
||||
if decomposed.skew.1 != 0.0 {
|
||||
temp.m31 = decomposed.skew.1;
|
||||
matrix = multiply(temp, matrix);
|
||||
temp.m31 = 0.0;
|
||||
}
|
||||
|
||||
if decomposed.skew.0 != 0.0 {
|
||||
temp.m31 = 0.0;
|
||||
temp.m21 = decomposed.skew.0;
|
||||
matrix = multiply(temp, matrix);
|
||||
if decomposed.skew.0 != 0.0 {
|
||||
temp.m21 = decomposed.skew.0;
|
||||
matrix = multiply(temp, matrix);
|
||||
}
|
||||
}
|
||||
|
||||
// Apply scale
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue