Skip to content

Commit

Permalink
avm2: Use VectorStorage in Matrix3D object construction
Browse files Browse the repository at this point in the history
Co-authored-by: Kamil Jarosz <[email protected]>
  • Loading branch information
cookie-s and kjarosh committed Dec 7, 2024
1 parent a905129 commit 11bbf00
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions core/src/avm2/globals/flash/geom/transform.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -209,12 +211,17 @@ fn matrix3d_to_object<'gc>(
matrix: Matrix3D,
activation: &mut Activation<'_, 'gc>,
) -> Result<Value<'gc>, 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())
}

Expand Down

0 comments on commit 11bbf00

Please sign in to comment.