godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.16k stars 97 forks source link

Make intersect_shape return Position and Normal #8667

Open eddieataberk opened 11 months ago

eddieataberk commented 11 months ago

Describe the project you are working on

A game uses intersect_shape

Describe the problem or limitation you are having in your project

Unlike intersact_ray, intersect_shape does not return position calling collide_shape to get positions separately is not intuitive or optimal. get_rest_info returns the point and normal of the first collision but currently, there is no way to get normals of other collisions.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Match the dictionaries in intersact_shape with the dictionary from get_rest_info

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

collider_id: The colliding object's ID.

_# Just copy/pasted from get_rest_into linearvelocity is not necessary since we can get this value in different ways. _linearvelocity: The colliding object's velocity Vector3. If the object is an Area3D, the result is (0, 0, 0).

normal: The object's surface normal at the intersection point.

point: The intersection point.

rid: The intersecting object's RID.

shape: The shape index of the colliding shape.

If this enhancement will not be used often, can it be worked around with a few lines of script?

No

Is there a reason why this should be core and not an add-on in the asset library?

this is about core engine functions

AThousandShips commented 11 months ago

How would this work? There isn't any guarantee that such a position exists. Intersection of shapes works with an incremental step, not an exact solution

eddieataberk commented 11 months ago

How would this work? There isn't any guarantee that such a position exists. Intersection of shapes works with an incremental step, not an exact solution

maybe add another method that would return the exact solution? how does get_rest_info and collide_shape works?

AThousandShips commented 11 months ago

My bad missed that the intersect_shape doesn't do motion, so not relevant in that way, but you can just use collide_shape to get this data and then extract the normal from the shape no? Or get_rest_info with excluding the shapes you don't want from the intersect_shapes call

I think the method is intentionally simple, the ray one differs because rays are much simpler