-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Added collision visibility modes #47204
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -326,8 +326,8 @@ | |||||
<member name="occluder_light_mask" type="int" setter="set_occluder_light_mask" getter="get_occluder_light_mask" default="1"> | ||||||
The light mask assigned to all light occluders in the TileMap. The TileSet's light occluders will cast shadows only from Light2D(s) that have the same light mask(s). | ||||||
</member> | ||||||
<member name="show_collision" type="bool" setter="set_show_collision" getter="is_show_collision_enabled" default="true"> | ||||||
If [code]true[/code], collision shapes are shown in the editor and at run-time. Requires [b]Visible Collision Shapes[/b] to be enabled in the [b]Debug[/b] menu for collision shapes to be visible at run-time. | ||||||
<member name="show_collision" type="int" setter="set_show_collision" getter="is_show_collision_enabled" enum="TileMap.CollisionVisibilityMode" default="2"> | ||||||
Show or hide collision shapes. See [enum CollisionVisibilityMode] for possible values. | ||||||
</member> | ||||||
<member name="tile_set" type="TileSet" setter="set_tileset" getter="get_tileset"> | ||||||
The assigned [TileSet]. | ||||||
|
@@ -377,5 +377,14 @@ | |||||
<constant name="TILE_ORIGIN_BOTTOM_LEFT" value="2" enum="TileOrigin"> | ||||||
Tile origin at its bottom-left corner. | ||||||
</constant> | ||||||
<constant name="COLLISION_VISIBILITY_MODE_ALWAYS_SHOW" value="0" enum="CollisionVisibilityMode"> | ||||||
Always show collision shapes in editor and game. | ||||||
</constant> | ||||||
<constant name="COLLISION_VISIBILITY_MODE_ALWAYS_HIDE" value="1" enum="CollisionVisibilityMode"> | ||||||
Always Hide collision shapes in editor and game. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
</constant> | ||||||
<constant name="COLLISION_VISIBILITY_MODE_USE_DEBUG_SETTING" value="2" enum="CollisionVisibilityMode"> | ||||||
Use [b]Visible Collision Shapes[/b] in debug menu to control visibility. Only works in game. | ||||||
</constant> | ||||||
</constants> | ||||||
</class> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit confused by these options. There doesn't seem to be a way to show collision shapes in editor, but not in game? That would seem like the most common use case to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This property is mostly a switch to debug Tilemap collision in both editor and game, with a default option that allows to switch it off on all tilemaps at the same time, but it's true that a 4th option for editor only could be useful too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me the expected behavior would be that it behaves like other collision shapes by default:
And then since it can be annoying to have tilemaps always show collision shapes in the editor, or in game with Visible Collision Shapes, there needs to be a way to turn it off.
So IMO a boolean as done initially should have been enough, but maybe its logic was not correct?
show_collision = true
: collision shapes visible in editor, visible in game if collision debugging is enabled, otherwise not visibleshow_collision = false
: collision shapes not visible in editor nor in game, regardless of debug settingsIs there any other use case worth supporting via an enum?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This behavior is what #46623 was originally doing, but it didn't allow hiding all tilemaps at once in the editor when several of them are used as layers, which could cause some problems (see #46623 (comment)).
This PR implements the solution proposed by @groud in #46623 (comment), which is to have more options instead of a boolean, so by default it can be controlled using "Visible Collision Shapes" option for all tilemaps.
A gizmo could be a less confusing alternative to enable/disable collision shapes in the editor, but I don't know if it's possible to have one that would affect only the collision from tilemaps, it seems you can have only one gizmo per node type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "Visible Collision Shapes" option is used to configure what is visible at runtime, not in the editor. Collision shapes are always visible in the editor, regardless of whether that option is enabled or not.
So IMO it makes things more confusing if this option starts being used to show/hide tilemap collision shapes in the editor, while still leaving non-tilemap collision shapes always visible.
If "Visible Collision Shapes" is turned off, tilemap collision shapes should never be visible at runtime (but the current documentation suggests for the enum values otherwise).
#46623 (comment) is a misunderstanding of what "Visible Collision Shapes" is intended for. For this user's use case, they should just disable collision shapes visibility for all the tilemaps they don't want to see.
OR we simply switch the boolean to false by default, and let users enable it for the tilemaps where they do want to see visible collision shapes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree again. IMO its special use case(#46623 (comment))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@akien-mga Old pr has this problem, let me know if we are not merging this one, I need to update the old one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My idea for this would be to make the "Show debug collision shape" settings smarter. And change it to a 3-options too:
The question is what to do with the shapes. If the idea is to override this setting, we might simply have instead those 4 options per shape:
I believe this is kind of the most expected way to set all of this, as those 3 options (plus one to "inherit" settings) are basically 3 levels of debug. From the "In don't want to debug physics" to the "I have issues with physics, show me shapes in game".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this is actually the easiest option. This way it's disabled by default in both editor and game (which solves #46623 (comment)), and then users can set things individually:
-
show_collision=false
: always disabled in both game and editor-
show_collision=true
: always enabled in editor, controlled by "Visible Collision Shapes" in gameSo the only thing that would not be possible for now is to switch collisions on and off for all tilemaps at once in the editor, but that could be handled later with an improved gizmo system.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opened #47382 to switch it to opt-in.