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

Allow customizing debug color of Path3D. #82321

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

ywmaa
Copy link
Contributor

@ywmaa ywmaa commented Sep 25, 2023

@ywmaa
Copy link
Contributor Author

ywmaa commented Sep 25, 2023

The solution is not working for some reason, so that's why I assigned it as a draft.

@YuriSizov
Copy link
Contributor

Hey, I noticed that were making your first PRs recently. I recommend familiarizing with our contribution guidelines. Namely the preferred way to title commits and pull requests.

For example, for this feature the commit message could be "Allow to customize debug color of Path3D".

@ywmaa
Copy link
Contributor Author

ywmaa commented Sep 25, 2023

Yeah, those are my first PRs.

I recommend familiarizing with our contribution guidelines. Namely the preferred way to title commits and pull requests.

For example, for this feature the commit message could be "Allow to customize debug color of Path3D".

thanks that will help, I was using a message similar to the linux kernel stuff, lol.

@smix8
Copy link
Contributor

smix8 commented Sep 25, 2023

Debug is split between Editor debug and runtime debug (because the Editor is not available at runtime).

The one that you see in the Editor and also in the screenshot of the proposal is from an Editor plugin.
editor/plugins/path_2d_editor_plugin.cpp
editor/plugins/path_3d_editor_plugin.cpp

The debug that you see at runtime with the "Visible paths" debug enabled is part of the Path2D and Path3D node.
scene/2d/path_2d.cpp
scene/3d/path_3d.cpp

A debug change should be added to both Path2D and Path3D as both nodes should keep feature parity wherever possible and reasonable.

If you need some examples you could look at the NavigationAgent2D and NavigationAgent3D as both have custom path debug implemented. PR #71543 added it for the agent (there where some bug fixes since so don't copy directly).

@ywmaa
Copy link
Contributor Author

ywmaa commented Sep 25, 2023

image

@smix8
you are right, turns out I was testing them wrong.
thanks, now I can continue, and probably make this PR ready.

@ywmaa
Copy link
Contributor Author

ywmaa commented Sep 26, 2023

so while going through this, to change the color in the editor, it applies to all path3D, I think because the gizmos are just instances, is it worth it to not use instances for the same material to have custom debug color ?

@smix8
Copy link
Contributor

smix8 commented Sep 26, 2023

That is why the e.g. NavigationAgent has a "debug_use_custom" bool.

When enabled it creates its own material copy so it does not affect all other instances that share the default material for performance.

@ywmaa ywmaa changed the title Path3D: custom debug color and custom debug show Allow to customize debug color of Path3D. Sep 26, 2023
@ywmaa ywmaa marked this pull request as ready for review September 26, 2023 10:52
@ywmaa ywmaa requested review from a team as code owners September 26, 2023 10:52
@ywmaa
Copy link
Contributor Author

ywmaa commented Sep 26, 2023

I think I will add custom debug color to Path2D in a seperate PR, or should I add it in this PR too ?

@Calinou
Copy link
Member

Calinou commented Sep 26, 2023

I think I will add custom debug color to Path2D in a seperate PR, or should I add it in this PR too ?

These nodes are rendered differently, so I think it's more suited for a separate PR.

@ywmaa ywmaa force-pushed the custom_debug_color_curve3D branch from a976224 to e55578a Compare August 23, 2024 06:52
@ywmaa ywmaa changed the title Allow to customize debug color of Path3D. Allow customizing debug color of Path3D. Aug 23, 2024
@ywmaa
Copy link
Contributor Author

ywmaa commented Aug 23, 2024

Just Rebased to make this PR ready, in case the team wants to merge it for 4.4

Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

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

Tested locally, there are some issues:

  • The material used for custom colors should be unshaded, so that the shape appears at its intended color regardless of lighting conditions. Right now, the red path in the screenshot below uses #ff0000 but appears quite dark due to this:
With sky Black sky (no ambient light)
image image
  • The material used for custom colors should be transparent. This yellow path should be invisible as its alpha component is 0, but it's visible:

image

  • Paths do not get brighter when selected (or darker when unselected) like the default path color does:
Default unselected Default selected
image image
Custom unselected Custom selected
image image
  • The path color does not update immediately after you change it in the color picker (or even after pressing Enter). You need to do something else for the gizmo to update instead, but the update ought to happen as soon as possible.

  • The editor view does not match the running project view, as Show Path being unchecked is ignored in the editor. Also, the main path is not colored when running the project; only the fishbones are:

Editor Running project
image image
  • I'm not sure if there should be a Show Path option. Other nodes like RayCast2D/3D don't have it. If you want to hide a path, you can set its color to a fully transparent custom color, in which case the gizmo drawing should be skipped (to improve performance).

@ywmaa
Copy link
Contributor Author

ywmaa commented Aug 25, 2024

is there a signal or a way to hook Color property realtime change to a function ?

@ywmaa
Copy link
Contributor Author

ywmaa commented Aug 25, 2024

Ok, so I found my way (turns out when I change the color in the editor it does realtime change the Color Property, so I just emit a signal on set_custom_debug_color)

@Calinou also I have implemented what you asked in the review, you can try it out any time.

@ywmaa
Copy link
Contributor Author

ywmaa commented Aug 25, 2024

LOL, I think I did something wrong in the runtime material, the game crashes with the Path3D in the scene

@ywmaa
Copy link
Contributor Author

ywmaa commented Aug 25, 2024

Now everything should work.

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.

4 participants