-
-
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#: Add float delta overloads of _Process and _PhysicsProcess #74070
Conversation
Though this is late, I hope we can include it in 4.0. It's a breaking change, but it's something users complain a lot about. |
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.
The CharacterBody & Node templates need adjusting (can you even have distinct templates for a double build?)
Also set_physics_process_delta_time
and set_process_delta_time
should be added to ScriptLanguageExtension
Looks ok to me, but
- I would have left the Get(Physics)ProcessDeltaTime changes for 4.0.x
- Tho probably a giant pain to implement, It should be possible to make this change in a backwards compatible way by emitting two overload for these methods, so that the users can implement it with either a float or a double argument.
- IMO this change is unlikely to cause regressions, as long as everything still compiles
We're sadly past the window of opportunity for such changes, this should have been at least a week ago. The stable release is in a couple of days, and the published RC6 should be the final "real" release candidate, so we're not making any compat breaking changes anymore. |
I'm going to see if it's possible to go with the overload solution to not break compat. |
Despite breaking compat, I strongly prefer this PR (changing the class BaseNode : Node
{
public override void _Process(float delta) { }
}
class DerivedNode : BaseNode
{
public override void _Process(double delta) { }
}
|
3180108
to
f37c044
Compare
I've updated the PR. The latest version shouldn't break compat.
The
You shouldn't call the base of the other overload. Otherwise, it will be called twice (the To prevent the execution of a base overload, override that particular overload (overriding both works) and skip the base call.
As long as you don't use casts to call a different overload on |
Yes, but that wasn't my intention. I just want to call the base implementation which in the base class may happen to be the Hopefully this example illustrates my point better: class BaseCharacter : Character3D
{
public override void _Process(double delta)
{
MoveAndSlide();
}
}
class DerivedCharacter : BaseCharacter
{
public override void _Process(float delta)
{
Velocity = Vector3.Forward * delta;
base._Process(delta);
}
} Because the
You and I know this because we're familiar with the code. My concern is that for users this will be confusing.
Do you mean that the |
Yes, we will keep it just to avoid breaking compat. I forgot to mark it as obsolete. |
This overload reduces the need for casting the delta in order to use it in `float` operations. The `double` overload has been marked with `EditorBrowsableState.Never` to discourage its use, as it can cause confusion. The plan is to replace both with a single `real_t` version in Godot 5. The `float` overload is called right after the `double` overload.
f37c044
to
bc572ac
Compare
After discussing the PR, and the issue more broadly, we are closing this PR, since we are not planning to merge it. We understand that changing the type of the As such, we do not think the aforementioned effects on usability (namely, having to cast the Still, the community's opinion is important to us, and we are considering using the upcoming GDExtension-based API as an opportunity to switch those methods to using singles again. Footnotes |
The bindings generator is hard-coded to replace the type of the parameter from
double
toreal_t
. This means it's no longer necessary to cast the delta in order to use it infloat
operations.Math types like
Vector3
usereal_t
, so going withreal_t
instead offloat
means the solution also works for project wherereal_t
is 64-bit.The double precision version of the delta is still available through the
GetProcessDeltaTime()
andGetPhysicsProcessDeltaTime()
. I optimized the methods to return a cached value instead of going through an internal call. I also added two matching properties to reduce verbosity.Fixes godotengine/godot-proposals#5403