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

Clarify expected types in RayCast3D documentation #101373

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jburt137
Copy link

@jburt137 jburt137 commented Jan 9, 2025

Updating documentation, per #100139 (comment)

rburing
on Dec 7, 2024
Member
Yes, the documentation is wrong (too narrow). In addition to CSG there's also GridMap. Fixes to the documentation are welcome.

@jburt137 jburt137 requested a review from a team as a code owner January 9, 2025 22:23
@AThousandShips AThousandShips changed the title Update RayCast3D.xml per Issue #100139 Clarify expected types in RayCast3D documentation Jan 10, 2025
@AThousandShips AThousandShips added bug documentation cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release cherrypick:4.3 Considered for cherry-picking into a future 4.3.x release labels Jan 10, 2025
@AThousandShips AThousandShips added this to the 4.4 milestone Jan 10, 2025
@@ -44,7 +44,7 @@
<method name="get_collider" qualifiers="const">
<return type="Object" />
<description>
Returns the first object that the ray intersects, or [code]null[/code] if no object is intersecting the ray (i.e. [method is_colliding] returns [code]false[/code]).
Returns the first object that the ray intersects, or [code]null[/code] if no object is intersecting the ray (i.e. [method is_colliding] returns [code]false[/code]). This object is not guaranteed to be a [CollisionObject3D]. For example, if the ray intersects a [CSGShape3D] or a [GridMap], the method will return a [CSGShape3D] instance or [GridMap] instance. To validate and ensure type safety, you should explicitly check the type of the returned object before casting.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Returns the first object that the ray intersects, or [code]null[/code] if no object is intersecting the ray (i.e. [method is_colliding] returns [code]false[/code]). This object is not guaranteed to be a [CollisionObject3D]. For example, if the ray intersects a [CSGShape3D] or a [GridMap], the method will return a [CSGShape3D] instance or [GridMap] instance. To validate and ensure type safety, you should explicitly check the type of the returned object before casting.
Returns the first object that the ray intersects, or [code]null[/code] if no object is intersecting the ray (i.e. [method is_colliding] returns [code]false[/code]).
[b]Note:[/b] This object is not guaranteed to be a [CollisionObject3D]. For example, if the ray intersects a [CSGShape3D] or a [GridMap], the method will return a [CSGShape3D] or [GridMap] instance.

Casting is a kind of type testing, also I don't think an explicit comment is needed, but if it is added it should be more brief

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="RayCast3D" inherits="Node3D" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
A ray in 3D space, used to find the first [CollisionObject3D] it intersects.
A ray in 3D space, used to find the first [Object] or [CollisionObject3D] it intersects.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A ray in 3D space, used to find the first [Object] or [CollisionObject3D] it intersects.
A ray in 3D space, used to find the first object it intersects.

Let's remove any reference to avoid confusion

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="RayCast3D" inherits="Node3D" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
A ray in 3D space, used to find the first [CollisionObject3D] it intersects.
A ray in 3D space, used to find the first [Object] or [CollisionObject3D] it intersects.
</brief_description>
<description>
A raycast represents a ray from its origin to its [member target_position] that finds the closest [CollisionObject3D] along its path, if it intersects any.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The long description needs to be updated as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release cherrypick:4.3 Considered for cherry-picking into a future 4.3.x release documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RayCast3D.get_collider does not return a CollisionShape3D
2 participants