2
0
Эх сурвалжийг харах

Change ternary operator formatting

Ray 6 жил өмнө
parent
commit
374811c440
7 өөрчлөгдсөн 52 нэмэгдсэн , 52 устгасан
  1. 22 22
      src/core.c
  2. 4 4
      src/models.c
  3. 11 11
      src/raudio.c
  4. 5 5
      src/rlgl.h
  5. 1 1
      src/shapes.c
  6. 5 5
      src/text.c
  7. 4 4
      src/textures.c

+ 22 - 22
src/core.c

@@ -1430,11 +1430,11 @@ Vector3 ColorToHSV(Color color)
     Vector3 hsv = { 0.0f, 0.0f, 0.0f };
     float min, max, delta;
 
-    min = rgb.x < rgb.y ? rgb.x : rgb.y;
-    min = min  < rgb.z ? min  : rgb.z;
+    min = rgb.x < rgb.y? rgb.x : rgb.y;
+    min = min  < rgb.z? min  : rgb.z;
 
-    max = rgb.x > rgb.y ? rgb.x : rgb.y;
-    max = max  > rgb.z ? max  : rgb.z;
+    max = rgb.x > rgb.y? rgb.x : rgb.y;
+    max = max  > rgb.z? max  : rgb.z;
 
     hsv.z = max;            // Value
     delta = max - min;
@@ -1485,25 +1485,25 @@ Color ColorFromHSV(Vector3 hsv)
     // Red channel
     float k = fmod((5.0f + h/60.0f), 6);
     float t = 4.0f - k;
-    k = (t < k) ? t : k;
-    k = (k < 1) ? k : 1;
-    k = (k > 0) ? k : 0;
+    k = (t < k)? t : k;
+    k = (k < 1)? k : 1;
+    k = (k > 0)? k : 0;
     color.r = (v - v*s*k)*255;
 
     // Green channel
     k = fmod((3.0f + h/60.0f), 6);
     t = 4.0f - k;
-    k = (t < k) ? t : k;
-    k = (k < 1) ? k : 1;
-    k = (k > 0) ? k : 0;
+    k = (t < k)? t : k;
+    k = (k < 1)? k : 1;
+    k = (k > 0)? k : 0;
     color.g = (v - v*s*k)*255;
 
     // Blue channel
     k = fmod((1.0f + h/60.0f), 6);
     t = 4.0f - k;
-    k = (t < k) ? t : k;
-    k = (k < 1) ? k : 1;
-    k = (k > 0) ? k : 0;
+    k = (t < k)? t : k;
+    k = (k < 1)? k : 1;
+    k = (k > 0)? k : 0;
     color.b = (v - v*s*k)*255;
 
     return color;
@@ -1677,7 +1677,7 @@ const char *GetFileNameWithoutExt(const char *filePath)
 
     // NOTE: strrchr() returns a pointer to the last occurrence of character
     lastDot = strrchr(result, nameDot);
-    lastSep = (pathSep == 0) ? NULL : strrchr(result, pathSep);
+    lastSep = (pathSep == 0)? NULL : strrchr(result, pathSep);
 
     if (lastDot != NULL)            // Check if it has an extension separator...
     {
@@ -3191,7 +3191,7 @@ static void PollInputEvents(void)
 
     // Poll Events (registered events)
     // NOTE: Activity is paused if not enabled (appEnabled)
-    while ((ident = ALooper_pollAll(appEnabled ? 0 : -1, NULL, &events,(void**)&source)) >= 0)
+    while ((ident = ALooper_pollAll(appEnabled? 0 : -1, NULL, &events,(void**)&source)) >= 0)
     {
         // Process this event
         if (source != NULL) source->process(androidApp, source);
@@ -3771,7 +3771,7 @@ static EM_BOOL EmscriptenTouchCallback(int eventType, const EmscriptenTouchEvent
     }
 
     printf("%s, numTouches: %d %s%s%s%s\n", emscripten_event_type_to_string(eventType), event->numTouches,
-           event->ctrlKey ? " CTRL" : "", event->shiftKey ? " SHIFT" : "", event->altKey ? " ALT" : "", event->metaKey ? " META" : "");
+           event->ctrlKey? " CTRL" : "", event->shiftKey? " SHIFT" : "", event->altKey? " ALT" : "", event->metaKey? " META" : "");
 
     for (int i = 0; i < event->numTouches; ++i)
     {
@@ -3825,7 +3825,7 @@ static EM_BOOL EmscriptenGamepadCallback(int eventType, const EmscriptenGamepadE
 {
     /*
     printf("%s: timeStamp: %g, connected: %d, index: %ld, numAxes: %d, numButtons: %d, id: \"%s\", mapping: \"%s\"\n",
-           eventType != 0 ? emscripten_event_type_to_string(eventType) : "Gamepad state",
+           eventType != 0? emscripten_event_type_to_string(eventType) : "Gamepad state",
            gamepadEvent->timestamp, gamepadEvent->connected, gamepadEvent->index, gamepadEvent->numAxes, gamepadEvent->numButtons, gamepadEvent->id, gamepadEvent->mapping);
 
     for(int i = 0; i < gamepadEvent->numAxes; ++i) printf("Axis %d: %g\n", i, gamepadEvent->axis[i]);
@@ -4189,11 +4189,11 @@ static void EventThreadSpawn(char *device)
     {
         // Looks like a interesting device
         TraceLog(LOG_INFO, "Opening input device [%s] (%s%s%s%s%s)", device,
-            worker->isMouse ? "mouse " : "",
-            worker->isMultitouch ? "multitouch " : "",
-            worker->isTouch ? "touchscreen " : "",
-            worker->isGamepad ? "gamepad " : "",
-            worker->isKeyboard ? "keyboard " : "");
+            worker->isMouse? "mouse " : "",
+            worker->isMultitouch? "multitouch " : "",
+            worker->isTouch? "touchscreen " : "",
+            worker->isGamepad? "gamepad " : "",
+            worker->isKeyboard? "keyboard " : "");
 
         // Create a thread for this device
         int error = pthread_create(&worker->threadId, NULL, &EventThread, (void *)worker);

+ 4 - 4
src/models.c

@@ -2260,7 +2260,7 @@ void MeshTangents(Mesh *mesh)
         float t2 = uv3.y - uv1.y;
 
         float div = s1*t2 - s2*t1;
-        float r = (div == 0.0f) ? 0.0f : 1.0f/div;
+        float r = (div == 0.0f)? 0.0f : 1.0f/div;
 
         Vector3 sdir = { (t2*x1 - t1*x2)*r, (t2*y1 - t1*y2)*r, (t2*z1 - t1*z2)*r };
         Vector3 tdir = { (s1*x2 - s2*x1)*r, (s1*y2 - s2*y1)*r, (s1*z2 - s2*z1)*r };
@@ -2293,7 +2293,7 @@ void MeshTangents(Mesh *mesh)
         mesh->tangents[i*4 + 0] = tangent.x;
         mesh->tangents[i*4 + 1] = tangent.y;
         mesh->tangents[i*4 + 2] = tangent.z;
-        mesh->tangents[i*4 + 3] = (Vector3DotProduct(Vector3CrossProduct(normal, tangent), tan2[i]) < 0.0f) ? -1.0f : 1.0f;
+        mesh->tangents[i*4 + 3] = (Vector3DotProduct(Vector3CrossProduct(normal, tangent), tan2[i]) < 0.0f)? -1.0f : 1.0f;
     #endif
     }
 
@@ -2312,7 +2312,7 @@ void MeshBinormals(Mesh *mesh)
         Vector3 tangent = { mesh->tangents[i*4 + 0], mesh->tangents[i*4 + 1], mesh->tangents[i*4 + 2] };
         float tangentW = mesh->tangents[i*4 + 3];
 
-        // TODO: Register computed binormal in mesh->binormal ?
+        // TODO: Register computed binormal in mesh->binormal?
         // Vector3 binormal = Vector3Multiply(Vector3CrossProduct(normal, tangent), tangentW);
     }
 }
@@ -2639,7 +2639,7 @@ static Material LoadMTL(const char *fileName)
                     } break;
                     case 'e':   // Ke float float float     Emmisive color (RGB)
                     {
-                        // TODO: Support Ke ?
+                        // TODO: Support Ke?
                     } break;
                     default: break;
                 }

+ 11 - 11
src/raudio.c

@@ -834,7 +834,7 @@ Sound LoadSoundFromWave(Wave wave)
         //
         // I have decided on the first option because it offloads work required for the format conversion to the to the loading stage.
         // The downside to this is that it uses more memory if the original sound is u8 or s16.
-        mal_format formatIn  = ((wave.sampleSize == 8) ? mal_format_u8 : ((wave.sampleSize == 16) ? mal_format_s16 : mal_format_f32));
+        mal_format formatIn  = ((wave.sampleSize == 8)? mal_format_u8 : ((wave.sampleSize == 16)? mal_format_s16 : mal_format_f32));
         mal_uint32 frameCountIn = wave.sampleCount/wave.channels;
 
         mal_uint32 frameCount = (mal_uint32)mal_convert_frames(NULL, DEVICE_FORMAT, DEVICE_CHANNELS, DEVICE_SAMPLE_RATE, NULL, formatIn, wave.channels, wave.sampleRate, frameCountIn);
@@ -946,7 +946,7 @@ void ExportWaveAsCode(Wave wave, const char *fileName)
 
     // Write byte data as hexadecimal text
     fprintf(txtFile, "static unsigned char %s_DATA[%i] = { ", varFileName, dataSize);
-    for (int i = 0; i < dataSize - 1; i++) fprintf(txtFile, ((i%BYTES_TEXT_PER_LINE == 0) ? "0x%x,\n" : "0x%x, "), ((unsigned char *)wave.data)[i]);
+    for (int i = 0; i < dataSize - 1; i++) fprintf(txtFile, ((i%BYTES_TEXT_PER_LINE == 0)? "0x%x,\n" : "0x%x, "), ((unsigned char *)wave.data)[i]);
     fprintf(txtFile, "0x%x };\n", ((unsigned char *)wave.data)[dataSize - 1]);
 
     fclose(txtFile);
@@ -997,8 +997,8 @@ void SetSoundPitch(Sound sound, float pitch)
 // Convert wave data to desired format
 void WaveFormat(Wave *wave, int sampleRate, int sampleSize, int channels)
 {
-    mal_format formatIn  = ((wave->sampleSize == 8) ? mal_format_u8 : ((wave->sampleSize == 16) ? mal_format_s16 : mal_format_f32));
-    mal_format formatOut = ((      sampleSize == 8) ? mal_format_u8 : ((      sampleSize == 16) ? mal_format_s16 : mal_format_f32));
+    mal_format formatIn  = ((wave->sampleSize == 8)? mal_format_u8 : ((wave->sampleSize == 16)? mal_format_s16 : mal_format_f32));
+    mal_format formatOut = ((      sampleSize == 8)? mal_format_u8 : ((      sampleSize == 16)? mal_format_s16 : mal_format_f32));
 
     mal_uint32 frameCountIn = wave->sampleCount;  // Is wave->sampleCount actually the frame count? That terminology needs to change, if so.
 
@@ -1511,7 +1511,7 @@ AudioStream InitAudioStream(unsigned int sampleRate, unsigned int sampleSize, un
         stream.channels = 1;  // Fallback to mono channel
     }
 
-    mal_format formatIn = ((stream.sampleSize == 8) ? mal_format_u8 : ((stream.sampleSize == 16) ? mal_format_s16 : mal_format_f32));
+    mal_format formatIn = ((stream.sampleSize == 8)? mal_format_u8 : ((stream.sampleSize == 16)? mal_format_s16 : mal_format_f32));
 
     // The size of a streaming buffer must be at least double the size of a period.
     unsigned int periodSize = device.bufferSizeInFrames/device.periods;
@@ -1528,7 +1528,7 @@ AudioStream InitAudioStream(unsigned int sampleRate, unsigned int sampleSize, un
     audioBuffer->looping = true;        // Always loop for streaming buffers.
     stream.audioBuffer = audioBuffer;
 
-    TraceLog(LOG_INFO, "[AUD ID %i] Audio stream loaded successfully (%i Hz, %i bit, %s)", stream.source, stream.sampleRate, stream.sampleSize, (stream.channels == 1) ? "Mono" : "Stereo");
+    TraceLog(LOG_INFO, "[AUD ID %i] Audio stream loaded successfully (%i Hz, %i bit, %s)", stream.source, stream.sampleRate, stream.sampleSize, (stream.channels == 1)? "Mono" : "Stereo");
 
     return stream;
 }
@@ -1566,7 +1566,7 @@ void UpdateAudioStream(AudioStream stream, const void *data, int samplesCount)
         else
         {
             // Just update whichever sub-buffer is processed.
-            subBufferToUpdate = (audioBuffer->isSubBufferProcessed[0]) ? 0 : 1;
+            subBufferToUpdate = (audioBuffer->isSubBufferProcessed[0])? 0 : 1;
         }
 
         mal_uint32 subBufferSizeInFrames = audioBuffer->bufferSizeInFrames/2;
@@ -1769,7 +1769,7 @@ static Wave LoadWAV(const char *fileName)
                     // NOTE: subChunkSize comes in bytes, we need to translate it to number of samples
                     wave.sampleCount = (wavData.subChunkSize/(wave.sampleSize/8))/wave.channels;
 
-                    TraceLog(LOG_INFO, "[%s] WAV file loaded successfully (%i Hz, %i bit, %s)", fileName, wave.sampleRate, wave.sampleSize, (wave.channels == 1) ? "Mono" : "Stereo");
+                    TraceLog(LOG_INFO, "[%s] WAV file loaded successfully (%i Hz, %i bit, %s)", fileName, wave.sampleRate, wave.sampleSize, (wave.channels == 1)? "Mono" : "Stereo");
                 }
             }
         }
@@ -1890,7 +1890,7 @@ static Wave LoadOGG(const char *fileName)
 
         TraceLog(LOG_DEBUG, "[%s] Samples obtained: %i", fileName, numSamplesOgg);
 
-        TraceLog(LOG_INFO, "[%s] OGG file loaded successfully (%i Hz, %i bit, %s)", fileName, wave.sampleRate, wave.sampleSize, (wave.channels == 1) ? "Mono" : "Stereo");
+        TraceLog(LOG_INFO, "[%s] OGG file loaded successfully (%i Hz, %i bit, %s)", fileName, wave.sampleRate, wave.sampleSize, (wave.channels == 1)? "Mono" : "Stereo");
 
         stb_vorbis_close(oggFile);
     }
@@ -1917,7 +1917,7 @@ static Wave LoadFLAC(const char *fileName)
     if (wave.channels > 2) TraceLog(LOG_WARNING, "[%s] FLAC channels number (%i) not supported", fileName, wave.channels);
 
     if (wave.data == NULL) TraceLog(LOG_WARNING, "[%s] FLAC data could not be loaded", fileName);
-    else TraceLog(LOG_INFO, "[%s] FLAC file loaded successfully (%i Hz, %i bit, %s)", fileName, wave.sampleRate, wave.sampleSize, (wave.channels == 1) ? "Mono" : "Stereo");
+    else TraceLog(LOG_INFO, "[%s] FLAC file loaded successfully (%i Hz, %i bit, %s)", fileName, wave.sampleRate, wave.sampleSize, (wave.channels == 1)? "Mono" : "Stereo");
 
     return wave;
 }
@@ -1944,7 +1944,7 @@ static Wave LoadMP3(const char *fileName)
     if (wave.channels > 2) TraceLog(LOG_WARNING, "[%s] MP3 channels number (%i) not supported", fileName, wave.channels);
 
     if (wave.data == NULL) TraceLog(LOG_WARNING, "[%s] MP3 data could not be loaded", fileName);
-    else TraceLog(LOG_INFO, "[%s] MP3 file loaded successfully (%i Hz, %i bit, %s)", fileName, wave.sampleRate, wave.sampleSize, (wave.channels == 1) ? "Mono" : "Stereo");
+    else TraceLog(LOG_INFO, "[%s] MP3 file loaded successfully (%i Hz, %i bit, %s)", fileName, wave.sampleRate, wave.sampleSize, (wave.channels == 1)? "Mono" : "Stereo");
 
     return wave;
 }

+ 5 - 5
src/rlgl.h

@@ -775,8 +775,8 @@ typedef struct DrawCall {
     #endif
     "void main() \n"
     "{ \n"
-    "   vec2 lensCenter = fragTexCoord.x < 0.5 ? leftLensCenter : rightLensCenter; \n"
-    "   vec2 screenCenter = fragTexCoord.x < 0.5 ? leftScreenCenter : rightScreenCenter; \n"
+    "   vec2 lensCenter = fragTexCoord.x < 0.5? leftLensCenter : rightLensCenter; \n"
+    "   vec2 screenCenter = fragTexCoord.x < 0.5? leftScreenCenter : rightScreenCenter; \n"
     "   vec2 theta = (fragTexCoord - lensCenter)*scaleIn; \n"
     "   float rSq = theta.x*theta.x + theta.y*theta.y; \n"
     "   vec2 theta1 = theta*(hmdWarpParam.x + hmdWarpParam.y*rSq + hmdWarpParam.z*rSq*rSq + hmdWarpParam.w*rSq*rSq*rSq); \n"
@@ -1136,7 +1136,7 @@ void rlEnd(void)
     // TODO: System could be improved (a bit) just storing every draw alignment value
     // and adding it to vertexOffset on drawing... maybe in a future...
     int vertexCount = draws[drawsCounter - 1].vertexCount;
-    int vertexToAlign = (vertexCount >= 4) ? vertexCount%4 : (4 - vertexCount%4);
+    int vertexToAlign = (vertexCount >= 4)? vertexCount%4 : (4 - vertexCount%4);
     for (int i = 0; i < vertexToAlign; i++) rlVertex3f(-1, -1, -1);
 
     // Make sure vertexCount is the same for vertices, texcoords, colors and normals
@@ -1233,7 +1233,7 @@ void rlTexCoord2f(float x, float y)
 }
 
 // Define one vertex (normal)
-// NOTE: Normals limited to TRIANGLES only ?
+// NOTE: Normals limited to TRIANGLES only?
 void rlNormal3f(float x, float y, float z)
 {
     // TODO: Normals usage...
@@ -2206,7 +2206,7 @@ RenderTexture2D rlLoadRenderTexture(int width, int height, int format, int depth
         target.depth.id = rlLoadTextureDepth(width, height, depthBits, !useDepthTexture);
         target.depth.width = width;
         target.depth.height = height;
-        target.depth.format = 19;       //DEPTH_COMPONENT_24BIT ?
+        target.depth.format = 19;       //DEPTH_COMPONENT_24BIT?
         target.depth.mipmaps = 1;
     }
     //-----------------------------------------------------------------------------------------------------

+ 1 - 1
src/shapes.c

@@ -132,7 +132,7 @@ void DrawLineEx(Vector2 startPos, Vector2 endPos, float thick, Color color)
     rlPushMatrix();
         rlTranslatef((float)startPos.x, (float)startPos.y, 0.0f);
         rlRotatef(RAD2DEG*angle, 0.0f, 0.0f, 1.0f);
-        rlTranslatef(0, (thick > 1.0f) ? -thick/2.0f : -1.0f, 0.0f);
+        rlTranslatef(0, (thick > 1.0f)? -thick/2.0f : -1.0f, 0.0f);
 
         rlBegin(RL_QUADS);
             rlColor4ub(color.r, color.g, color.b, color.a);

+ 5 - 5
src/text.c

@@ -306,7 +306,7 @@ Font LoadFontEx(const char *fileName, int fontSize, int *fontChars, int charsCou
     Font font = { 0 };
 
     font.baseSize = fontSize;
-    font.charsCount = (charsCount > 0) ? charsCount : 95;
+    font.charsCount = (charsCount > 0)? charsCount : 95;
     font.chars = LoadFontData(fileName, font.baseSize, fontChars, font.charsCount, FONT_DEFAULT);
 
 #if defined(SUPPORT_FILEFORMAT_TTF)
@@ -483,7 +483,7 @@ CharInfo *LoadFontData(const char *fileName, int fontSize, int *fontChars, int c
         stbtt_GetFontVMetrics(&fontInfo, &ascent, &descent, &lineGap);
 
         // In case no chars count provided, default to 95
-        charsCount = (charsCount > 0) ? charsCount : 95;
+        charsCount = (charsCount > 0)? charsCount : 95;
 
         // Fill fontChars in case not provided externally
         // NOTE: By default we fill charsCount consecutevely, starting at 32 (Space)
@@ -557,7 +557,7 @@ Image GenImageFontAtlas(CharInfo *chars, int charsCount, int fontSize, int paddi
     Image atlas = { 0 };
 
     // In case no chars count provided we suppose default of 95
-    charsCount = (charsCount > 0) ? charsCount : 95;
+    charsCount = (charsCount > 0)? charsCount : 95;
 
     // Calculate image size based on required pixel area
     // NOTE 1: Image is forced to be squared and POT... very conservative!
@@ -856,7 +856,7 @@ void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, f
 
             if ((textOffsetX + glyphWidth + 1) >= rec.width)
             {
-                endLine = (endLine < 1) ? i : endLine;
+                endLine = (endLine < 1)? i : endLine;
                 if (i == endLine) endLine -= 1;
                 if ((startLine + 1) == endLine) endLine = i - 1;
                 state = !state;
@@ -916,7 +916,7 @@ void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, f
                                    rec.y + textOffsetY + font.chars[index].offsetY*scaleFactor,
                                    font.chars[index].rec.width*scaleFactor,
                                    font.chars[index].rec.height*scaleFactor }, (Vector2){ 0, 0 }, 0.0f,
-                                   (!isGlyphSelected) ? tint : selectText);
+                                   (!isGlyphSelected)? tint : selectText);
                 }
             }
 

+ 4 - 4
src/textures.c

@@ -588,7 +588,7 @@ Vector4 *GetImageDataNormalized(Image image)
                     pixels[i].x = (float)((pixel & 0b1111100000000000) >> 11)*(1.0f/31);
                     pixels[i].y = (float)((pixel & 0b0000011111000000) >> 6)*(1.0f/31);
                     pixels[i].z = (float)((pixel & 0b0000000000111110) >> 1)*(1.0f/31);
-                    pixels[i].w = ((pixel & 0b0000000000000001) == 0) ? 0.0f : 1.0f;
+                    pixels[i].w = ((pixel & 0b0000000000000001) == 0)? 0.0f : 1.0f;
 
                 } break;
                 case UNCOMPRESSED_R5G6B5:
@@ -814,7 +814,7 @@ void ExportImageAsCode(Image image, const char *fileName)
     fprintf(txtFile, "#define %s_FORMAT   %i          // raylib internal pixel format\n\n", varFileName, image.format);
 
     fprintf(txtFile, "static unsigned char %s_DATA[%i] = { ", varFileName, dataSize);
-    for (int i = 0; i < dataSize - 1; i++) fprintf(txtFile, ((i%BYTES_TEXT_PER_LINE == 0) ? "0x%x,\n" : "0x%x, "), ((unsigned char *)image.data)[i]);
+    for (int i = 0; i < dataSize - 1; i++) fprintf(txtFile, ((i%BYTES_TEXT_PER_LINE == 0)? "0x%x,\n" : "0x%x, "), ((unsigned char *)image.data)[i]);
     fprintf(txtFile, "0x%x };\n", ((unsigned char *)image.data)[dataSize - 1]);
 
     fclose(txtFile);
@@ -984,7 +984,7 @@ void ImageFormat(Image *image, int newFormat)
                         r = (unsigned char)(round(pixels[i].x*31.0f));
                         g = (unsigned char)(round(pixels[i].y*31.0f));
                         b = (unsigned char)(round(pixels[i].z*31.0f));
-                        a = (pixels[i].w > ((float)ALPHA_THRESHOLD/255.0f)) ? 1 : 0;
+                        a = (pixels[i].w > ((float)ALPHA_THRESHOLD/255.0f))? 1 : 0;
 
                         ((unsigned short *)image->data)[i] = (unsigned short)r << 11 | (unsigned short)g << 6 | (unsigned short)b << 1 | (unsigned short)a;
                     }
@@ -2231,7 +2231,7 @@ Image GenImageGradientH(int width, int height, Color left, Color right)
 Image GenImageGradientRadial(int width, int height, float density, Color inner, Color outer)
 {
     Color *pixels = (Color *)malloc(width*height*sizeof(Color));
-    float radius = (width < height) ? (float)width/2.0f : (float)height/2.0f;
+    float radius = (width < height)? (float)width/2.0f : (float)height/2.0f;
 
     float centerX = (float)width/2.0f;
     float centerY = (float)height/2.0f;