-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
C#: Optimize GetProcessDeltaTime() and GetPhysicsProcessDeltaTime() #74078
C#: Optimize GetProcessDeltaTime() and GetPhysicsProcessDeltaTime() #74078
Conversation
Now the methods return a cached value instead of going through an internal call. I also added matching properties to reduce verbosity.
virtual void set_physics_process_delta_time(double p_time); | ||
virtual void set_process_delta_time(double p_time); |
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 thought of using the process_frame
and physics_frame
signals, but our callback needs to have priority, as we want the delta time to be updated before the other callbacks are called.
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
[SuppressMessage("Performance", "CA1822:Mark members as static")] | ||
public partial double GetPhysicsProcessDeltaTime() => CachedPhysicsProcessDeltaTime; | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
[SuppressMessage("Performance", "CA1822:Mark members as static")] | ||
public partial double GetProcessDeltaTime() => CachedProcessDeltaTime; |
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.
Should we hide/deprecate these methods in favor of the properties?
@@ -112,6 +113,7 @@ struct ManagedCallbacks { | |||
FuncDelegateUtils_TrySerializeDelegateWithGCHandle DelegateUtils_TrySerializeDelegateWithGCHandle; | |||
FuncDelegateUtils_TryDeserializeDelegateWithGCHandle DelegateUtils_TryDeserializeDelegateWithGCHandle; | |||
FuncScriptManagerBridge_FrameCallback ScriptManagerBridge_FrameCallback; | |||
FuncScriptManagerBridge_SetProcessDeltaTime ScriptManagerBridge_SetProcessDeltaTime; |
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.
Forgot to add CHECK_CALLBACK_NOT_NULL
to gd_mono_cache.cpp
?
@RedworkDE also mentioned in #74070 (review) that |
After discussing, the .NET team has decided to close this PR. Since C# is moving to GDExtension, the callbacks that are added here to |
Now the methods return a cached value instead of going through an internal call. I also added matching properties to reduce verbosity.