Skip to content

avm2: Store PerspectiveProjection to DisplayObject#19670

Merged
Dinnerbone merged 8 commits intoruffle-rs:masterfrom
cookie-s:perspective-projection-storage
Jun 10, 2025
Merged

avm2: Store PerspectiveProjection to DisplayObject#19670
Dinnerbone merged 8 commits intoruffle-rs:masterfrom
cookie-s:perspective-projection-storage

Conversation

@cookie-s
Copy link
Copy Markdown
Contributor

@cookie-s cookie-s commented Mar 1, 2025

Continued from #19532 .

DisplayObject stores Option<PerspectiveProjection> through Transform so we can remove HAS_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_setters)

@cookie-s cookie-s force-pushed the perspective-projection-storage branch 7 times, most recently from 19168c2 to af96e50 Compare March 2, 2025 17:43
@cookie-s cookie-s marked this pull request as ready for review March 2, 2025 17:56
@Lord-McSweeney Lord-McSweeney added A-avm2 Area: AVM2 (ActionScript 3) T-fix Type: Bug fix (in something that's supposed to work already) waiting-on-review Waiting on review from a Ruffle team member labels Mar 3, 2025
@cookie-s cookie-s force-pushed the perspective-projection-storage branch from af96e50 to 970b60c Compare April 26, 2025 13:19
@cookie-s cookie-s marked this pull request as draft April 26, 2025 13:23
@cookie-s cookie-s force-pushed the perspective-projection-storage branch 3 times, most recently from e5874ce to da3e09a Compare April 26, 2025 14:17
Comment on lines +3 to +8
[approximations]
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
Copy link
Copy Markdown
Contributor Author

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.)

Copy link
Copy Markdown
Collaborator

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.

@cookie-s cookie-s marked this pull request as ready for review April 26, 2025 14:31
Comment thread core/src/avm2/globals/flash/geom/perspective_projection.rs
Comment thread core/src/avm2/globals/flash/geom/transform.rs Outdated
.classes()
.perspectiveprojection
.construct(activation, &[])?;
.construct(activation, &[])?
Copy link
Copy Markdown
Collaborator

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?

Copy link
Copy Markdown
Contributor Author

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.

},
));
stage.set_is_root(gc_context, true);
stage.set_perspective_projection(gc_context, None); // Set default PerspectiveProjection
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this line necessary?

Copy link
Copy Markdown
Contributor Author

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.

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.

root.set_perspective_projection(self.gc(), None); // Set default PerspectiveProjection

The root actually has a different value used when None (null) is provided..
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,
),
});
}

@cookie-s cookie-s force-pushed the perspective-projection-storage branch from da3e09a to aa6197e Compare May 2, 2025 00:42
Copy link
Copy Markdown
Contributor Author

@cookie-s cookie-s left a 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!

Comment thread core/src/avm2/globals/flash/geom/perspective_projection.rs
.classes()
.perspectiveprojection
.construct(activation, &[])?;
.construct(activation, &[])?
Copy link
Copy Markdown
Contributor Author

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.

},
));
stage.set_is_root(gc_context, true);
stage.set_perspective_projection(gc_context, None); // Set default PerspectiveProjection
Copy link
Copy Markdown
Contributor Author

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.

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.

root.set_perspective_projection(self.gc(), None); // Set default PerspectiveProjection

The root actually has a different value used when None (null) is provided..
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,
),
});
}

Comment thread core/src/avm2/globals/flash/geom/transform.rs Outdated
@cookie-s cookie-s force-pushed the perspective-projection-storage branch from aa6197e to 513015d Compare May 11, 2025 02:25
@cookie-s cookie-s force-pushed the perspective-projection-storage branch 2 times, most recently from fdba546 to 744856c Compare May 28, 2025 00:24
@Dinnerbone Dinnerbone force-pushed the perspective-projection-storage branch from 744856c to 0a76bf0 Compare June 10, 2025 17:33
@Dinnerbone
Copy link
Copy Markdown
Contributor

I've fixed the rebase conflict.

Thank you so much!

cookie-s added 8 commits June 10, 2025 19:37
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
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.
@Dinnerbone Dinnerbone force-pushed the perspective-projection-storage branch from 0a76bf0 to db155ab Compare June 10, 2025 17:37
@Dinnerbone Dinnerbone enabled auto-merge (rebase) June 10, 2025 17:37
@Dinnerbone Dinnerbone merged commit 73e3af4 into ruffle-rs:master Jun 10, 2025
23 checks passed
@cookie-s cookie-s deleted the perspective-projection-storage branch June 11, 2025 04:17
@Lord-McSweeney Lord-McSweeney removed waiting-on-review Waiting on review from a Ruffle team member labels Jun 13, 2025
Hancock33 added a commit to Hancock33/batocera.piboy that referenced this pull request Jun 15, 2025
---------------------------------------------------------------------------------------
amiberry.mk 8f253ae5e44b7cc5bd90454bf63e719b6ffc6a24 # Version: Commits on Jun 10, 2025
---------------------------------------------------------------------------------------
bugfix: Prevent null pointer return for small ROM buffer sizes,

--------------------------------------------------------------------------------------------
amiberry-lite.mk ee9f7f9cb4a3623d9050a1adc1aec45063f022d4 # Version: Commits on Jun 11, 2025
--------------------------------------------------------------------------------------------
bugfix: Fix some address sanitizer issues,

------------------------------------------------------------------------------------------
dolphin-emu.mk a16387741383ca00524f78f9854c55be7089cf93 # Version: Commits on Jun 10, 2025
------------------------------------------------------------------------------------------
Merge pull request #13746 from LillyJadeKatrin/retroachievements-hardcore-changed

MainWindow - Avoid excessive emulation state changes,

------------------------------------------------------------------------------------------
duckstation.mk 36b869003a5032ad6b8ebdfeb290664590722e00 # Version: Commits on Jun 10, 2025
------------------------------------------------------------------------------------------
Qt: Use standard key sequences for main window shortcuts

Notably, this enables command+R to refresh on macOS, where F5

is not commonly used.,

-----------------------------------------------------------------------------------------
lightspark.mk a92464d46e92f0e974d3fd848a69d85386fa0280 # Version: Commits on Jun 11, 2025
-----------------------------------------------------------------------------------------
[ABCVm] fix several issues with local numbers

fixes some regressions in \Nightflies\,

--------------------------------------------------------------------------------------
openmsx.mk c0305648eea0974c57318ec420d6a166f8bcd767 # Version: Commits on Jun 09, 2025
--------------------------------------------------------------------------------------
Add auto raw screenshot size option to the GUI.

Closes #1062.,

----------------------------------------------------
pcsx2.mk v2.3.414 # Version: Commits on Jun 10, 2025
----------------------------------------------------
- [IopBios: do not overflow snprintf tmp buffer](PCSX2/pcsx2#12826)

-------------------------------------------------------------------------------------
ppsspp.mk d5cf9c97ca79c558268abd7b331238b33c35ed0f # Version: Commits on Jun 11, 2025
-------------------------------------------------------------------------------------
Merge pull request #20506 from crashGG/mmpx-enhace

Fixed luma calculation in MMPX,

---------------------------------------------------------------
ruffle.mk nightly-2025-06-11 # Version: Commits on Jun 11, 2025
---------------------------------------------------------------
## What's Changed

* build(deps): bump the cargo-minor group across 1 directory with 9 updates by @dependabot in ruffle-rs/ruffle#20591

* web: Switch from `unload` to `pagehide` event by @Toad06 in ruffle-rs/ruffle#20429

* core: Add known_failure tests for frame script handling by @nivkner in ruffle-rs/ruffle#20589

* avm2: hitTestPoint should only use local coordinates for the player root by @ZingBallyhoo in ruffle-rs/ruffle#20054

* avm2: Store PerspectiveProjection to DisplayObject by @cookie-s in ruffle-rs/ruffle#19670

* desktop: Implement font sorting using fontconfig by @kjarosh in ruffle-rs/ruffle#20392

* avm1: don't panic when trying to set a different NativeObject kind by @moulins in ruffle-rs/ruffle#20482

* avm2: Don't activate fast-path for non-public Multiname by @Lord-McSweeney in ruffle-rs/ruffle#18746

**Full Changelog**: ruffle-rs/ruffle@nightly-2025-06-10...nightly-2025-06-11,

----------------------------------------------------
ryujinx.mk 1.3.85 # Version: Commits on Jun 11, 2025
----------------------------------------------------
Canary-1.3.85

--------------------------------------------------------------------------------------
scummvm.mk fdcbc279765e432cbabf19264273f4a87f61fc11 # Version: Commits on Jun 10, 2025
--------------------------------------------------------------------------------------
SCUMM: Use correct save slot when loading during a SMUSH video

This only affected the original load dialogs.,

--------------------------------------------------------------------------------------
shadps4.mk 3e0ec9ebef8c6b7d752d4538e42b36b571c983a6 # Version: Commits on Jun 11, 2025
--------------------------------------------------------------------------------------
Core: Merge Direct Memory Areas (#3084)

* Merge dmem areas

* Fix DirectMemoryArea::CanMergeWith

Don't merge dmem areas if the memory types are different.

* Reduce some warnings to info

Both functions should behave properly now, there's no reason to warn about their use.

* Clang,

---------------------------------------------------------------------------------------
thextech.mk 60b4df7c9465eae98e60b0949c2fd92fb6c00a15 # Version: Commits on Jun 11, 2025
---------------------------------------------------------------------------------------
Update AudioCodecs,

-------------------------------------------------
vice.mk r45696 # Version: Commits on Jun 11, 2025
-------------------------------------------------
used constant instead of magic number, make docs match the implementation :)

git-svn-id: https://svn.code.sf.net/p/vice-emu/code/trunk@45696 379a1393-f5fb-40a0-bcee-ef074d9b53f7,

----------------------------------------------------------------------------------------
rpi-utils.mk b7651d86d71a172b2208c67b2e360cbcb4f9d98f # Version: Commits on Jun 11, 2025
----------------------------------------------------------------------------------------
pinctrl: Clarify the required privelege level

See: raspberrypi/utils#135

Signed-off-by: Phil Elwell <[email protected]>,

----------------------------------------------------------------------------------------
pironman5.mk b70f2afc10d70661d8a798d1744696a1e9864282 # Version: Commits on Jun 11, 2025
----------------------------------------------------------------------------------------
chore: update version to 1.2.13.3 and pm_auto dependency to 1.2.9,

------------------------------------------------------------------------------------
box64.mk 44669935dae4ca780417c877981c3ca9390758c9 # Version: Commits on Jun 11, 2025
------------------------------------------------------------------------------------
[WOW64] Small improvement to grab_segdata (#2728),

------------------------------------------------------------------------------------------
fallout2-ce.mk a67fe7ead1ac985eba480e9c31fd1df49db39c44 # Version: Commits on Jun 11, 2025
------------------------------------------------------------------------------------------
Merge pull request #191 from fallout2-ce/scan_scripts_for_unknown_opcodes_2

Scanner of not implemented opcodes, metarules, config options,

----------------------------------------------------
fheroes2.mk 1.1.9 # Version: Commits on Jun 11, 2025
----------------------------------------------------
- Add the ability to set owner color for capturable objects in the Editor

- Add the Black Cat and Barrel objects

- Update rendering of spells in battles and fix several rendering issues

- Improve performance for the Editor and language support

- Bundle several maps with fheroes2

- Over _**30**_ issues have been closed since the 1.1.8 release

Full list of changes can be found [here](https://github.com/ihhub/fheroes2/wiki/Change-Log).

Please follow the [**installation guide**](https://ihhub.github.io/fheroes2/INSTALL.html) to download and install fheroes2.,

----------------------------------------------------------------------------------------
openmohaa.mk a3662d01badf81856948a377446615609861e341 # Version: Commits on Jun 11, 2025
----------------------------------------------------------------------------------------
Use a debug print rather than an error drop when the reference count for an area is negative (#755),

-----------------------------------------------------
warehouse.mk 2.1.0 # Version: Commits on Jun 10, 2025
-----------------------------------------------------
Remove mime tags from appstream,

-----------------------------------------------------------------------------------------
winetricks.mk 9279fc0acdb7501a68258fe2da8424774e79b860 # Version: Commits on Jun 11, 2025
-----------------------------------------------------------------------------------------
busybox: update to FRP-5579-g5749feb3,

----------------------------------------------------------------------------------------
retroarch.mk aebfff21662da81dcd74573dc6b004457fc62299 # Version: Commits on Jun 11, 2025
----------------------------------------------------------------------------------------
apple: better mfi controller disconnect handling,

----------------------------------------------------------------------------------------
doomretro.mk 1795a80c56751515507d16af4db68c253516644d # Version: Commits on Jun 11, 2025
----------------------------------------------------------------------------------------
Further work on `play` CCMD,

-------------------------------------------------------------------------------------
gzdoom.mk 11809748a13ae088395e59c763b0f9114a4585a0 # Version: Commits on Jun 11, 2025
-------------------------------------------------------------------------------------
Fixed outdated example in config file

Config file said to use 'doom.doom2.Autoload' and 'doom.doom2.commercial.Autoload',

which do not seem to work anymore. Replaced with 'doom.id.doom2.Autoload' and

'doom.id.doom2.commercial.Autoload', respectively.,

-----------------------------------------------------------------------------------
tr1x.mk 9d582d30143663e01c3bb0e9871b0165b5b14152 # Version: Commits on Jun 10, 2025
-----------------------------------------------------------------------------------
lara/col/swim: add water exit fix option

This makes TR2's water exit constraint - whereby Lara can't exit

horizontally or below - optional in both games. In addition the

setting will control whether or not Lara can exit water onto a slope.

Resolves #3154.,

-----------------------------------------------------------------------------------
tr2x.mk 9d582d30143663e01c3bb0e9871b0165b5b14152 # Version: Commits on Jun 10, 2025
-----------------------------------------------------------------------------------
lara/col/swim: add water exit fix option

This makes TR2's water exit constraint - whereby Lara can't exit

horizontally or below - optional in both games. In addition the

setting will control whether or not Lara can exit water onto a slope.

Resolves #3154.,

---------------------------------------------------------------------------------------------------
libretro-dosbox-pure.mk 1a86ae47a58fca1fa8c5f5e4bd2ff98dfdb91b8e # Version: Commits on Jun 11, 2025
---------------------------------------------------------------------------------------------------
Add more options to the 'Force Output FPS' core option that can be used to enable frame skipping (#616),

----------------------------------------------------------------------------------------------
libretro-ppsspp.mk d5cf9c97ca79c558268abd7b331238b33c35ed0f # Version: Commits on Jun 11, 2025
----------------------------------------------------------------------------------------------
Merge pull request #20506 from crashGG/mmpx-enhace

Fixed luma calculation in MMPX,

-----------------------------------------------------------------------------------------------
libretro-scummvm.mk fdcbc279765e432cbabf19264273f4a87f61fc11 # Version: Commits on Jun 10, 2025
-----------------------------------------------------------------------------------------------
SCUMM: Use correct save slot when loading during a SMUSH video

This only affected the original load dialogs.,

---------------------------------------------------------------------------------------------
libretro-vba-m.mk 74528ccb30f69c6b29d24072863e31bcaa15e549 # Version: Commits on Jun 11, 2025
---------------------------------------------------------------------------------------------
Switch to SDL3 3.2.16,

---------------------------------------------------------------------------------------------
libretro-wasm4.mk 2bf43ca3129328daf0028a9659075692908685c9 # Version: Commits on Jun 11, 2025
---------------------------------------------------------------------------------------------
Merge pull request #809 from sulewicz/sulewicz/tank-wars

tank-wars,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-avm2 Area: AVM2 (ActionScript 3) T-fix Type: Bug fix (in something that's supposed to work already)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants