Skip to content
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

Allow previewing non-drawable scene objects with drawable children #76

Merged
merged 2 commits into from
Mar 1, 2024

Conversation

dgelessus
Copy link
Contributor

The "Preview" context menu item for scene objects was only enabled if the scene object had a draw interface directly attached. This PR implements previewing scene objects where there's no draw interface on the object itself, but some of the children do have draw interfaces.

Here's how this looks for Ahnonay for example:

Preview for Scene Object A_DummyRelocater in Ahnonay_District_ahnySphere01

I don't know the PlasmaShop codebase very well, but I didn't have to do much to get this working. QPlasmaRender already supported rendering multiple objects at once, so it was just a matter of recursively going through the parent object's children and adding every scene object to the renderer.

This doesn't work perfectly yet though. The code that sets the initial camera perspective only looks at the parent scene object and not the children, which isn't much help if the parent isn't drawable. At best, the camera starts zoomed too far in, and at worst, it lands in the middle of nowhere, far from the actual objects. Not sure how to fix this - the vector/matrix math in QPlasmaRender::center goes a bit over my head.

src/PrpShop/PRP/Render/QPlasmaRender.cpp Outdated Show resolved Hide resolved
src/PrpShop/PRP/Render/QPlasmaRender.cpp Outdated Show resolved Hide resolved
src/PrpShop/PRP/Render/QPlasmaRender.cpp Outdated Show resolved Hide resolved
src/PrpShop/QPlasmaUtils.cpp Outdated Show resolved Hide resolved
src/PrpShop/QPlasmaUtils.cpp Outdated Show resolved Hide resolved
@dgelessus
Copy link
Contributor Author

Also added a previewer for entire scene nodes in the same way. It has the same issues as my other change, but still works relatively well in many cases. Here's some Er'cana for example:

Preview of Ercana_District_PlantExterior

@zrax
Copy link
Member

zrax commented Mar 1, 2024

Please rebase to get the CI fixes from #77

src/PrpShop/PRP/Render/QSceneNode_Preview.h Outdated Show resolved Hide resolved
src/PrpShop/QPlasmaUtils.cpp Outdated Show resolved Hide resolved
@dgelessus
Copy link
Contributor Author

There are still some problems here with certain objects not being positioned/scaled correctly. For example, if you preview the spyroom scene node, the telescope and book appear far off from the rest of the geometry. I'm not sure what exactly causes this and how it could be handled better - I don't fully understand all the ways that Plasma stores object positions and geometry...

@dpogue
Copy link
Member

dpogue commented Mar 1, 2024

I don't fully understand all the ways that Plasma stores object positions and geometry...

For static objects, the matrix is usually baked into the geometry data, but for dynamic objects (anything animated or kickable and including clickables, probably) the matrix is stored in the CoordinateInterface (and then they can get complicated the chains of children inheriting parent matrices).

@zrax zrax merged commit 228f0e5 into H-uru:master Mar 1, 2024
4 checks passed
@dgelessus dgelessus deleted the preview_more_scene_objects branch March 1, 2024 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants