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

C#: Optimize GetProcessDeltaTime() and GetPhysicsProcessDeltaTime() #74078

Conversation

neikeq
Copy link
Contributor

@neikeq neikeq commented Feb 27, 2023

Now the methods return a cached value instead of going through an internal call. I also added matching properties to reduce verbosity.

Now the methods return a cached value instead of going through an
internal call. I also added matching properties to reduce verbosity.
@neikeq neikeq added this to the 4.1 milestone Feb 27, 2023
@neikeq neikeq requested review from a team as code owners February 27, 2023 20:10
Comment on lines +431 to +432
virtual void set_physics_process_delta_time(double p_time);
virtual void set_process_delta_time(double p_time);
Copy link
Contributor Author

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.

Comment on lines +204 to +210
[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;
Copy link
Member

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;
Copy link
Member

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?

@raulsntos
Copy link
Member

@RedworkDE also mentioned in #74070 (review) that set_physics_process_delta_time and set_process_delta_time should be added to ScriptLanguageExtension.

@YuriSizov YuriSizov modified the milestones: 4.1, 4.2 Jun 14, 2023
@AThousandShips AThousandShips modified the milestones: 4.2, 4.3 Oct 26, 2023
@AThousandShips AThousandShips modified the milestones: 4.3, 4.4 Jul 25, 2024
@raulsntos
Copy link
Member

After discussing, the .NET team has decided to close this PR. Since C# is moving to GDExtension, the callbacks that are added here to ScriptLanguage would not be usable in the future C# implementation. So we either need to also add this in some form to GDExtension or this needs to be led by some scripting language other than C#.

@raulsntos raulsntos closed this Jul 29, 2024
@raulsntos raulsntos removed this from the 4.4 milestone Jul 29, 2024
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