[rcore] Screen/world-space related functions consistency
Screen-to-world and world-to-screen related functions look a bit inconsistent in naming at this moment, they should be reviewed.
Recently, GetViewRay() (temporal name) was added (https://github.com/raysan5/raylib/pull/3709) to allow screen-to-world ray retrieval, mostly intended for mouse position to ray for a custom viewport.
Checking all related functions, they look a bit unconsistent in naming, also some functions could be missing:
// Screen-space-related functions
RLAPI Ray GetMouseRay(Vector2 mousePosition, Camera camera); // Get a ray trace from mouse position
RLAPI Ray GetViewRay(Vector2 mousePosition, Camera camera, float width, float height); // Get a ray trace from mouse position in a viewport
RLAPI Vector2 GetWorldToScreen(Vector3 position, Camera camera); // Get the screen space position for a 3d world space position
RLAPI Vector2 GetWorldToScreenEx(Vector3 position, Camera camera, int width, int height); // Get size position for a 3d world space position
RLAPI Vector2 GetWorldToScreen2D(Vector2 position, Camera2D camera); // Get the screen space position for a 2d camera world space position
RLAPI Vector2 GetScreenToWorld2D(Vector2 position, Camera2D camera); // Get the world space position for a 2d camera screen space position
RLAPI Matrix GetCameraMatrix(Camera camera); // Get camera transform matrix (view matrix)
RLAPI Matrix GetCameraMatrix2D(Camera2D camera); // Get camera 2d transform matrix
That naming should be probably reviewed for consistency (potential breaking change). Other frameworks/engines could be checked for reference (Unity API is usually very good at naming).
Some possible renames for consistency:
-
GetMouseRay()-->GetScreenToWorldRay() -
GetViewRay()-->GetScreenToWorldRayEx()
Name seems more technically correct but maybe more confusing to users?
I believe the possible renames are good.
Unity has this methods: ScreenToWorldPoint, WorldToScreenPoint
https://docs.unity3d.com/ScriptReference/Camera.ScreenToWorldPoint.html https://docs.unity3d.com/ScriptReference/Camera.WorldToScreenPoint.html
WorldToScreenPoint corresponds to raylib GetWorldToScreen Do we want a GetScreenToWorld similar to unity ScreenToWorldPoint ?
It's confusing to have an official example using a function that has not yet been released (Picking in 3d mode example).
Especially when the 'last time updated with raylib 4.0' that did not have the changed name.
I couldn't compile with w64devkit because it's using 5.0.