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

Custom nodes are not exposed to statically compiled languages #632

Open
nothke opened this issue Oct 6, 2023 · 5 comments
Open

Custom nodes are not exposed to statically compiled languages #632

nothke opened this issue Oct 6, 2023 · 5 comments
Labels
enhancement New feature or request topic:runtime Concerning runtime behavior (or its source code) topic:usage Concerning packaging, loading or settings

Comments

@nothke
Copy link

nothke commented Oct 6, 2023

Is it possible to use Jolt types from C#? It is impossible to inherit from JoltGeneric6DofJoint3D for example, as the type doesn't exist or I can't find the right namespace it belongs to..?

@github-actions github-actions bot added the needs triage Something that needs investigation label Oct 6, 2023
@mihe mihe added enhancement New feature or request topic:usage Concerning packaging, loading or settings topic:runtime Concerning runtime behavior (or its source code) and removed needs triage Something that needs investigation labels Oct 6, 2023
@mihe mihe changed the title Using Jolt- types from C# Custom nodes are not exposed to statically compiled languages Oct 6, 2023
@mihe
Copy link
Contributor

mihe commented Oct 6, 2023

No, this is not possible at the moment, unfortunately. This is a somewhat general problem with Godot, where bindings for statically compiled languages like C#, C++ and Rust are sort of "frozen in time" from when that build of Godot was made, and anything exposed by a GDExtension (or even GDScript as seen here) won't be available from these languages. I've been meaning to investigate this since long before I even added the Jolt-specific nodes, but I haven't gotten around to it.

My initial hope/ambition was to distribute a separate NuGet package with bindings that somehow utilize GodotObject.Get, GodotObject.Set and GodotObject.Call to at least make the interface more ergonomic, but honestly I'm not sure how well that plays out in practice. I don't think you'd be able to things like inherit from such a class in any case.

There are other alternatives as well, like the approach taken by the Debug Draw 3D extension, where the bindings are generated on-demand by the extension through an editor action and compiled along with the rest of the Godot project. I believe the circumstances for Debug Draw 3D are quite different though, in that the entirety of the API can be expressed as a static class in C#, which makes this approach a lot more feasible.

The workaround in the meantime would be to utilize things like GodotObject.Get, GodotObject.Set and GodotObject.Call yourself when interacting with these nodes from C#. I don't think there's anything like that which would let you inherit from the class, but you could always make your own wrapper for it instead I guess.

@simeonradivoev
Copy link

simeonradivoev commented Apr 16, 2024

Can you get access from a another GDExtension if not from C#?
I can't actually find info on how to communicate between GDExtensions if any 🤔

@mihe
Copy link
Contributor

mihe commented Apr 16, 2024

Assuming your GDExtension is written in C, C++ or Rust, or any other statically compiled language, you'd have the exact same issue, and you would need to use Object::get, Object::set and Object::call to interact with any of the custom nodes.

If it's written in some dynamic language like Python or Lua (that isn't relying on bindings generated by extension_api.json) it might be a different story, but I'm not familiar enough with the scripting side of GDExtension to really say for sure.

And just be clear, you can still use this extension just fine to power all the default Godot nodes (RigidBody3D, Generic6DOFJoint, etc.) which you can obviously interact with just fine from another GDExtension, but using the substitute joints (JoltGeneric6DOFJoint, etc.) won't be very ergonomic unfortunately.

@simeonradivoev
Copy link

I'm new to the GDExtensions, but how do different GDExtensions communicate typically? My thinking was if there was a way to access the more advanced features of jolt, for example the simulation rollback.

@mihe
Copy link
Contributor

mihe commented Apr 21, 2024

There is no such channel of communication between extensions, official or otherwise. The only public symbol that's exposed from the DLL is the extension entry point, which then registers the physics server, the custom nodes, the editor plugin, etc.

Rollback in particular is also not something you'll be likely to achieve by just exposing the underlying Jolt stuff to some other extension. See this comment for more details as to why.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request topic:runtime Concerning runtime behavior (or its source code) topic:usage Concerning packaging, loading or settings
Projects
None yet
Development

No branches or pull requests

3 participants