From a223d93ceabddae41169f4e70957b203bad4bd5c 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 0f84e87ff32b..2a416e90c0f8 100644 --- a/core/src/avm2/globals/flash/geom/transform.rs +++ b/core/src/avm2/globals/flash/geom/transform.rs @@ -360,15 +360,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, @@ -377,7 +380,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) }