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

shape_collide and body_collide_shape from IPhysicsServer2DExtension gives compilation error #677

Open
Ughuuu opened this issue Apr 26, 2024 · 2 comments
Labels
bug c: register Register classes, functions and other symbols to GDScript

Comments

@Ughuuu
Copy link
Contributor

Ughuuu commented Apr 26, 2024

The following 2 functions:

#[godot_api]
impl IPhysicsServer2DExtension for RapierPhysicsServer2D {
...
    unsafe fn shape_collide(&mut self, shape_A: Rid, xform_A: Transform2D, motion_A: Vector2, shape_B: Rid, xform_B: Transform2D, motion_B: Vector2, results: * mut c_void, result_max: i32, result_count: * mut i32,) -> bool {
        false
    }

    unsafe fn body_collide_shape(&mut self, body: Rid, body_shape: i32, shape: Rid, shape_xform: Transform2D, motion: Vector2, results: * mut c_void, result_max: i32, result_count: * mut i32,) -> bool {
    }
...
}

When implemented to a IPhysicsServer2DExtension gives the following error:

17 | #[godot_api]
   | ^^^^^^^^^^^^ the trait `ToGodot` is not implemented for `*mut i32`, which is required by `(bool, godot::prelude::Rid, godot::prelude::Transform2D, godot::prelude::Vector2, godot::prelude::Rid, godot::prelude::Transform2D, godot::prelude::Vector2, *mut c_void, i32, *mut i32): PtrcallSignatureTuple`
   |
   = help: the trait `ToGodot` is implemented for `i32`
   = note: required for `(bool, Rid, Transform2D, Vector2, Rid, Transform2D, Vector2, *mut c_void, i32, *mut i32)` to implement `PtrcallSignatureTuple`
@lilizoey lilizoey added bug c: register Register classes, functions and other symbols to GDScript labels Apr 26, 2024
@lilizoey
Copy link
Member

This happens because we only implement ToGodot/FromGodot for native class pointers, but not primitive pointers even if they show up in parameters of functions. as a simple fix we could just manually implement this, but a more proper long term fix would be to have the codegen find all used pointer types and automatically implement the traits for them.

@lilizoey
Copy link
Member

from what i can tell, these are the pointers used which i think dont have the trait impls:

*mut *const u8
*mut i32
*mut f64
*mut u8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug c: register Register classes, functions and other symbols to GDScript
Projects
None yet
Development

No branches or pull requests

2 participants