Skip to content

Commit a17a81f

Browse files
committed
Review code formating
1 parent 51486a0 commit a17a81f

File tree

2 files changed

+43
-33
lines changed

2 files changed

+43
-33
lines changed

src/rmodels.c

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -570,8 +570,9 @@ void DrawCylinderEx(Vector3 startPos, Vector3 endPos, float startRadius, float e
570570
rlBegin(RL_TRIANGLES);
571571
rlColor4ub(color.r, color.g, color.b, color.a);
572572

573-
for (int i = 0; i < sides; i++) {
574-
// compute the four vertices
573+
for (int i = 0; i < sides; i++)
574+
{
575+
// Compute the four vertices
575576
float s1 = sinf(baseAngle*(i + 0))*startRadius;
576577
float c1 = cosf(baseAngle*(i + 0))*startRadius;
577578
Vector3 w1 = { startPos.x + s1*b1.x + c1*b2.x, startPos.y + s1*b1.y + c1*b2.y, startPos.z + s1*b1.z + c1*b2.z };
@@ -585,11 +586,12 @@ void DrawCylinderEx(Vector3 startPos, Vector3 endPos, float startRadius, float e
585586
float c4 = cosf(baseAngle*(i + 1))*endRadius;
586587
Vector3 w4 = { endPos.x + s4*b1.x + c4*b2.x, endPos.y + s4*b1.y + c4*b2.y, endPos.z + s4*b1.z + c4*b2.z };
587588

588-
if (startRadius > 0) { //
589+
if (startRadius > 0)
590+
{
589591
rlVertex3f(startPos.x, startPos.y, startPos.z); // |
590592
rlVertex3f(w2.x, w2.y, w2.z); // T0
591593
rlVertex3f(w1.x, w1.y, w1.z); // |
592-
} //
594+
}
593595
// w2 x.-----------x startPos
594596
rlVertex3f(w1.x, w1.y, w1.z); // | |\'. T0 /
595597
rlVertex3f(w2.x, w2.y, w2.z); // T1 | \ '. /
@@ -599,7 +601,8 @@ void DrawCylinderEx(Vector3 startPos, Vector3 endPos, float startRadius, float e
599601
rlVertex3f(w4.x, w4.y, w4.z); // T2 '. \ |T3/
600602
rlVertex3f(w3.x, w3.y, w3.z); // | '. \ | /
601603
// '.\|/
602-
if (endRadius > 0) { // 'x w3
604+
if (endRadius > 0) // 'x w3
605+
{
603606
rlVertex3f(endPos.x, endPos.y, endPos.z); // |
604607
rlVertex3f(w3.x, w3.y, w3.z); // T3
605608
rlVertex3f(w4.x, w4.y, w4.z); // |
@@ -657,8 +660,9 @@ void DrawCylinderWiresEx(Vector3 startPos, Vector3 endPos, float startRadius, fl
657660
rlBegin(RL_LINES);
658661
rlColor4ub(color.r, color.g, color.b, color.a);
659662

660-
for (int i = 0; i < sides; i++) {
661-
// compute the four vertices
663+
for (int i = 0; i < sides; i++)
664+
{
665+
// Compute the four vertices
662666
float s1 = sinf(baseAngle*(i + 0))*startRadius;
663667
float c1 = cosf(baseAngle*(i + 0))*startRadius;
664668
Vector3 w1 = { startPos.x + s1*b1.x + c1*b2.x, startPos.y + s1*b1.y + c1*b2.y, startPos.z + s1*b1.z + c1*b2.z };
@@ -4749,7 +4753,8 @@ static cgltf_result LoadFileGLTFCallback(const struct cgltf_memory_options *memo
47494753
}
47504754

47514755
// Release file data callback for cgltf
4752-
static void ReleaseFileGLTFCallback(const struct cgltf_memory_options *memoryOptions, const struct cgltf_file_options *fileOptions, void *data) {
4756+
static void ReleaseFileGLTFCallback(const struct cgltf_memory_options *memoryOptions, const struct cgltf_file_options *fileOptions, void *data)
4757+
{
47534758
UnloadFileData(data);
47544759
}
47554760

@@ -5335,7 +5340,8 @@ static Model LoadGLTF(const char *fileName)
53355340
model.meshes[meshIndex].animVertices = RL_CALLOC(model.meshes[meshIndex].vertexCount*3, sizeof(float));
53365341
memcpy(model.meshes[meshIndex].animVertices, model.meshes[meshIndex].vertices, model.meshes[meshIndex].vertexCount*3*sizeof(float));
53375342
model.meshes[meshIndex].animNormals = RL_CALLOC(model.meshes[meshIndex].vertexCount*3, sizeof(float));
5338-
if (model.meshes[meshIndex].normals != NULL) {
5343+
if (model.meshes[meshIndex].normals != NULL)
5344+
{
53395345
memcpy(model.meshes[meshIndex].animNormals, model.meshes[meshIndex].normals, model.meshes[meshIndex].vertexCount*3*sizeof(float));
53405346
}
53415347

@@ -5379,7 +5385,7 @@ static bool GetPoseAtTimeGLTF(cgltf_interpolation_type interpolationType, cgltf_
53795385
break;
53805386
}
53815387
}
5382-
5388+
53835389
float duration = fmax((tend - tstart), EPSILON);
53845390
float t = (time - tstart)/duration;
53855391
t = (t < 0.0f)? 0.0f : t;
@@ -5400,7 +5406,6 @@ static bool GetPoseAtTimeGLTF(cgltf_interpolation_type interpolationType, cgltf_
54005406

54015407
*r = v1;
54025408
} break;
5403-
54045409
case cgltf_interpolation_type_linear:
54055410
{
54065411
float tmp[3] = { 0.0f };
@@ -5409,10 +5414,9 @@ static bool GetPoseAtTimeGLTF(cgltf_interpolation_type interpolationType, cgltf_
54095414
cgltf_accessor_read_float(output, keyframe+1, tmp, 3);
54105415
Vector3 v2 = {tmp[0], tmp[1], tmp[2]};
54115416
Vector3 *r = data;
5412-
5417+
54135418
*r = Vector3Lerp(v1, v2, t);
54145419
} break;
5415-
54165420
case cgltf_interpolation_type_cubic_spline:
54175421
{
54185422
float tmp[3] = { 0.0f };
@@ -5428,6 +5432,7 @@ static bool GetPoseAtTimeGLTF(cgltf_interpolation_type interpolationType, cgltf_
54285432

54295433
*r = Vector3CubicHermite(v1, tangent1, v2, tangent2, t);
54305434
} break;
5435+
default: break;
54315436
}
54325437
}
54335438
else if (output->type == cgltf_type_vec4)
@@ -5444,7 +5449,6 @@ static bool GetPoseAtTimeGLTF(cgltf_interpolation_type interpolationType, cgltf_
54445449

54455450
*r = v1;
54465451
} break;
5447-
54485452
case cgltf_interpolation_type_linear:
54495453
{
54505454
float tmp[4] = { 0.0f };
@@ -5453,10 +5457,9 @@ static bool GetPoseAtTimeGLTF(cgltf_interpolation_type interpolationType, cgltf_
54535457
cgltf_accessor_read_float(output, keyframe+1, tmp, 4);
54545458
Vector4 v2 = {tmp[0], tmp[1], tmp[2], tmp[3]};
54555459
Vector4 *r = data;
5456-
5460+
54575461
*r = QuaternionSlerp(v1, v2, t);
54585462
} break;
5459-
54605463
case cgltf_interpolation_type_cubic_spline:
54615464
{
54625465
float tmp[4] = { 0.0f };
@@ -5477,12 +5480,13 @@ static bool GetPoseAtTimeGLTF(cgltf_interpolation_type interpolationType, cgltf_
54775480
{
54785481
v2 = Vector4Negate(v2);
54795482
}
5480-
5483+
54815484
outTangent1 = Vector4Scale(outTangent1, duration);
54825485
inTangent2 = Vector4Scale(inTangent2, duration);
54835486

54845487
*r = QuaternionCubicHermiteSpline(v1, outTangent1, v2, inTangent2, t);
54855488
} break;
5489+
default: break;
54865490
}
54875491
}
54885492

src/rtextures.c

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1993,8 +1993,9 @@ void ImageAlphaPremultiply(Image *image)
19931993
ImageFormat(image, format);
19941994
}
19951995

1996-
// Apply box blur
1997-
void ImageBlurGaussian(Image *image, int blurSize) {
1996+
// Apply box blur to image
1997+
void ImageBlurGaussian(Image *image, int blurSize)
1998+
{
19981999
// Security check to avoid program crash
19992000
if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
20002001

@@ -2006,15 +2007,17 @@ void ImageBlurGaussian(Image *image, int blurSize) {
20062007
Vector4 *pixelsCopy1 = RL_MALLOC((image->height)*(image->width)*sizeof(Vector4));
20072008
Vector4 *pixelsCopy2 = RL_MALLOC((image->height)*(image->width)*sizeof(Vector4));
20082009

2009-
for (int i = 0; i < (image->height)*(image->width); i++) {
2010+
for (int i = 0; i < (image->height*image->width); i++)
2011+
{
20102012
pixelsCopy1[i].x = pixels[i].r;
20112013
pixelsCopy1[i].y = pixels[i].g;
20122014
pixelsCopy1[i].z = pixels[i].b;
20132015
pixelsCopy1[i].w = pixels[i].a;
20142016
}
20152017

20162018
// Repeated convolution of rectangular window signal by itself converges to a gaussian distribution
2017-
for (int j = 0; j < GAUSSIAN_BLUR_ITERATIONS; j++) {
2019+
for (int j = 0; j < GAUSSIAN_BLUR_ITERATIONS; j++)
2020+
{
20182021
// Horizontal motion blur
20192022
for (int row = 0; row < image->height; row++)
20202023
{
@@ -4997,22 +5000,25 @@ int GetPixelDataSize(int width, int height, int format)
49975000
//----------------------------------------------------------------------------------
49985001
// Module specific Functions Definition
49995002
//----------------------------------------------------------------------------------
5000-
// From https://stackoverflow.com/questions/1659440/32-bit-to-16-bit-floating-point-conversion/60047308#60047308
5001-
5002-
static float HalfToFloat(unsigned short x) {
5003-
const unsigned int e = (x&0x7C00)>>10; // exponent
5004-
const unsigned int m = (x&0x03FF)<<13; // mantissa
5003+
// Convert half-float (stored as unsigned short) to float
5004+
// REF: https://stackoverflow.com/questions/1659440/32-bit-to-16-bit-floating-point-conversion/60047308#60047308
5005+
static float HalfToFloat(unsigned short x)
5006+
{
5007+
const unsigned int e = (x & 0x7C00) >> 10; // Exponent
5008+
const unsigned int m = (x & 0x03FF) << 13; // Mantissa
50055009
const float fm = (float)m;
5006-
const unsigned int v = (*(unsigned int*)&fm)>>23; // evil log2 bit hack to count leading zeros in denormalized format
5007-
const unsigned int r = (x&0x8000)<<16 | (e!=0)*((e+112)<<23|m) | ((e==0)&(m!=0))*((v-37)<<23|((m<<(150-v))&0x007FE000)); // sign : normalized : denormalized
5010+
const unsigned int v = (*(unsigned int*)&fm) >> 23; // Evil log2 bit hack to count leading zeros in denormalized format
5011+
const unsigned int r = (x & 0x8000) << 16 | (e != 0)*((e + 112) << 23 | m) | ((e == 0)&(m != 0))*((v - 37) << 23 | ((m << (150 - v)) & 0x007FE000)); // sign : normalized : denormalized
50085012
return *(float*)&r;
50095013
}
50105014

5011-
static unsigned short FloatToHalf(float x) {
5012-
const unsigned int b = (*(unsigned int*)&x)+0x00001000; // round-to-nearest-even: add last bit after truncated mantissa
5013-
const unsigned int e = (b&0x7F800000)>>23; // exponent
5014-
const unsigned int m = b&0x007FFFFF; // mantissa; in line below: 0x007FF000 = 0x00800000-0x00001000 = decimal indicator flag - initial rounding
5015-
return (b&0x80000000)>>16 | (e>112)*((((e-112)<<10)&0x7C00)|m>>13) | ((e<113)&(e>101))*((((0x007FF000+m)>>(125-e))+1)>>1) | (e>143)*0x7FFF; // sign : normalized : denormalized : saturate
5015+
// Convert float to half-float (stored as unsigned short)
5016+
static unsigned short FloatToHalf(float x)
5017+
{
5018+
const unsigned int b = (*(unsigned int*) & x) + 0x00001000; // Round-to-nearest-even: add last bit after truncated mantissa
5019+
const unsigned int e = (b & 0x7F800000) >> 23; // Exponent
5020+
const unsigned int m = b & 0x007FFFFF; // Mantissa; in line below: 0x007FF000 = 0x00800000-0x00001000 = decimal indicator flag - initial rounding
5021+
return (b & 0x80000000) >> 16 | (e > 112)*((((e - 112) << 10) & 0x7C00) | m >> 13) | ((e < 113) & (e > 101))*((((0x007FF000 + m) >> (125 - e)) + 1) >> 1) | (e > 143)*0x7FFF; // sign : normalized : denormalized : saturate
50165022
}
50175023

50185024
// Get pixel data from image as Vector4 array (float normalized)

0 commit comments

Comments
 (0)