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

[Bullet] RayCast.get_collider_shape() doesn't actually return Shape ID #37985

Closed
Tracked by #39876
manglemix opened this issue Apr 18, 2020 · 4 comments
Closed
Tracked by #39876

Comments

@manglemix
Copy link

Godot_v3.2-stable_win64

Windows 10 version 1809

The documentation states that RayCast.get_collider.shape() returns the Shape ID of the CollisionShape that the RayCast intersected. However, it doesn't seem to return the correct number.

var target = $RayCast.get_collider()
var shape = target.shape_owner_get_owner(target.shape_find_owner($RayCast.get_collider_shape()))

The above code in my project causes this error:
E 0:00:06.707 shape_find_owner: Index p_shape_index = 522 is out of bounds (total_subshapes = 1).
<C++ Source> scene/3d/collision_object.cpp:328 @ shape_find_owner()
Bullet.gd:54 @ _process()

After asking for help in the Godot Discord Server, a Godot dev suggested that get_collider_shape() was returning the Shape RID instead. They suggested I check by using Godot Physics Engine, which after testing caused no errors

@akien-mga
Copy link
Member

This should either be clarified in the documentation (s/ID/RID/), or the API could be changed so that it actually returns the shape index.

It might be worth making things consistent with KinematicCollision's API:

scene/3d/physics_body.cpp
1487:Object *KinematicCollision::get_collider_shape() const {
1500:int KinematicCollision::get_collider_shape_index() const {

While noting that in 2D there's also:

servers/physics_2d_server.cpp
495:int Physics2DTestMotionResult::get_collider_shape() const {

which I think returns a shape index, but I didn't check.

@pouleyKetchoupp pouleyKetchoupp changed the title RayCast.get_collider_shape() doesn't actually return Shape ID [Bullet] RayCast.get_collider_shape() doesn't actually return Shape ID Jan 15, 2021
@pouleyKetchoupp
Copy link
Contributor

Seems like it's the same as #39767, fixed in #42881

@JakSparro98
Copy link

@pouleyKetchoupp I want to report that there's still an issue in Godot 3.3.3 with spaceState.IntersectRay's way of raycasting, the "shape" key doesn't return the correct id with Bullet (the raycast node counterpart seems to not have this problem though).

@pouleyKetchoupp
Copy link
Contributor

pouleyKetchoupp commented Oct 7, 2021

@JakSparro98 Indeed, the issue actually still exists for raycasts. It was reported again in #47989 with a minimal test project so I'll leave that one open.

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

5 participants