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

Decouple PhantomCameraHost from specific PhantomCamera #207

Open
GeneralProtectionFault opened this issue Feb 3, 2024 · 1 comment
Open
Labels
2D Issues concerning 2D scenes bug Something isn't working Investigating

Comments

@GeneralProtectionFault
Copy link

Project Type

2D

Feature Description

Allow having a camera on the scene w/ a PhantomCameraHost, and dynamically add/remove the PhantomCamera without having to remove/add a new PhantomCameraHost

Use Cases

For clarity, I'm accessing this via C#.
I also am using 2D, but if the same logic is used, I imagine it applies to 3D as well.
I set up 2 scenes that I can go between, and add the PhantomCamera & settings/target in code. This works fine.

If, when changing scenes, I free the scene w/ the PhantomCamera & Host, it still works. Going back into the scene a 2nd time works as expected.

However, if I store the scene in memory (a static variable - this is done on a large scene to avoid unacceptable loading time), and simply remove the PhantomCamera from that scene (and remove the scene from the tree), then go back to the stored-in-memory scene again, adding the PhantomCamera on this 2nd tryy causes problems, and this error is thrown:

"Attempt to call function 'queue_redraw' in base 'previously freed' on a null instance."

I essentially figured out that I need to dynamically remove & add the PhantomCameraHost in this situation, which works fine. However, it's not obvious.

Importance

Low - there are workarounds where the proposed feature would just simplify things

Usage

Often - a significant amount of projects can find this useful

(Optional) Proposed Solution

It would be cool if the plugin handled this use case and did not require the removing/adding a fresh PhantomCameraHost.
However, I do not know what domino-effects that would have, so if that is a bad idea, I would suggest that an error be thrown at the appropriate times that lets the user know that the PhantomCameraHost needs to be removed/recreated if doing so with the PhantomCamera itself.

@ramokz
Copy link
Owner

ramokz commented Feb 13, 2024

"Attempt to call function 'queue_redraw' in base 'previously freed' on a null instance."

If that error is the only one you're getting, then it might not be a complicated fix.
queue_redraw is called manually, but only within the PCam2D script. Suggesting it could be isolated to 2D scenes.

There are two queue_redraw call instances in the script, does the error you're seeing specify which line it's coming from?

@ramokz ramokz added bug Something isn't working 2D Issues concerning 2D scenes Investigating labels Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2D Issues concerning 2D scenes bug Something isn't working Investigating
Projects
None yet
Development

No branches or pull requests

2 participants