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

Implement Rid #102

Closed
tengkuizdihar opened this issue Jan 31, 2023 · 4 comments · Fixed by #171
Closed

Implement Rid #102

tengkuizdihar opened this issue Jan 31, 2023 · 4 comments · Fixed by #171
Labels
c: core Core components feature Adds functionality to the library

Comments

@tengkuizdihar
Copy link

tengkuizdihar commented Jan 31, 2023

Original title: Creating A New Class From PhysicsServer3DExtension

Right now I'm trying to port Rapier Physics Engine to Godot 4 using PhysicsServer3DExtension. I have seen an example of this class in the wild with https://github.com/godot-jolt/godot-jolt/blob/HEAD/src/register_types.cpp#L28, but does anyone know the equivalent in rust gdextension?

So far I got to this point, with errors all over the place.

#[derive(GodotClass)]
#[class(base=PhysicsServer3DExtension)]
pub struct RapierPhysicsServer3D {
    #[base]
    base: Base<PhysicsServer3DExtension>,
}

#[godot_api]
impl RapierPhysicsServer3D {
}

This is the error log I got from cargo build

error[E0599]: the function or associated item `property_info` exists for tuple `(godot::prelude::Rid,)`, but its trait bounds were not satisfied
   --> examples/dodge-the-creeps/rust/src/main_scene.rs:172:1
    |
172 | #[godot_api]
    | ^^^^^^^^^^^^ function or associated item cannot be called on `(godot::prelude::Rid,)` due to unsatisfied trait bounds
    |
   ::: /home/notroot/programming/gdextension/godot-core/src/builtin/others.rs:25:1
    |
25  | impl_builtin_stub!(Rid, OpaqueRid);
    | ----------------------------------
    | |
    | doesn't satisfy `_: godot::prelude::meta::VariantMetadata`
    | doesn't satisfy `godot::prelude::Rid: Debug`
    | doesn't satisfy `godot::prelude::Rid: godot::prelude::ToVariant`
    |
    = note: the following trait bounds were not satisfied:
            `godot::prelude::Rid: godot::prelude::meta::VariantMetadata`
            which is required by `(godot::prelude::Rid,): godot::prelude::meta::SignatureTuple`
            `godot::prelude::Rid: godot::prelude::ToVariant`
            which is required by `(godot::prelude::Rid,): godot::prelude::meta::SignatureTuple`
            `godot::prelude::Rid: Debug`
            which is required by `(godot::prelude::Rid,): godot::prelude::meta::SignatureTuple`
    = note: this error originates in the macro `$crate::gdext_register_method_inner` which comes from the expansion of the attribute macro `godot_api` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0599]: the function or associated item `param_metadata` exists for tuple `(godot::prelude::Rid,)`, but its trait bounds were not satisfied
   --> examples/dodge-the-creeps/rust/src/main_scene.rs:172:1
    |
172 | #[godot_api]
    | ^^^^^^^^^^^^ function or associated item cannot be called on `(godot::prelude::Rid,)` due to unsatisfied trait bounds
    |
   ::: /home/notroot/programming/gdextension/godot-core/src/builtin/others.rs:25:1
    |
25  | impl_builtin_stub!(Rid, OpaqueRid);
    | ----------------------------------
    | |
    | doesn't satisfy `_: godot::prelude::meta::VariantMetadata`
    | doesn't satisfy `godot::prelude::Rid: Debug`
    | doesn't satisfy `godot::prelude::Rid: godot::prelude::ToVariant`
    |
    = note: the following trait bounds were not satisfied:
            `godot::prelude::Rid: godot::prelude::meta::VariantMetadata`
            which is required by `(godot::prelude::Rid,): godot::prelude::meta::SignatureTuple`
            `godot::prelude::Rid: godot::prelude::ToVariant`
            which is required by `(godot::prelude::Rid,): godot::prelude::meta::SignatureTuple`
            `godot::prelude::Rid: Debug`
            which is required by `(godot::prelude::Rid,): godot::prelude::meta::SignatureTuple`
    = note: this error originates in the macro `$crate::gdext_register_method_inner` which comes from the expansion of the attribute macro `godot_api` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `godot::prelude::Rid: godot::prelude::meta::VariantMetadata` is not satisfied
   --> examples/dodge-the-creeps/rust/src/main_scene.rs:172:1
    |
172 | #[godot_api]
    | ^^^^^^^^^^^^ the trait `godot::prelude::meta::VariantMetadata` is not implemented for `godot::prelude::Rid`
    |
    = help: the following other types implement trait `godot::prelude::meta::VariantMetadata`:
              ()
              InstanceId
              Variant
              bool
              f32
              f64
              godot::prelude::Array
              godot::prelude::Color
            and 26 others
    = note: required for `(godot::prelude::Rid,)` to implement `godot::prelude::meta::SignatureTuple`
    = note: this error originates in the macro `$crate::gdext_register_method_inner` which comes from the expansion of the attribute macro `godot_api` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: `godot::prelude::Rid` doesn't implement `Debug`
   --> examples/dodge-the-creeps/rust/src/main_scene.rs:172:1
    |
172 | #[godot_api]
    | ^^^^^^^^^^^^ `godot::prelude::Rid` cannot be formatted using `{:?}` because it doesn't implement `Debug`
    |
    = help: the trait `Debug` is not implemented for `godot::prelude::Rid`
    = help: the following other types implement trait `godot::prelude::meta::SignatureTuple`:
              (R, P0)
              (R, P0, P1)
              (R, P0, P1, P2)
              (R, P0, P1, P2, P3)
              (R, P0, P1, P2, P3, P4)
              (R, P0, P1, P2, P3, P4, P5)
              (R, P0, P1, P2, P3, P4, P5, P6)
              (R, P0, P1, P2, P3, P4, P5, P6, P7)
            and 3 others
    = note: required for `(godot::prelude::Rid,)` to implement `godot::prelude::meta::SignatureTuple`
    = note: this error originates in the macro `$crate::gdext_register_method_inner` which comes from the expansion of the attribute macro `godot_api` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `godot::prelude::Rid: EngineEnum` is not satisfied
   --> examples/dodge-the-creeps/rust/src/main_scene.rs:172:1
    |
172 | #[godot_api]
    | ^^^^^^^^^^^^ the trait `EngineEnum` is not implemented for `godot::prelude::Rid`
    |
    = help: the following other types implement trait `EngineEnum`:
              ASTCFormat
              ActionMode
              ActionType
              AdvanceMode
              AfterGUIInput
              AlphaAntiAliasing
              AlphaMode
              AmbientMode
            and 599 others
    = note: required for `godot::prelude::Rid` to implement `godot::prelude::ToVariant`
    = note: required for `(godot::prelude::Rid,)` to implement `godot::prelude::meta::SignatureTuple`
    = note: this error originates in the macro `$crate::gdext_register_method_inner` which comes from the expansion of the attribute macro `godot_api` (in Nightly builds, run with -Z macro-backtrace for more info)

Some errors have detailed explanations: E0277, E0599.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `dodge-the-creeps` due to 9 previous errors
warning: build failed, waiting for other jobs to finish...
@lilizoey
Copy link
Member

I tried this myself, but gdextension is still missing two main features to make this possible:

  1. A proper implementation of RID (though this can be worked around)
  2. The ability to overload arbitrary virtual methods. For the physicsservers you need to overload all the virtual methods defined in the extension-classes, which is currently not supported.

If you still wanna try to make this work you'll likely need to modify gdextension itself until proper support for at least arbitrary virtual methods is added.

@Bromeon Bromeon added bug c: register Register classes, functions and other symbols to GDScript labels Feb 1, 2023
@tengkuizdihar
Copy link
Author

understandable, this is itching for me to solve, but I'll probably ask in discord for what could be done. Also, why is RID aren't supported yet, I thought it's basically just a regular UID?

@Bromeon
Copy link
Member

Bromeon commented Feb 1, 2023

Also, why is RID aren't supported yet, I thought it's basically just a regular UID?

It's a bit trickier if you also consider safety, see documentation of Rid in GDNative.

But even apart from that, the library is currently in an early experimental stage, as advertised in the ReadMe. A lot of things are not implemented.

@Bromeon Bromeon changed the title Creating A New Class From PhysicsServer3DExtension Implement Rid Feb 5, 2023
@Bromeon
Copy link
Member

Bromeon commented Feb 5, 2023

I'll keep this issue around to track Rid implementation progress.

@Bromeon Bromeon added feature Adds functionality to the library c: core Core components and removed bug c: register Register classes, functions and other symbols to GDScript labels Feb 5, 2023
@bors bors bot closed this as completed in 1dcbc40 Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: core Core components feature Adds functionality to the library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants