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

The doc of follow_viewport_enabled does the opposite thing. #103031

Open
rt9391 opened this issue Feb 19, 2025 · 2 comments · May be fixed by #103111
Open

The doc of follow_viewport_enabled does the opposite thing. #103031

rt9391 opened this issue Feb 19, 2025 · 2 comments · May be fixed by #103111

Comments

@rt9391
Copy link

rt9391 commented Feb 19, 2025

Version

4.4.beta4

Issue description:
CanvasItem.follow_viewport_enabled
The description does not match the actual behavior, in fact it does the opposite.

"If enabled, the CanvasLayer stays in a fixed position on the screen. If disabled, the CanvasLayer maintains its position in world space."

The GUI nodes (those labels) is in a canvaslayer that DISABLED follow_viewport_enabled, whitch would be "maintains its position in world space" according to the doc.
But apparently these GUI only "fixed position on the screen", not maintains in wolrd space.

Image

begins of the camera movement
Image

end of the camera movement
Image

MRP file:
CanvasLayerFviewTest.zip

Originally posted by @rt9391 in #99754 (comment)

@Meorge
Copy link
Contributor

Meorge commented Feb 19, 2025

I tested the provided MRP and looked at the Follow Viewport setting for the CanvasLayers, and from what I can tell this does indeed appear to be the case. For reference, the relevant code, from line 296 of canvas_layer.cpp:

void CanvasLayer::_update_follow_viewport(bool p_force_exit) {
	if (!is_inside_tree()) {
		return;
	}
	if (p_force_exit || !follow_viewport) {
		RS::get_singleton()->canvas_set_parent(canvas, RID(), 1.0);
	} else {
		RS::get_singleton()->canvas_set_parent(canvas, vp->get_world_2d()->get_canvas(), follow_viewport_scale);
	}
}

To my understanding:

  • If "Follow Viewport" is false, then the CanvasLayer's rendering parent is some kind of null object (perhaps the root)? So it doesn't get affected by any world space movement.
  • If "Follow Viewport" is true, then the CanvasLayer's rendering parent is the 2D world's canvas. So it does get affected by world space movement, such as moving off-screen as the camera moves.

I'd be happy to throw together a quick PR for this, unless you'd like to @rt9391 😄

rt9391 added a commit to rt9391/rt9391godot2 that referenced this issue Feb 21, 2025
@rt9391
Copy link
Author

rt9391 commented Feb 21, 2025

I tested the provided MRP and looked at the Follow Viewport setting for the CanvasLayers, and from what I can tell this does indeed appear to be the case. For reference, the relevant code, from line 296 of canvas_layer.cpp:

void CanvasLayer::_update_follow_viewport(bool p_force_exit) {
if (!is_inside_tree()) {
return;
}
if (p_force_exit || !follow_viewport) {
RS::get_singleton()->canvas_set_parent(canvas, RID(), 1.0);
} else {
RS::get_singleton()->canvas_set_parent(canvas, vp->get_world_2d()->get_canvas(), follow_viewport_scale);
}
}
To my understanding:

  • If "Follow Viewport" is false, then the CanvasLayer's rendering parent is some kind of null object (perhaps the root)? So it doesn't get affected by any world space movement.
  • If "Follow Viewport" is true, then the CanvasLayer's rendering parent is the 2D world's canvas. So it does get affected by world space movement, such as moving off-screen as the camera moves.

I'd be happy to throw together a quick PR for this, unless you'd like to @rt9391 😄

Here`s the PR #103111

rt9391 added a commit to rt9391/rt9391godot2 that referenced this issue Feb 21, 2025
rt9391 added a commit to rt9391/rt9391godot2 that referenced this issue Feb 21, 2025
…havior.

Fixes godotengine#103031 Swapping enabled/disabled to match actual behavior.

Fixes godotengine#103031 Swapping enabled/disabled to match actual behavior.
rt9391 added a commit to rt9391/rt9391godot2 that referenced this issue Feb 21, 2025
rt9391 added a commit to rt9391/rt9391godot2 that referenced this issue Feb 21, 2025
The doc of follow_viewport_enabled in godotengine#99754 tells the opposite thing.
This PR swaped enabled/disabled description to match actual behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants