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

Fix CollisionShape{2D,3D}.debug_color inconsistencies #100093

Merged

Conversation

dalexeev
Copy link
Member

@dalexeev dalexeev commented Dec 6, 2024


Color CollisionShape2D::_get_default_debug_color() const {
SceneTree *st = SceneTree::get_singleton();
return st ? st->get_debug_collisions_color() : Color(0.0, 0.0, 0.0, 0.0);
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't it be better to keep Color() (black) instead of transparent black as the fallback?

If using collision shapes without a scene tree, a black shape is probably better than a transparent one.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is debatable. On the one hand, at least you'll see the shape. On the other hand, you might get a bunch of indistinguishable black rectangles, squares, spheres, etc. But in any case, this is a very hypothetical scenario, the vast majority of users use the standard SceneTree, and do not implement their own MainLoops.

Copy link
Contributor

@Zylann Zylann Dec 8, 2024

Choose a reason for hiding this comment

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

This transparent black already got noticed by a user of my voxel terrain module. They then though collision didn't work, but then we figured out it's because of the default value. Our system doesn't use nodes so we then had to add code to grab the debug_color from SceneTree.

Copy link
Member Author

@dalexeev dalexeev Dec 8, 2024

Choose a reason for hiding this comment

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

Would you prefer transparent or black color?

Copy link
Member

@akien-mga akien-mga Dec 17, 2024

Choose a reason for hiding this comment

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

Why can't we use a fallback value that's actually a good option, like the current default?

1837:   debug_collisions_color = GLOBAL_DEF("debug/shapes/collision/shape_color", Color(0.0, 0.6, 0.7, 0.42));

I think it's fine if hardcoded and not following user config as it's for more niche use cases, though from the report we got so far, more users seem to be affected by the transparent fallback that we thought.

Is this an issue this PR already addresses though, making all projects using SceneTree have the proper color (as opposed to only projects using shape nodes)?

Copy link
Contributor

Choose a reason for hiding this comment

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

I would be for a better default too, although having skimmed over some code related to it, I think it's been used as a special value to mean "null". Maybe that should be checked as well

@dalexeev dalexeev force-pushed the fix-collision-shape-2d-3d-debug-color branch from f8f5767 to 4b73862 Compare December 6, 2024 11:39
@dalexeev dalexeev force-pushed the fix-collision-shape-2d-3d-debug-color branch from 4b73862 to 8bf2afd Compare December 6, 2024 12:12
Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

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

This is already better than the status quo, but maybe the fallback color could be something colored and semi-transparent like the previous default.

Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

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

Let's merge as is for now and see if a different default is useful after dev7.

@akien-mga akien-mga merged commit 46c8f8c into godotengine:master Dec 18, 2024
20 checks passed
@akien-mga
Copy link
Member

Thanks!

@dalexeev dalexeev deleted the fix-collision-shape-2d-3d-debug-color branch December 20, 2024 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Default value of CollisionShape3D's property debug_color should not be saved in .tscn file
4 participants