godot icon indicating copy to clipboard operation
godot copied to clipboard

Fix non const animation node `_process` virtual function

Open GuilhermeGSousa opened this issue 1 year ago • 3 comments
trafficstars

Quick fix for https://github.com/godotengine/godot/issues/74807

I'm working on a motion matching implementation, and am currently improving its API. I currently think the best way to do this by extending AnimationRootNode, but the docs mention the _process method is deprecated, and that many APIs are missing to be able to extend animation nodes. I guess my question is, is this the case? If so, is there anything planned to support this in coming releases?

  • Bugsquad edit, closes: https://github.com/godotengine/godot/issues/74807

GuilhermeGSousa avatar Sep 14 '24 22:09 GuilhermeGSousa

I'm not seeing how I can register compatibility methods for GDVIRTUAL functions, is that implementer?

Also, how do changes to the C++ bindings work? Is extension_api.json automatically updated, or should I open a PR for that?

GuilhermeGSousa avatar Sep 15 '24 06:09 GuilhermeGSousa

I'm not seeing how I can register compatibility methods for GDVIRTUAL functions, is that implementer?

There is no way to safely change a virtual method in a binary compatible way. Instead, you need to add a new virtual method under a new name, and then selectively call whichever one is implemented (usually preferring the new one first). You can check if a virtual method is implemented via the GDVIRTUAL_IS_OVERRIDDEN() macro

dsnopek avatar Oct 05 '24 17:10 dsnopek

Actually, looking at the PR in more detail, I'm not sure changing const-ness actually breaks compatibility. It may be fine. Someone should test if a GDExtension that overrides this virtual method compiled for Godot 4.3 works fine when loaded into Godot compiled with this PR.

dsnopek avatar Oct 05 '24 17:10 dsnopek

@dsnopek Thanks for your reply, sorry I got to this so late. I can give that a try as I'm working on one such GDExtension, I'll get back to you on that.

GuilhermeGSousa avatar Oct 14 '24 11:10 GuilhermeGSousa

@dsnopek just tested what you suggested, loading a GDExtension that overrides the const version of this method, on godot compiled with these changes. Works great, no errors!

GuilhermeGSousa avatar Oct 14 '24 13:10 GuilhermeGSousa

The commits will need to be squashed before this can be merged.

Repiteo avatar Oct 25 '24 17:10 Repiteo

Thanks!

Repiteo avatar Oct 30 '24 00:10 Repiteo