Skip to content

Commit

Permalink
Formating review
Browse files Browse the repository at this point in the history
  • Loading branch information
raysan5 committed Aug 26, 2023
1 parent b27e98a commit 9646497
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
13 changes: 11 additions & 2 deletions src/raymath.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* - Functions use always a "result" variable for return
* - Functions are always defined inline
* - Angles are always in radians (DEG2RAD/RAD2DEG macros provided for convenience)
* - No compound literals used to make sure libray is compatible with C++
*
* CONFIGURATION:
* #define RAYMATH_IMPLEMENTATION
Expand Down Expand Up @@ -716,25 +717,33 @@ RMAPI Vector3 Vector3Normalize(Vector3 v)
//Calculate the projection of the vector v1 on to v2
RMAPI Vector3 Vector3Project(Vector3 v1, Vector3 v2)
{
Vector3 result = { 0 };

float v1dv2 = (v1.x*v2.x + v1.y*v2.y + v1.z*v2.z);
float v2dv2 = (v2.x*v2.x + v2.y*v2.y + v2.z*v2.z);

float mag = v1dv2/v2dv2;

Vector3 result = { v2.x*mag , v2.y*mag, v2.z*mag };
result.x = v2.x*mag;
result.y = v2.y*mag;
result.z = v2.z*mag;

return result;
}

//Calculate the rejection of the vector v1 on to v2
RMAPI Vector3 Vector3Reject(Vector3 v1, Vector3 v2)
{
Vector3 result = { 0 };

float v1dv2 = (v1.x*v2.x + v1.y*v2.y + v1.z*v2.z);
float v2dv2 = (v2.x*v2.x + v2.y*v2.y + v2.z*v2.z);

float mag = v1dv2/v2dv2;

Vector3 result = { v1.x - (v2.x*mag) , v1.y - (v2.y*mag), v1.z - (v2.z*mag) };
result.x = v1.x - (v2.x*mag);
result.y = v1.y - (v2.y*mag);
result.z = v1.z - (v2.z*mag);

return result;
}
Expand Down
18 changes: 6 additions & 12 deletions src/rtextures.c
Original file line number Diff line number Diff line change
Expand Up @@ -3284,19 +3284,13 @@ void ImageDrawRectangleRec(Image *dst, Rectangle rec, Color color)
if (rec.width < 0) rec.width = 0;
if (rec.height < 0) rec.height = 0;

// clamp the size the the image bounds
if (rec.x + rec.width >= dst->width)
rec.width = dst->width - rec.x;
// Clamp the size the the image bounds
if ((rec.x + rec.width) >= dst->width) rec.width = dst->width - rec.x;
if ((rec.y + rec.height) >= dst->height) rec.height = dst->height - rec.y;

if (rec.y + rec.height >= dst->height)
rec.height = dst->height - rec.y;

// check if the rect is even inside the image
if (rec.x > dst->width || rec.y > dst->height)
return;

if (rec.x + rec.width < 0 || rec.y + rec.height < 0)
return;
// Check if the rect is even inside the image
if ((rec.x > dst->width) || (rec.y > dst->height)) return;
if (((rec.x + rec.width) < 0) || (rec.y + rec.height < 0)) return;

int sy = (int)rec.y;
int sx = (int)rec.x;
Expand Down

0 comments on commit 9646497

Please sign in to comment.