mirror of
https://github.com/raysan5/raylib.git
synced 2026-11-25 09:01:47 -05:00
Compare commits
5 Commits
d6cb247ca7
...
debc1f6b1f
| Author | SHA1 | Date | |
|---|---|---|---|
| debc1f6b1f | |||
| aa40a977cc | |||
| b3c685c383 | |||
| 225a9132dd | |||
| 83f32af26c |
@ -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);
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user