-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Extension bindings for cast_motion
are incorrect in double-precision builds
#88720
Comments
CC @godotengine/gdextension |
My personal preference would be for |
Hm, I just built Godot with double precision and ran with JSON data {
"name": "_cast_motion",
"is_const": false,
"is_static": false,
"is_vararg": false,
"is_virtual": true,
"return_value": {
"type": "bool"
},
"arguments": [
{
"name": "shape_rid",
"type": "RID"
},
{
"name": "transform",
"type": "Transform2D"
},
{
"name": "motion",
"type": "Vector2"
},
{
"name": "margin",
"type": "float",
"meta": "double"
},
{
"name": "collision_mask",
"type": "int",
"meta": "uint32"
},
{
"name": "collide_with_bodies",
"type": "bool"
},
{
"name": "collide_with_areas",
"type": "bool"
},
{
"name": "closest_safe",
"type": "double*"
},
{
"name": "closest_unsafe",
"type": "double*"
}
]
} Are you maybe trying to use the |
Yes, that seems to be the crux here. For some reason I was under the impression that the default/bundled But alright, I suppose I can just generate a custom Is there any particular reason why the same Anyway, I'll go ahead and close this. |
Well, they are binary incompatible, the function signatures are actually different. The main consequence of this is that a number function hashes are different, but it also has an impact on virtual functions as shown here. We've discussed this a couple of times, the most recent one was here. But at a higher-level, if you're re-compiling Godot with different options than the official builds, you can end up with differences that affect compatibility (for example, some additional modules may be enabled or disabled), and so any time you're doing that, you should generate your own |
I'm very surprised that I didn't run into any issues with this at all. Everything ran just fine with no warnings or errors, and I was able to utilize the extra precision as expected. I guess it's just about hitting the right API call. |
It'd probably be a good idea add something to godot-cpp that will detect if the |
Tested versions
Reproducible in: 4.3.dev [b15105a]
System information
N/A
Issue description
PhysicsDirectBodyState3DExtension::_cast_motion
, which is overridden by a GDExtension to implementPhysicsDirectBodyState3D::cast_motion
, has the resulting safe and unsafe fractions bound usingGDExtensionPtr<real_t>
, as seen here:godot/servers/extensions/physics_server_3d_extension.h
Line 135 in b15105a
godot/servers/extensions/physics_server_2d_extension.h
Line 133 in b15105a
This unfortunately leads to
--dump-extension-api
emitting a function signature offloat*
intoextension_api.json
, presumably becausereal_t
isn't an actual nominal type, which means that even double-precision builds of a GDExtension end up implementing the function asfloat*
when in fact areal_t*
is being passed in (and moved across asvoid*
) from the Godot side of things.This then means that any result written to these fractions in double-precision builds end up garbled on the other end, leading to shape-casts being broken.
In terms of fixing this, I see the choices as being either:
GDExtensionPtr<real_t>
toGDExtensionPtr<float>
. The extra precision seems overkill for something like this anyway. This however means it will break for anyone who might be currently be casting this toreal_t*
, like myself, although I haven't actually pushed any release with this yet.GDExtensionPtr<real_t>
toGDExtensionPtr<double>
, which will then break everyprecision=single
extension build instead, as well as being a breaking change in terms of compilation (for godot-cpp).extension_api.json
to emitreal_t*
for the function signature, which would be a breaking change in terms of compilation forprecision=double
builds, but would preserve the workaround mentioned in option 1.EDIT: I suppose a 4th option could be to expose an entirely new method, like
_cast_motion2
, which usesGDExtensionPtr<double>
instead, but it seems unfortunate to leave the old broken method as-is.Steps to reproduce
N/A
Minimal reproduction project (MRP)
N/A
The text was updated successfully, but these errors were encountered: