Skip to content

Implement Rid #102

@tengkuizdihar

Description

@tengkuizdihar

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...

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: coreCore componentsfeatureAdds functionality to the library

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions