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

Add a way to add extra functionality to built-in classes using GDExtension #9957

Open
peachey2k2 opened this issue Jun 13, 2024 · 2 comments

Comments

@peachey2k2
Copy link

peachey2k2 commented Jun 13, 2024

Describe the project you are working on

TL;DR: The built-in tween system doesn't work for me and I want to implement my own into every class. I tinkered with it a bit, but it didn't go anywhere.

First of all, I'm not very experienced with C++ nor GDExtension. There might be a way to do this. If so, sorry.

I'm working on some sort of a video editor plugin. Basically, the idea is that instead of separate video files, the user can use built-in nodes in Godot. I also want to make it so each node can decide when to do what, using a tween-like system. I can't use the built-in tween system for reasons such as:

  1. They're one-time use, meaning the preview panel would be super buggy.
  2. They aren't customizable enough for my purposes.
  3. They aren't very efficient in mass quantities.

This isn't a problem for me, I had already made a tween system in the past for another project. The problem is I couldn't figure out a way to add it to the engine. I basically want to add a function into the Object class, so that it can be inherited by any other class. I then would have a class with access to that object, along with everything exposed within it. To do this however, I messed around with it quite a lot, mainly with #include_next, but couldn't get it to work in any way.

Describe the problem or limitation you are having in your project

I want to add a new function into the built-in Object class, so that it can be used in any other class. I recall doing something similar in C#, but couldn't find a way in here.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

As opposed to C#, there is no partial keyword in C++ (thanks Bjarne Stroustrup). I can't really think of a way to get through that. Perhaps a way to bind methods to any class would work.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Like how we bind methods like how we do it right now, but for any class. I don't really have an idea how that'd work in code though.

If this enhancement will not be used often, can it be worked around with a few lines of script?

No as far as I know.

Is there a reason why this should be core and not an add-on in the asset library?

Yes, there could be a lot of use cases for something like this.

@Calinou Calinou changed the title Add a way to add extra functionality to built-in classes using GDExtension. Add a way to add extra functionality to built-in classes using GDExtension Jun 13, 2024
@Zireael07
Copy link

Another use case would be extending the built in Geometry or Astar, to better handle graphs

@AThousandShips
Copy link
Member

AThousandShips commented Jun 14, 2024

Related:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants