Skip to content

Commit

Permalink
avm2: Reset matrix when .matrix3D = null is set
Browse files Browse the repository at this point in the history
.matrix = A, .matrix = null, then .matrix3D has the info of the matrix A.
.matrix3D = A, .matrix3D = null, then .matrix is reset to the identity.
  • Loading branch information
cookie-s committed Dec 28, 2024
1 parent 1b6802d commit 019476d
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions core/src/avm2/globals/flash/geom/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,15 +359,18 @@ pub fn set_matrix_3d<'gc>(
avm2_stub_setter!(activation, "flash.geom.Transform", "matrix3D");

let display_object = get_display_object(this);
let Some(obj) = args.try_get_object(activation, 0) else {
display_object
.base_mut(activation.gc())
.set_has_matrix3d_stub(false);
return Ok(Value::Undefined);

let (matrix, has_matrix3d) = {
match args.try_get_object(activation, 0) {
Some(obj) => {
let matrix3d = object_to_matrix3d(obj, activation)?;
let matrix = Matrix::from(matrix3d);
(matrix, true)
}
None => (Matrix::IDENTITY, false),
}
};

let matrix3d = object_to_matrix3d(obj, activation)?;
let matrix = Matrix::from(matrix3d);
display_object.set_matrix(activation.gc(), matrix);
if let Some(parent) = display_object.parent() {
// Self-transform changes are automatically handled,
Expand All @@ -376,7 +379,8 @@ pub fn set_matrix_3d<'gc>(
}
display_object
.base_mut(activation.gc())
.set_has_matrix3d_stub(true);
.set_has_matrix3d_stub(has_matrix3d);

Ok(Value::Undefined)
}

Expand Down

0 comments on commit 019476d

Please sign in to comment.