REVIEWED: Avoid some float -> double promotions
This commit is contained in:
parent
c65efecf0a
commit
0da7830745
4 changed files with 20 additions and 20 deletions
|
@ -498,14 +498,14 @@ RMAPI Vector3 Vector3Perpendicular(Vector3 v)
|
||||||
float min = (float) fabs(v.x);
|
float min = (float) fabs(v.x);
|
||||||
Vector3 cardinalAxis = {1.0f, 0.0f, 0.0f};
|
Vector3 cardinalAxis = {1.0f, 0.0f, 0.0f};
|
||||||
|
|
||||||
if (fabs(v.y) < min)
|
if (fabsf(v.y) < min)
|
||||||
{
|
{
|
||||||
min = (float) fabs(v.y);
|
min = (float) fabs(v.y);
|
||||||
Vector3 tmp = {0.0f, 1.0f, 0.0f};
|
Vector3 tmp = {0.0f, 1.0f, 0.0f};
|
||||||
cardinalAxis = tmp;
|
cardinalAxis = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fabs(v.z) < min)
|
if (fabsf(v.z) < min)
|
||||||
{
|
{
|
||||||
Vector3 tmp = {0.0f, 0.0f, 1.0f};
|
Vector3 tmp = {0.0f, 0.0f, 1.0f};
|
||||||
cardinalAxis = tmp;
|
cardinalAxis = tmp;
|
||||||
|
@ -1516,7 +1516,7 @@ RMAPI Quaternion QuaternionInvert(Quaternion q)
|
||||||
|
|
||||||
float lengthSq = q.x*q.x + q.y*q.y + q.z*q.z + q.w*q.w;
|
float lengthSq = q.x*q.x + q.y*q.y + q.z*q.z + q.w*q.w;
|
||||||
|
|
||||||
if (lengthSq != 0.0)
|
if (lengthSq != 0.0f)
|
||||||
{
|
{
|
||||||
float invLength = 1.0f/lengthSq;
|
float invLength = 1.0f/lengthSq;
|
||||||
|
|
||||||
|
@ -1619,14 +1619,14 @@ RMAPI Quaternion QuaternionSlerp(Quaternion q1, Quaternion q2, float amount)
|
||||||
cosHalfTheta = -cosHalfTheta;
|
cosHalfTheta = -cosHalfTheta;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fabs(cosHalfTheta) >= 1.0f) result = q1;
|
if (fabsf(cosHalfTheta) >= 1.0f) result = q1;
|
||||||
else if (cosHalfTheta > 0.95f) result = QuaternionNlerp(q1, q2, amount);
|
else if (cosHalfTheta > 0.95f) result = QuaternionNlerp(q1, q2, amount);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
float halfTheta = acosf(cosHalfTheta);
|
float halfTheta = acosf(cosHalfTheta);
|
||||||
float sinHalfTheta = sqrtf(1.0f - cosHalfTheta*cosHalfTheta);
|
float sinHalfTheta = sqrtf(1.0f - cosHalfTheta*cosHalfTheta);
|
||||||
|
|
||||||
if (fabs(sinHalfTheta) < 0.001f)
|
if (fabsf(sinHalfTheta) < 0.001f)
|
||||||
{
|
{
|
||||||
result.x = (q1.x*0.5f + q2.x*0.5f);
|
result.x = (q1.x*0.5f + q2.x*0.5f);
|
||||||
result.y = (q1.y*0.5f + q2.y*0.5f);
|
result.y = (q1.y*0.5f + q2.y*0.5f);
|
||||||
|
@ -1792,7 +1792,7 @@ RMAPI Quaternion QuaternionFromAxisAngle(Vector3 axis, float angle)
|
||||||
// Get the rotation angle and axis for a given quaternion
|
// Get the rotation angle and axis for a given quaternion
|
||||||
RMAPI void QuaternionToAxisAngle(Quaternion q, Vector3 *outAxis, float *outAngle)
|
RMAPI void QuaternionToAxisAngle(Quaternion q, Vector3 *outAxis, float *outAngle)
|
||||||
{
|
{
|
||||||
if (fabs(q.w) > 1.0f)
|
if (fabsf(q.w) > 1.0f)
|
||||||
{
|
{
|
||||||
// QuaternionNormalize(q);
|
// QuaternionNormalize(q);
|
||||||
float length = sqrtf(q.x*q.x + q.y*q.y + q.z*q.z + q.w*q.w);
|
float length = sqrtf(q.x*q.x + q.y*q.y + q.z*q.z + q.w*q.w);
|
||||||
|
|
|
@ -2674,7 +2674,7 @@ void SetTargetFPS(int fps)
|
||||||
if (fps < 1) CORE.Time.target = 0.0;
|
if (fps < 1) CORE.Time.target = 0.0;
|
||||||
else CORE.Time.target = 1.0/(double)fps;
|
else CORE.Time.target = 1.0/(double)fps;
|
||||||
|
|
||||||
TRACELOG(LOG_INFO, "TIMER: Target time per frame: %02.03f milliseconds", (float)CORE.Time.target*1000);
|
TRACELOG(LOG_INFO, "TIMER: Target time per frame: %02.03f milliseconds", (float)CORE.Time.target*1000.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get current FPS
|
// Get current FPS
|
||||||
|
@ -5048,8 +5048,8 @@ void PollInputEvents(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register buttons for 2nd triggers (because GLFW doesn't count these as buttons but rather axis)
|
// Register buttons for 2nd triggers (because GLFW doesn't count these as buttons but rather axis)
|
||||||
CORE.Input.Gamepad.currentButtonState[i][GAMEPAD_BUTTON_LEFT_TRIGGER_2] = (char)(CORE.Input.Gamepad.axisState[i][GAMEPAD_AXIS_LEFT_TRIGGER] > 0.1);
|
CORE.Input.Gamepad.currentButtonState[i][GAMEPAD_BUTTON_LEFT_TRIGGER_2] = (char)(CORE.Input.Gamepad.axisState[i][GAMEPAD_AXIS_LEFT_TRIGGER] > 0.1f);
|
||||||
CORE.Input.Gamepad.currentButtonState[i][GAMEPAD_BUTTON_RIGHT_TRIGGER_2] = (char)(CORE.Input.Gamepad.axisState[i][GAMEPAD_AXIS_RIGHT_TRIGGER] > 0.1);
|
CORE.Input.Gamepad.currentButtonState[i][GAMEPAD_BUTTON_RIGHT_TRIGGER_2] = (char)(CORE.Input.Gamepad.axisState[i][GAMEPAD_AXIS_RIGHT_TRIGGER] > 0.1f);
|
||||||
|
|
||||||
CORE.Input.Gamepad.axisCount = GLFW_GAMEPAD_AXIS_LAST + 1;
|
CORE.Input.Gamepad.axisCount = GLFW_GAMEPAD_AXIS_LAST + 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3284,10 +3284,10 @@ void DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis, float rota
|
||||||
Color color = model.materials[model.meshMaterial[i]].maps[MATERIAL_MAP_DIFFUSE].color;
|
Color color = model.materials[model.meshMaterial[i]].maps[MATERIAL_MAP_DIFFUSE].color;
|
||||||
|
|
||||||
Color colorTint = WHITE;
|
Color colorTint = WHITE;
|
||||||
colorTint.r = (unsigned char)((((float)color.r/255.0)*((float)tint.r/255.0))*255.0f);
|
colorTint.r = (unsigned char)((((float)color.r/255.0f)*((float)tint.r/255.0f))*255.0f);
|
||||||
colorTint.g = (unsigned char)((((float)color.g/255.0)*((float)tint.g/255.0))*255.0f);
|
colorTint.g = (unsigned char)((((float)color.g/255.0f)*((float)tint.g/255.0f))*255.0f);
|
||||||
colorTint.b = (unsigned char)((((float)color.b/255.0)*((float)tint.b/255.0))*255.0f);
|
colorTint.b = (unsigned char)((((float)color.b/255.0f)*((float)tint.b/255.0f))*255.0f);
|
||||||
colorTint.a = (unsigned char)((((float)color.a/255.0)*((float)tint.a/255.0))*255.0f);
|
colorTint.a = (unsigned char)((((float)color.a/255.0f)*((float)tint.a/255.0f))*255.0f);
|
||||||
|
|
||||||
model.materials[model.meshMaterial[i]].maps[MATERIAL_MAP_DIFFUSE].color = colorTint;
|
model.materials[model.meshMaterial[i]].maps[MATERIAL_MAP_DIFFUSE].color = colorTint;
|
||||||
DrawMesh(model.meshes[i], model.materials[model.meshMaterial[i]], model.transform);
|
DrawMesh(model.meshes[i], model.materials[model.meshMaterial[i]], model.transform);
|
||||||
|
@ -3664,7 +3664,7 @@ RayCollision GetRayCollisionModel(Ray ray, Model model)
|
||||||
// NOTE: Based on https://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm
|
// NOTE: Based on https://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm
|
||||||
RayCollision GetRayCollisionTriangle(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3)
|
RayCollision GetRayCollisionTriangle(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3)
|
||||||
{
|
{
|
||||||
#define EPSILON 0.000001 // A small number
|
#define EPSILON 0.000001f // A small number
|
||||||
|
|
||||||
RayCollision collision = { 0 };
|
RayCollision collision = { 0 };
|
||||||
Vector3 edge1 = { 0 };
|
Vector3 edge1 = { 0 };
|
||||||
|
|
|
@ -1958,25 +1958,25 @@ void ImageColorContrast(Image *image, float contrast)
|
||||||
for (int x = 0; x < image->width; x++)
|
for (int x = 0; x < image->width; x++)
|
||||||
{
|
{
|
||||||
float pR = (float)pixels[y*image->width + x].r/255.0f;
|
float pR = (float)pixels[y*image->width + x].r/255.0f;
|
||||||
pR -= 0.5;
|
pR -= 0.5f;
|
||||||
pR *= contrast;
|
pR *= contrast;
|
||||||
pR += 0.5;
|
pR += 0.5f;
|
||||||
pR *= 255;
|
pR *= 255;
|
||||||
if (pR < 0) pR = 0;
|
if (pR < 0) pR = 0;
|
||||||
if (pR > 255) pR = 255;
|
if (pR > 255) pR = 255;
|
||||||
|
|
||||||
float pG = (float)pixels[y*image->width + x].g/255.0f;
|
float pG = (float)pixels[y*image->width + x].g/255.0f;
|
||||||
pG -= 0.5;
|
pG -= 0.5f;
|
||||||
pG *= contrast;
|
pG *= contrast;
|
||||||
pG += 0.5;
|
pG += 0.5f;
|
||||||
pG *= 255;
|
pG *= 255;
|
||||||
if (pG < 0) pG = 0;
|
if (pG < 0) pG = 0;
|
||||||
if (pG > 255) pG = 255;
|
if (pG > 255) pG = 255;
|
||||||
|
|
||||||
float pB = (float)pixels[y*image->width + x].b/255.0f;
|
float pB = (float)pixels[y*image->width + x].b/255.0f;
|
||||||
pB -= 0.5;
|
pB -= 0.5f;
|
||||||
pB *= contrast;
|
pB *= contrast;
|
||||||
pB += 0.5;
|
pB += 0.5f;
|
||||||
pB *= 255;
|
pB *= 255;
|
||||||
if (pB < 0) pB = 0;
|
if (pB < 0) pB = 0;
|
||||||
if (pB > 255) pB = 255;
|
if (pB > 255) pB = 255;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue