-
-
Notifications
You must be signed in to change notification settings - Fork 843
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 flash.geom.PerspectiveProjection #19532
base: master
Are you sure you want to change the base?
Conversation
21ae2a2
to
de64c8d
Compare
e929ede
to
afc763f
Compare
// Not associated with any DO | ||
None => 500.0, | ||
// Stage's PerspectiveProjection | ||
Some(dobj) if dobj.as_stage().is_some() => 500.0, |
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.
I don't know where this value 500 comes from. It fits the output from the test in FP.
private var displayObject: DisplayObject = null; | ||
|
||
[Ruffle(NativeAccessible)] | ||
private var fov: Number = 55.0; |
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.
From TestTransform()
result, fieldOfView
should be saved and focalLength
should be computed from it.
PP(FOV:55, FL:480.25)
assignment to Sprite.transform.perspectiveProjection
produces PP(FOV:55, FL:288.15)
(when SWF width is 300).
afc763f
to
2aa2853
Compare
this might be useful, take a look |
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.
I think it all looks fine, but if you don’t mind, I wanna investigate a bit into the remaining unknowns; but I’ll only be able to do it on wednesday.
stub_method("flash.geom.PerspectiveProjection", "toMatrix3D"); | ||
return new Matrix3D(); | ||
var fl: Number = this.focalLength; | ||
return new Matrix3D(new <Number>[ |
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.
To be sure, this is a complete matrix impl? Asking due to the removed stub.
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.
Yes, I believe so. For other methods, especially setters are related to unimplemented rendering/visual, but I believe this toMatrix3D
just returns the Matrix3D object.
Ah, but only if the small but not very small floating point number differences are allowed. Please see precision
in TestToMatrix3D
test function. There is unexplainable numerical errors which is now rounded to approximation in the test.
Except for that, I believe all features in toMatrix3D
are implemented.
As for emergence75’s code, note that we did find issues with some of the changes there (see: #18495 (comment) and the subsequent comment). I know that since then it was replaced by a newer PR (which I’m sorry for not commenting on), but as far as I’m aware, the listed concerns about the changes still apply :( With that, I’d be careful with treating it as a source. |
Oh thank you. My PR might be better to implement the input validation for fieldOfView setter.
Sure thank you! |
2aa2853
to
3fadf21
Compare
// Stage's PerspectiveProjection | ||
Some(dobj) if dobj.as_stage().is_some() => 500.0, | ||
// root's PerspectiveProjection | ||
Some(dobj) if dobj.is_root() => activation.context.stage.stage_size().0 as f64, |
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.
If this has the same logic as the one below, any reason for it to be separate?
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.
Good point. No! Thank you, merged to the line below at f6f2aba
import flash.geom.Matrix3D; | ||
import flash.geom.Point; | ||
|
||
public class PerspectiveProjection { | ||
// Getters are stubbed with what seem to be Flash's default values | ||
[Ruffle(NativeAccessible)] | ||
private var displayObject: DisplayObject = null; |
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.
Does this actually need the live reference to the DO? What if instead, only the width value was stored?
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.
True, storing only width
passes the current test, but another observation by for example this code:
private function TestTransformUpdate(): void {
var s: Sprite = new Sprite();
trace("// Set non-null to transform.perspectiveProjection");
s.transform.perspectiveProjection = new PerspectiveProjection();
printProps(s.transform.perspectiveProjection);
trace("// Set null to transform.perspectiveProjection");
s.transform.perspectiveProjection.fieldOfView = 100;
printProps(s.transform.perspectiveProjection);
}
shows some setter in DO.transform.perspectiveProjection : PerspectiveProjection
should update the values in DO.
It's the similar behavior to transform.matrix3D
rather than transform.matrix
in terms of what we discussed before: #18810 (comment)
(although that setter behavior is not implemented to matrix3D and transform.perspectiveProjection
setter is almost imcomplete as of now.)
Given that, we will anyway need reference to DO at some point I believe.
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.
Oh, I see, yeah.
var a = dobj.transform.perspectiveProjection;
var b = dobj.transform.perspectiveProjection;
trace(a === b); // false
a.fieldOfView = 123;
trace(b.fieldOfView); // 123
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.
Can you please add some TODO comments explaining the above, and maybe a known-failure test? But just a comment is enough, I think I'm gonna approve the PR in a moment.
although that setter behavior is not implemented to matrix3D and transform.perspectiveProjection setter is almost imcomplete as of now
Sure, I think this is an okay compromise.
3fadf21
to
f5e13c0
Compare
doc: https://docs.ruffle.rs/en_US/FlashPlatform/reference/actionscript/3/flash/geom/PerspectiveProjection.html
This PR implements
flash.geom.PerspectiveProjection
features. However, assignment toflash.display.DisplayObject
throughtransform.perspectiveProjection
is not yet supported. No effect to visual, either.