From 019476db8d210f43d3ab2bac84f1a2b1317d80f4 Mon Sep 17 00:00:00 2001 From: kcz Date: Fri, 27 Dec 2024 19:48:18 -0500 Subject: [PATCH] avm2: Reset matrix when .matrix3D = null is set .matrix = A, .matrix = null, then .matrix3D has the info of the matrix A. .matrix3D = A, .matrix3D = null, then .matrix is reset to the identity. --- core/src/avm2/globals/flash/geom/transform.rs | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/core/src/avm2/globals/flash/geom/transform.rs b/core/src/avm2/globals/flash/geom/transform.rs index adb7581640af..d893222cade2 100644 --- a/core/src/avm2/globals/flash/geom/transform.rs +++ b/core/src/avm2/globals/flash/geom/transform.rs @@ -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, @@ -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) }