-
-
Notifications
You must be signed in to change notification settings - Fork 828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
avm2: Implement Matrix3D with 2D support only #18810
avm2: Implement Matrix3D with 2D support only #18810
Conversation
31c6e11
to
14bcef1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you and welcome!
Replace stubs for flash.geom.Transform.matrix3D getter/setter with an actual implementation of Matrix3D with limited support. This implementation is just a proxy to the existing 2D matrix implementation. Therefore transformations beyond 2D transformation works differently from the expected result.
3D Matrix transformations are not yet fully supported.
242f757
to
8f52116
Compare
This PR unfortunately introduces a regression by breaking the getter of The following patch fixes that but the getter still always returns an object instead of returning diff --git a/core/src/avm2/globals/flash/geom/transform.rs b/core/src/avm2/globals/flash/geom/transform.rs
index 104a34a09..759238484 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<Value<'gc>, Error<'gc>> {
- let args = matrix.raw_data.map(Into::into);
+ let value_type = activation.avm2().class_defs().number;
+ let mut raw_data_storage = VectorStorage::new(16, true, Some(value_type), 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())
}
|
I'm sorry @cookie-s! We have to consider reverting it :( To be merged again, it will need a test + the patch posted by me above + 2D/3D switch to cover the following property (source: https://docs.ruffle.rs/en_US/FlashPlatform/reference/actionscript/3/flash/geom/Transform.html#matrix3D).
|
More specifically: after some research, turns out that var mat = movieclip.transform.matrix3D;
movieclip.x = 50;
trace(mat.rawData); // shows 50 This is also required for
to work (which is again opposite to |
@kjarosh Thank you for letting me know and providing the patch! @adrian17 Thank you, that's very interesting observation. After your comment, I checked the reference closely and found
It mentions |
Partially resolves #8033 .
Screenshots
The comparison of screenshots for the first two frames mentioned in #8033 . (Please ignore background differences because those are not at the exact same frames.)
Description
This PR replace stubs for
flash.geom.Transform.matrix3D
getter/setter with an actual implementation of Matrix3D with limited support.This implementation is just a proxy to the existing 2D matrix implementation. Therefore transformations beyond 2D transformation works differently from the expected result.