-
-
Notifications
You must be signed in to change notification settings - Fork 828
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
avm2: Implement Matrix3D with 2D support only
Replace stubs for flash.geom.Transform.matrix3D getter/setter with an actual implementation of Matrix3D with limited support. This implementation is just a proxy to the existing 2D matrix implementation. Therefore transformations beyond 2D transformation work differently from the expected result.
- Loading branch information
Showing
5 changed files
with
124 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
use crate::matrix::Matrix; | ||
use swf::Twips; | ||
|
||
/// The transformation matrix for 3D used by Flash display objects. | ||
#[derive(Copy, Clone, Debug, PartialEq)] | ||
pub struct Matrix3D { | ||
/// 4x4 matrix elements. | ||
pub raw_data: [f64; 16], | ||
} | ||
|
||
impl From<Matrix> for Matrix3D { | ||
fn from(matrix: Matrix) -> Self { | ||
Self { | ||
raw_data: [ | ||
// 1st column | ||
matrix.a.into(), | ||
matrix.b.into(), | ||
0.0, | ||
0.0, | ||
// 2nd column | ||
matrix.c.into(), | ||
matrix.d.into(), | ||
0.0, | ||
0.0, | ||
// 3rd column | ||
0.0, | ||
0.0, | ||
1.0, | ||
0.0, | ||
// 4th column | ||
matrix.tx.to_pixels(), | ||
matrix.ty.to_pixels(), | ||
0.0, | ||
1.0, | ||
], | ||
} | ||
} | ||
} | ||
impl From<Matrix3D> for Matrix { | ||
fn from(matrix: Matrix3D) -> Self { | ||
Self { | ||
a: matrix.raw_data[0] as f32, | ||
b: matrix.raw_data[1] as f32, | ||
c: matrix.raw_data[4] as f32, | ||
d: matrix.raw_data[5] as f32, | ||
tx: Twips::from_pixels(matrix.raw_data[12]), | ||
ty: Twips::from_pixels(matrix.raw_data[13]), | ||
} | ||
} | ||
} |