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

get_collision_face_index() is not implemented #268

Open
maylokana opened this issue Oct 5, 2024 · 3 comments
Open

get_collision_face_index() is not implemented #268

maylokana opened this issue Oct 5, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@maylokana
Copy link

Describe the bug

RayCast3D's get_collision_face_index() doesn't work at all
I tested this with the .NET build and originally stumbled across it with C# scripts, but it seems to be non-functional with GDScript as well. Code works perfectly fine with in-built physics

To Reproduce

  1. Create a StaticBody3D attached with a ConcavePolygonShape3D
  2. Create a RayCast3D
  3. Use the raycast's get_collision_face_index() function

Expected behavior

Please don't make me say "get_collision_face_index() didn't work" because I'm going to say that it did this and always returned -1

Environment:

  • OS: Windows 10 22H2
  • Version v0.8.5
  • Godot Version: 4.3.stable.mono
  • Type 3d-single-enchanced-determinism

Example project(zip)

Written in GDScript to test non-mono builds
raytouchy-example.zip

@maylokana maylokana added the bug Something isn't working label Oct 5, 2024
@Ughuuu Ughuuu added enhancement New feature or request and removed bug Something isn't working labels Oct 5, 2024
@Ughuuu
Copy link
Contributor

Ughuuu commented Oct 5, 2024

Seems like the face_id is not implemented, it will always be -1. Needs impl. Function docs: https://docs.godotengine.org/en/stable/classes/class_raycast3d.html#class-raycast3d-method-get-collision-face-index

Rapier exposes at raycast a property that can be used for this:

/// Feature at the intersection point.
pub feature: FeatureId,

Sending this out from callback and then sending it out for callback could be a solution to this.

The feature returned is of type:

#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, Default)]
pub enum FeatureId {
    /// Shape-dependent identifier of a vertex.
    Vertex(u32),
    #[cfg(feature = "dim3")]
    /// Shape-dependent identifier of an edge.
    Edge(u32),
    /// Shape-dependent identifier of a face.
    Face(u32),
    // XXX: remove this variant.
    /// Unknown identifier.
    #[default]
    Unknown,
}

Then there is also making sure the shape is in sync between rapier and godot(which should be the case). If such returning the id should work, however it seems rapier knows if its a vertex, edge or face. So we need to convert somehow from that to face at all times(maybe iterating through all faces and check if the edge or vertex is part of a face).

Note:
Is the question template thing too official sounding or a problem? I think its just a generic one, didnt think much about it.(about the expected behaviour comment you said)

@maylokana
Copy link
Author

maylokana commented Oct 5, 2024

Is the question template thing too official sounding or a problem?

I don't mind it, it's just that I wasn't necessarily writing a bug report and didn't know how to put down a missing feature or other issue. Apologies if it seemed like I was frustrated about it

@Ughuuu Ughuuu changed the title get_collision_face_index() is nonfunctional get_collision_face_index() is not implemented Oct 6, 2024
@Ughuuu
Copy link
Contributor

Ughuuu commented Oct 6, 2024

Is the question template thing too official sounding or a problem?

I don't mind it, it's just that I wasn't necessarily writing a bug report and didn't know how to put down a missing feature or other issue. Apologies if it seemed like I was frustrated about it

No problem. You didn't seem frustrated, no worries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants