From 63568721f9aace1a6f4c232d49b490ebb473b510 Mon Sep 17 00:00:00 2001 From: veclavtalica <75177764+quantumedbox@users.noreply.github.com> Date: Fri, 24 Jun 2022 13:59:31 +0500 Subject: [PATCH] fix: precision loss, discard unused (#2541) --- src/raudio.c | 4 ++-- src/rmodels.c | 13 +++++-------- src/rtext.c | 4 ++-- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/raudio.c b/src/raudio.c index b132bfa71..19ecc1626 100644 --- a/src/raudio.c +++ b/src/raudio.c @@ -1625,7 +1625,7 @@ void UnloadMusicStream(Music music) else if (music.ctxType == MUSIC_AUDIO_FLAC) drflac_free((drflac *)music.ctxData, NULL); #endif #if defined(SUPPORT_FILEFORMAT_MP3) - else if (music.ctxType == MUSIC_AUDIO_MP3) { drmp3_uninit((drmp3 *)music.ctxData); RL_FREE(music.ctxData); } + else if (music.ctxType == MUSIC_AUDIO_MP3) { drmp3_uninit((drmp3 *)music.ctxData); RL_FREE(music.ctxData); } #endif #if defined(SUPPORT_FILEFORMAT_XM) else if (music.ctxType == MUSIC_MODULE_XM) jar_xm_free_context((jar_xm_context_t *)music.ctxData); @@ -2221,7 +2221,7 @@ static ma_uint32 ReadAudioBufferFramesInMixingFormat(AudioBuffer *audioBuffer, f ma_uint64 outputFramesToProcessThisIteration = frameCount - totalOutputFramesProcessed; ma_uint64 inputFramesToProcessThisIteration = 0; - ma_result result = ma_data_converter_get_required_input_frame_count(&audioBuffer->converter, outputFramesToProcessThisIteration, &inputFramesToProcessThisIteration); + (void)ma_data_converter_get_required_input_frame_count(&audioBuffer->converter, outputFramesToProcessThisIteration, &inputFramesToProcessThisIteration); if (inputFramesToProcessThisIteration > inputBufferFrameCap) { inputFramesToProcessThisIteration = inputBufferFrameCap; diff --git a/src/rmodels.c b/src/rmodels.c index 96af9f83f..d3614cb59 100644 --- a/src/rmodels.c +++ b/src/rmodels.c @@ -2630,7 +2630,7 @@ Mesh GenMeshKnot(float radius, float size, int radSeg, int sides) // NOTE: Vertex data is uploaded to GPU Mesh GenMeshHeightmap(Image heightmap, Vector3 size) { - #define GRAY_VALUE(c) ((c.r+c.g+c.b)/3) + #define GRAY_VALUE(c) ((c.r+c.g+c.b)/3.0f) Mesh mesh = { 0 }; @@ -2653,8 +2653,6 @@ Mesh GenMeshHeightmap(Image heightmap, Vector3 size) int tcCounter = 0; // Used to count texcoords float by float int nCounter = 0; // Used to count normals float by float - int trisCounter = 0; - Vector3 scaleFactor = { size.x/mapX, size.y/255.0f, size.z/mapZ }; Vector3 vA = { 0 }; @@ -2671,15 +2669,15 @@ Mesh GenMeshHeightmap(Image heightmap, Vector3 size) // one triangle - 3 vertex mesh.vertices[vCounter] = (float)x*scaleFactor.x; - mesh.vertices[vCounter + 1] = (float)GRAY_VALUE(pixels[x + z*mapX])*scaleFactor.y; + mesh.vertices[vCounter + 1] = GRAY_VALUE(pixels[x + z*mapX])*scaleFactor.y; mesh.vertices[vCounter + 2] = (float)z*scaleFactor.z; mesh.vertices[vCounter + 3] = (float)x*scaleFactor.x; - mesh.vertices[vCounter + 4] = (float)GRAY_VALUE(pixels[x + (z + 1)*mapX])*scaleFactor.y; + mesh.vertices[vCounter + 4] = GRAY_VALUE(pixels[x + (z + 1)*mapX])*scaleFactor.y; mesh.vertices[vCounter + 5] = (float)(z + 1)*scaleFactor.z; mesh.vertices[vCounter + 6] = (float)(x + 1)*scaleFactor.x; - mesh.vertices[vCounter + 7] = (float)GRAY_VALUE(pixels[(x + 1) + z*mapX])*scaleFactor.y; + mesh.vertices[vCounter + 7] = GRAY_VALUE(pixels[(x + 1) + z*mapX])*scaleFactor.y; mesh.vertices[vCounter + 8] = (float)z*scaleFactor.z; // another triangle - 3 vertex @@ -2692,7 +2690,7 @@ Mesh GenMeshHeightmap(Image heightmap, Vector3 size) mesh.vertices[vCounter + 14] = mesh.vertices[vCounter + 5]; mesh.vertices[vCounter + 15] = (float)(x + 1)*scaleFactor.x; - mesh.vertices[vCounter + 16] = (float)GRAY_VALUE(pixels[(x + 1) + (z + 1)*mapX])*scaleFactor.y; + mesh.vertices[vCounter + 16] = GRAY_VALUE(pixels[(x + 1) + (z + 1)*mapX])*scaleFactor.y; mesh.vertices[vCounter + 17] = (float)(z + 1)*scaleFactor.z; vCounter += 18; // 6 vertex, 18 floats @@ -2749,7 +2747,6 @@ Mesh GenMeshHeightmap(Image heightmap, Vector3 size) } nCounter += 18; // 6 vertex, 18 floats - trisCounter += 2; } } diff --git a/src/rtext.c b/src/rtext.c index b9dc5e9d6..722dbb1d7 100644 --- a/src/rtext.c +++ b/src/rtext.c @@ -1051,7 +1051,7 @@ void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, f { // NOTE: Fixed line spacing of 1.5 line-height // TODO: Support custom line spacing defined by user - textOffsetY += (int)((font.baseSize + font.baseSize/2)*scaleFactor); + textOffsetY += (int)((font.baseSize + font.baseSize/2.0f)*scaleFactor); textOffsetX = 0.0f; } else @@ -1123,7 +1123,7 @@ void DrawTextCodepoints(Font font, const int *codepoints, int count, Vector2 pos { // NOTE: Fixed line spacing of 1.5 line-height // TODO: Support custom line spacing defined by user - textOffsetY += (int)((font.baseSize + font.baseSize/2)*scaleFactor); + textOffsetY += (int)((font.baseSize + font.baseSize/2.0f)*scaleFactor); textOffsetX = 0.0f; } else