From 11bbf00870fb06d5b6c2591363e1a7d330bbc3cc Mon Sep 17 00:00:00 2001 From: kcz Date: Thu, 5 Dec 2024 20:37:15 -0500 Subject: [PATCH] avm2: Use VectorStorage in Matrix3D object construction Co-authored-by: Kamil Jarosz --- core/src/avm2/globals/flash/geom/transform.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/core/src/avm2/globals/flash/geom/transform.rs b/core/src/avm2/globals/flash/geom/transform.rs index 563bd2f47bf03..f4692f0d5a28c 100644 --- a/core/src/avm2/globals/flash/geom/transform.rs +++ b/core/src/avm2/globals/flash/geom/transform.rs @@ -1,5 +1,7 @@ use crate::avm2::globals::slots::*; +use crate::avm2::object::VectorObject; use crate::avm2::parameters::ParametersExt; +use crate::avm2::vector::VectorStorage; use crate::avm2::{Activation, Error, Object, TObject, Value}; use crate::display_object::TDisplayObject; use crate::prelude::{DisplayObject, Matrix, Twips}; @@ -209,12 +211,17 @@ fn matrix3d_to_object<'gc>( matrix: Matrix3D, activation: &mut Activation<'_, 'gc>, ) -> Result, Error<'gc>> { - let args = matrix.raw_data.map(Into::into); + let number = activation.avm2().class_defs().number; + let mut raw_data_storage = VectorStorage::new(16, true, Some(number), activation); + for (i, data) in matrix.raw_data.iter().enumerate() { + raw_data_storage.set(i, Value::Number(*data), activation)?; + } + let vector = VectorObject::from_vector(raw_data_storage, activation)?.into(); let object = activation .avm2() .classes() .matrix3d - .construct(activation, &args)?; + .construct(activation, &[vector])?; Ok(object.into()) }