Prevent update_shape from being called twice on first frame, thus speeding up CSG nodes load times. #114351
+1
−0
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.
due to logic oversight, update_shape can get queued twice to run on the first frame, making scenes csg shapes laggy to open/load in, with this redundant call.
This change makes sure that it cant queue twice by marking it as dirty as soon as possible, so it cant queue again.
Found out about the double queue behavior when i was making a benching tool for csg and logging functions calls.
Where i saw that "update_shape" gets called twice on scene load.
A bit of code-base reading later, found out that "_make_dirty" 's logic can double queue it on specific but common scenario. Where its a root shape and not dirty it will call_deferred twice.
Old code: (macros removed for clarity)
by setting
dirty = true;earlier in the logic it prevents this double queue from happening and calls it once. (since the second queue up looks if dirty is false)new code: (macros removed for clarity)
With this fix, it now logs like this:
And noticeably reduces scene loading time a second or so, since update_shape can get laggy and now only calls once.