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

Error when switching from a 3D scene with a PCamHost to one with only a PCam #297

Closed
jogly opened this issue May 9, 2024 · 2 comments
Closed
Labels
bug Something isn't working
Milestone

Comments

@jogly
Copy link

jogly commented May 9, 2024

Issue description

When switching scenes the Phantom Camera view finder dock tries to make the new scene's PCam3D active, but uses the old scene's Camera3D (via the old scene's PCamHost) if the new scene does not have a PCamHost. This means calling get_global_transform on Camera3D when it is not in the current scene tree which results in the following editor error:

scene/3d/node_3d.cpp:346 - Condition "!is_inside_tree()" is true. Returning: Transform3D()

I was able to remove the error by checking if the camera3d is inside the tree before considering it in addons/phantom_camera/scripts/phantom_camera_host/phantom_camera_host.gd#128

func _assign_new_active_pcam(pcam: Node) -> void:
	var no_previous_pcam: bool

	if _active_pcam:
		if _is_2D:
			_prev_active_pcam_2d_transform = camera_2d.get_global_transform()
			_active_pcam.queue_redraw()
-		else: 
+		elif camera_3d.is_inside_tree():
			_prev_active_pcam_3d_transform = camera_3d.get_global_transform()
			_prev_camera_fov = camera_3d.get_fov()
			_prev_camera_h_offset = camera_3d.get_h_offset()
			_prev_camera_v_offset = camera_3d.get_v_offset()

but the real fix should patch the viewfinder logic to clean up on scene switching so it doesnt even try to update the old PCamHost.

Steps to reproduce

Two scenes:

  1. With a Camera3D, PCamHost, and PCam3D. The viewfinder should work.
  2. With a PCam3D only.

Switching from (1) to (2) should print the erorr.

(Optional) Minimal reproduction project

No response

@ramokz
Copy link
Owner

ramokz commented May 12, 2024

This looks like a case where logic in the _exit_tree() function is called, which tries to communicate with PCamHost. Which it really shouldn't, given everything is exiting the tree when changing scene.

Think there's a more systemic checker that could be put in place to guard against this.

@ramokz ramokz added the bug Something isn't working label May 12, 2024
@ramokz ramokz added this to the 0.7.2 milestone May 12, 2024
@ramokz
Copy link
Owner

ramokz commented May 23, 2024

Appears to be solved from changes in #267

@ramokz ramokz closed this as completed May 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

2 participants