Skip to content

Conversation

@smix8
Copy link
Contributor

@smix8 smix8 commented Jun 8, 2025

Improves NavigationAgent2D debug performance by using static mesh and multimesh.

The old debug used the classic canvas draw functions for line segments and rects. Those are really inefficient for longer paths due to each creating either a new internal throwaway mesh or a new draw command.

This PR changes the agent path debug to a single static mesh for all the line segments, aka a single draw.
All the path points reuse a single rect mesh that is rendered with a multimesh.

Should be a net-gain for all projects but projects with a lot of agents and longer path stability (aka not querying a new path every frame like a madman) will see the biggest performance boost by this change.

Since line width is not supported by mesh line primitives (and never worked great to begin with on a lot of hardware) the option is deprecated and hidden from the inspector.

@smix8 smix8 requested review from a team as code owners June 8, 2025 19:11
@smix8 smix8 added this to the 4.5 milestone Jun 8, 2025
@smix8 smix8 force-pushed the navagent2d_debug_perf branch 2 times, most recently from f08290e to 02c5dec Compare June 8, 2025 20:07
Comment on lines 161 to 162
<member name="debug_path_custom_line_width" type="float" setter="set_debug_path_custom_line_width" getter="get_debug_path_custom_line_width" default="-1.0" deprecated="Deprecated and has no effect.">
Deprecated.
Copy link
Member

Choose a reason for hiding this comment

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

IMO deprecated APIs in principle should still be functional, they are just flagged as not recommended anymore (and under the risk of later removal). An API that's outright removed/unsupported would be "obsoleted", and that's not a concept we use because at that point we might as well just remove it.

While looking for deprecation vs obsolescence definitions though, I found https://github.com/mdn/content/blob/main/files/en-us/mdn/writing_guidelines/experimental_deprecated_obsolete/index.md?plain=1#L38-L50 where the descriptions match my understanding but it seems they also stopped using "obsolete".

Copy link
Contributor Author

@smix8 smix8 Jun 8, 2025

Choose a reason for hiding this comment

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

From my point of view it can be removed. I just want to avoid that the hypothetical project that edits this property (I dont know any) runs into a script error instead of a depr warning or creates an issue not knowing why their line width is no longer working. Maybe it should be "obsoleted" for one version as a warning and removed in the next. In the linked example it reads "and may still work" so that depr stuff always works is at least not part of their definition.

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<member name="debug_path_custom_line_width" type="float" setter="set_debug_path_custom_line_width" getter="get_debug_path_custom_line_width" default="-1.0" deprecated="Deprecated and has no effect.">
Deprecated.
<member name="debug_path_custom_line_width" type="float" setter="set_debug_path_custom_line_width" getter="get_debug_path_custom_line_width" default="-1.0" deprecated="Deprecated and has no effect.">
This property does nothing.

And, instead of "Deprecated and has no effect." it needs an actual proper explanation as to why that is, as well as providing alternatives.

Copy link
Contributor Author

@smix8 smix8 Jun 10, 2025

Choose a reason for hiding this comment

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

There is no alternative as mentioned in the description as the mesh rendering does not support line width. The width is controlled by the "hardware" and always the same thin width no matter the display or zoom level. See PR #105606 for Path2D that does the same and has images to show what is the issue with this canvas item line width and why it is so bad for debug (apart from performance) for displays and zoom levels that are not super vanilla.

Copy link
Member

@Mickeon Mickeon Jun 10, 2025

Choose a reason for hiding this comment

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

Then, as the worst case scenario, omit the message, like deprecated="". It's not actually obligatory.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Improves NavigationAgent2D debug performance by using static mesh and multimesh.
@smix8 smix8 force-pushed the navagent2d_debug_perf branch from 02c5dec to 1c9bc22 Compare June 10, 2025 10:45
@Repiteo Repiteo modified the milestones: 4.5, 4.x Jun 16, 2025
@smix8 smix8 removed this from the 4.x milestone Jul 24, 2025
@smix8 smix8 closed this Jul 24, 2025
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