-
-
Notifications
You must be signed in to change notification settings - Fork 882
avm2: Store PerspectiveProjection to DisplayObject #19670
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
base: master
Are you sure you want to change the base?
avm2: Store PerspectiveProjection to DisplayObject #19670
Conversation
19168c2
to
af96e50
Compare
af96e50
to
970b60c
Compare
e5874ce
to
da3e09a
Compare
number_patterns = [ | ||
# Both FP 32,0,0,465 (for Linux) and FP 32 (for Windows) produced slightly different numbers in some environment. However, the original trace from mozilla/shumway is respected in the output file. | ||
'focalLength: ([0-9.]+)' | ||
] | ||
max_relative = 0.0000001 |
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 believe the output.txt
is from https://github.com/mozilla/shumway/blob/master/test/swfs/avm2/flash/geom/perspectiveprojection/PerspectiveProjectionClass.swf.trace .
I couldn't reproduce exactly the same result from PerspectiveProjectionClass.as
in the same directory (after recompilation with mxmlc) or even from the test.swf
(without recompilation).
(Fun fact: I was able to pass this test without this approximation until #19748 was merged -- What does it mean? Anyway, I think the problem is that I cannot reproduce the output.txt
from ActionScript or SWF.)
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 a small difference like this isn't a problem, we have similar issues with some of the AVM2 Number tests already.
.avm2() | ||
.classes() | ||
.perspectiveprojection | ||
.construct(activation, &[])?; | ||
.construct(activation, &[])? |
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.
Hmm, does this really return a new PerspectiveProjection each time the getter is called?
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, to make it clear, I added a test case testEq()
to geom_transform just now.
From the same Transform, every call to the getter creates a new PerspectiveProjection.
@@ -193,6 +194,7 @@ impl<'gc> Stage<'gc> { | |||
}, | |||
)); | |||
stage.set_is_root(gc_context, true); | |||
stage.set_perspective_projection(gc_context, None); // Set default PerspectiveProjection |
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.
Is this line necessary?
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, this line actually sets PerspectiveProjection::default()
to DO's PerspectiveProjection.
ruffle/core/src/display_object/stage.rs
Lines 894 to 896 in aa6197e
if perspective_projection.is_none() { | |
// `stage` doesn't allow null PerspectiveProjection. | |
perspective_projection = Some(Default::default()); |
Technically it's fine to set PerspectiveProjection::default()
directly at here, but for consistency with root.set_perspective_projection()
in a different file I'm passing None
here.
Line 397 in aa6197e
root.set_perspective_projection(self.gc(), None); // Set default PerspectiveProjection |
The
root
actually has a different value used when None
(null
) is provided..ruffle/core/src/display_object/movie_clip.rs
Lines 2836 to 2845 in aa6197e
if perspective_projection.is_none() && self.is_root() { | |
// `root` doesn't allow null PerspectiveProjection. | |
perspective_projection = Some(PerspectiveProjection { | |
field_of_view: 55.0, | |
center: ( | |
self.movie().width().to_pixels() / 2.0, | |
self.movie().height().to_pixels() / 2.0, | |
), | |
}); | |
} |
da3e09a
to
aa6197e
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.
Thank you for review!
.avm2() | ||
.classes() | ||
.perspectiveprojection | ||
.construct(activation, &[])?; | ||
.construct(activation, &[])? |
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, to make it clear, I added a test case testEq()
to geom_transform just now.
From the same Transform, every call to the getter creates a new PerspectiveProjection.
@@ -193,6 +194,7 @@ impl<'gc> Stage<'gc> { | |||
}, | |||
)); | |||
stage.set_is_root(gc_context, true); | |||
stage.set_perspective_projection(gc_context, None); // Set default PerspectiveProjection |
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, this line actually sets PerspectiveProjection::default()
to DO's PerspectiveProjection.
ruffle/core/src/display_object/stage.rs
Lines 894 to 896 in aa6197e
if perspective_projection.is_none() { | |
// `stage` doesn't allow null PerspectiveProjection. | |
perspective_projection = Some(Default::default()); |
Technically it's fine to set PerspectiveProjection::default()
directly at here, but for consistency with root.set_perspective_projection()
in a different file I'm passing None
here.
Line 397 in aa6197e
root.set_perspective_projection(self.gc(), None); // Set default PerspectiveProjection |
The
root
actually has a different value used when None
(null
) is provided..ruffle/core/src/display_object/movie_clip.rs
Lines 2836 to 2845 in aa6197e
if perspective_projection.is_none() && self.is_root() { | |
// `root` doesn't allow null PerspectiveProjection. | |
perspective_projection = Some(PerspectiveProjection { | |
field_of_view: 55.0, | |
center: ( | |
self.movie().width().to_pixels() / 2.0, | |
self.movie().height().to_pixels() / 2.0, | |
), | |
}); | |
} |
aa6197e
to
513015d
Compare
Stage and root have their own initial PerspectiveProjection value, and it's also used when attempting to set `null`.
* Remove FIXME for TestTranformUpdate() * Add four more test cases
fdba546
to
744856c
Compare
Small number differences in focalLength are accepted as approximation
It's now unused because ruffle_render::Transform stores Option<PerspectiveProjection>.
It's very hard to verify this value with any test while PerspectiveProjection rendering is not implemented. However, this change makes the most sense.
It's not obvious whether each getter of one Transform object should return the same instance or newly created instance.
Continued from #19532 .
DisplayObject stores
Option<PerspectiveProjection>
throughTransform
so we can removeHAS_PERSPECTIVE_PROJECTION_STUB
flag from display objects.The test
from_shumway/avm2/flash/geom/perspectiveprojection
passes now.Limitation
PerspectiveProjection is stored in Transform, but it's not used in rendering at all. (Hence, we cannot remove
stub_setter
s)