5 Commits

Author SHA1 Message Date
debc1f6b1f [rcore] Fix GetFileExtension() returning the name of hidden files in a directory (#6326)
Since the extension is searched in the file name only, the check for
a leading dot must compare against the file name rather than the full
path: "assets/.gitignore" returned ".gitignore" while ".gitignore"
returned NULL.
2026-10-25 10:03:51 +01:00
aa40a977cc [rcore][glfw] SetMousePosition(): use logical HighDPI coordinates (#6328)
* [rcore][glfw] SetMousePosition(): use logical HighDPI coordinates

* Remove explicit cast
2026-10-25 10:03:04 +01:00
b3c685c383 [rtextures] ImageAlphaClear(): fix 16-bit color conversion for R5G5B5A1 and R4G4B4A4 (#6329) 2026-10-25 09:56:44 +01:00
Ray
225a9132dd Comment formating 2026-10-25 09:55:03 +01:00
83f32af26c [rMesh] Faster ray -> mesh collision check (#6330)
* rlparser: update raylib_api.* by CI

* Transform the ray into model space, not the model into world space so the raycast check is faster ~50% faster

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-10-25 09:52:57 +01:00
4 changed files with 27 additions and 13 deletions

View File

@ -1261,7 +1261,9 @@ void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor, float d
// Set mouse position XY
void SetMousePosition(int x, int y)
{
CORE.Input.Mouse.currentPosition = (Vector2){ (float)x, (float)y };
Vector2 scale = CORE.Input.Mouse.scale;
CORE.Input.Mouse.currentPosition.x = roundf((float)x/scale.x);
CORE.Input.Mouse.currentPosition.y = roundf((float)y/scale.y);
// NOTE: emscripten not implemented
glfwSetCursorPos(platform.handle, CORE.Input.Mouse.currentPosition.x, CORE.Input.Mouse.currentPosition.y);

View File

@ -2503,7 +2503,7 @@ const char *GetFileExtension(const char *fileName)
const char *name = GetFileName(fileName);
const char *dot = strrchr(name, '.');
if ((dot == NULL) || (dot == fileName)) return NULL;
if ((dot == NULL) || (dot == name)) return NULL; // No extension for hidden files: ".gitignore"
return dot;
}

View File

@ -4328,6 +4328,15 @@ RayCollision GetRayCollisionMesh(Ray ray, Mesh mesh, Matrix transform)
// Check if mesh vertex data on CPU for testing
if (mesh.vertices != NULL)
{
// Transform the ray into model space by the inverse of the transform,
// so it can be tested against the untransformed vertex data
Matrix inverseMatrix = MatrixInvert(transform);
ray.position = Vector3Transform(ray.position, inverseMatrix);
// Direction does not get translation, just rotation
Quaternion invRot = QuaternionFromMatrix(inverseMatrix);
ray.direction = Vector3RotateByQuaternion(ray.direction, invRot);
int triangleCount = mesh.triangleCount;
// Test against all triangles in mesh
@ -4351,10 +4360,6 @@ RayCollision GetRayCollisionMesh(Ray ray, Mesh mesh, Matrix transform)
c = vertdata[i*3 + 2];
}
a = Vector3Transform(a, transform);
b = Vector3Transform(b, transform);
c = Vector3Transform(c, transform);
RayCollision triHitInfo = GetRayCollisionTriangle(ray, a, b, c);
if (triHitInfo.hit)
@ -4365,6 +4370,13 @@ RayCollision GetRayCollisionMesh(Ray ray, Mesh mesh, Matrix transform)
}
}
// Set the hit point and normal back in world space
if (collision.hit)
{
collision.point = Vector3Transform(collision.point, transform);
collision.normal = Vector3RotateByQuaternion(collision.normal, QuaternionFromMatrix(transform));
}
return collision;
}

View File

@ -2003,9 +2003,9 @@ void ImageAlphaClear(Image *image, Color color, float threshold)
{
unsigned char thresholdValue = ((threshold < 0.5f)? 0 : 1);
unsigned char r = (unsigned char)(round((float)color.r*31.0f));
unsigned char g = (unsigned char)(round((float)color.g*31.0f));
unsigned char b = (unsigned char)(round((float)color.b*31.0f));
unsigned char r = (unsigned char)(round((float)color.r/255.0*31.0f));
unsigned char g = (unsigned char)(round((float)color.g/255.0*31.0f));
unsigned char b = (unsigned char)(round((float)color.b/255.0*31.0f));
unsigned char a = (color.a < 128)? 0 : 1;
for (int i = 0; i < image->width*image->height; i++)
@ -2020,10 +2020,10 @@ void ImageAlphaClear(Image *image, Color color, float threshold)
{
unsigned char thresholdValue = (unsigned char)(threshold*15.0f);
unsigned char r = (unsigned char)(round((float)color.r*15.0f));
unsigned char g = (unsigned char)(round((float)color.g*15.0f));
unsigned char b = (unsigned char)(round((float)color.b*15.0f));
unsigned char a = (unsigned char)(round((float)color.a*15.0f));
unsigned char r = (unsigned char)(round((float)color.r/255.0*15.0f));
unsigned char g = (unsigned char)(round((float)color.g/255.0*15.0f));
unsigned char b = (unsigned char)(round((float)color.b/255.0*15.0f));
unsigned char a = (unsigned char)(round((float)color.a/255.0*15.0f));
for (int i = 0; i < image->width*image->height; i++)
{