-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
[Mono] Plane intersect methods returning Vector3(0, 0, 0) #32614
Comments
Could we make it return |
|
Another option, if we want to use purely value types, is to return I prefer nullable types to bool with out. |
I agree with Zylann about either for Nullable or returning bool with an out parameter since these seem to be basically self documenting. Nullable seems a little better since it's essentially a 1 to 1 equivalent with GDScript. |
I would prefer the bool and out way too. |
Nullable or bool/out are the most idiosyncratic ways to do this in C# so it should probably be one of these two. I can't think of any real pro/cons between the two so it seems like a purely stylistic difference. Returning a Vector3? (i.e. the nullable type) would more closely match the gdscript API. The other ideas involving INF or NaN just seem awkward and weird as a longtime C# dev. |
@mwerezak Agreed, the PR I opened uses |
Godot version:
3.1.1
OS/device including version:
Windows 10
Issue description:
Per the documentation at https://docs.godotengine.org/en/3.1/classes/class_plane.html Plane.intersect_3, Plane.intersect_ray and Plane.intersect_segment will return null if no intersection is found. However, in C#/Mono, value types cannot be null, so instead these methods return Vector3(0, 0, 0). This isn't good, since (0, 0, 0) could be a valid intersection point but we have no way to know if it was the actual intersection or an invalid result. A better result might be to return Vector3(float.NaN, float.NaN, float.NaN).
Steps to reproduce:
Try to use any of these three methods from C# using data which won't actually intersect. You can use Intersect3 with planes:
(0, 0, 1), 0
(0, 0, 1), 1
[any other plane]
The text was updated successfully, but these errors were encountered: