Просмотр исходного кода

various fixes for clang
also fix a comment typo

Sean Barrett 6 лет назад
Родитель
Сommit
5fe7fb52f2
5 измененных файлов с 22 добавлено и 32 удалено
  1. 6 5
      stb_divide.h
  2. 1 1
      stb_image.h
  3. 5 3
      stb_tilemap_editor.h
  4. 0 13
      stb_truetype.h
  5. 10 10
      stb_voxel_render.h

+ 6 - 5
stb_divide.h

@@ -163,20 +163,21 @@ int stb_div_floor(int v1, int v2)
    #ifdef C_INTEGER_DIVISION_FLOORS
    return v1/v2;
    #else
-   if (v1 >= 0 && v2 < 0)
+   if (v1 >= 0 && v2 < 0) {
       if ((-v1)+v2+1 < 0) // check if increasing v1's magnitude overflows
          return -stb__div(-v1+v2+1,v2); // nope, so just compute it
       else
          return -stb__div(-v1,v2) + ((-v1)%v2 ? -1 : 0);
-   if (v1 < 0 && v2 >= 0)
-      if (v1 != INT_MIN)
+   }
+   if (v1 < 0 && v2 >= 0) {
+      if (v1 != INT_MIN) {
          if (v1-v2+1 < 0) // check if increasing v1's magnitude overflows
             return -stb__div(v1-v2+1,-v2); // nope, so just compute it
          else
             return -stb__div(-v1,v2) + (stb__mod(v1,-v2) ? -1 : 0);
-      else // it must be possible to compute -(v1+v2) without overflowing
+      } else // it must be possible to compute -(v1+v2) without overflowing
          return -stb__div(-(v1+v2),v2) + (stb__mod(-(v1+v2),v2) ? -2 : -1);
-   else
+   } else
       return v1/v2;           // same sign, so expect truncation
    #endif
 }

+ 1 - 1
stb_image.h

@@ -168,7 +168,7 @@ RECENT REVISION HISTORY:
 //   If compiling for Windows and you wish to use Unicode filenames, compile
 //   with
 //       #define STBI_WINDOWS_UTF8
-//   and pass utf8-encoded filenames. Call stbiw_convert_wchar_to_utf8 to convert
+//   and pass utf8-encoded filenames. Call stbi_convert_wchar_to_utf8 to convert
 //   Windows wchar_t filenames to utf8.
 //
 // ===========================================================================

+ 5 - 3
stb_tilemap_editor.h

@@ -1061,8 +1061,9 @@ stbte_tilemap *stbte_create_map(int map_x, int map_y, int map_layers, int spacin
 void stbte_set_background_tile(stbte_tilemap *tm, short id)
 {
    int i;
-   STBTE_ASSERT(id >= -1 && id < 32768);
-   if (id >= 32768 || id < -1)
+   STBTE_ASSERT(id >= -1);
+   // STBTE_ASSERT(id < 32768);
+   if (id < -1)
       return;
    for (i=0; i < STBTE_MAX_TILEMAP_X * STBTE_MAX_TILEMAP_Y; ++i)
       if (tm->data[0][i][0] == -1)
@@ -1222,7 +1223,8 @@ void stbte_set_tile(stbte_tilemap *tm, int x, int y, int layer, signed short til
 {
    STBTE_ASSERT(x >= 0 && x < tm->max_x && y >= 0 && y < tm->max_y);
    STBTE_ASSERT(layer >= 0 && layer < tm->num_layers);
-   STBTE_ASSERT(tile >= -1 && tile < 32768);
+   STBTE_ASSERT(tile >= -1);
+   //STBTE_ASSERT(tile < 32768);
    if (x < 0 || x >= STBTE_MAX_TILEMAP_X || y < 0 || y >= STBTE_MAX_TILEMAP_Y)
       return;
    if (layer < 0 || layer >= tm->num_layers || tile < -1)

+ 0 - 13
stb_truetype.h

@@ -243,19 +243,6 @@
 //   recommend it.
 //
 //
-// SOURCE STATISTICS (based on v0.6c, 2050 LOC)
-//
-//   Documentation & header file        520 LOC  )___ 660 LOC documentation
-//   Sample code                        140 LOC  )
-//   Truetype parsing                   620 LOC  ---- 620 LOC TrueType
-//   Software rasterization             240 LOC  )
-//   Curve tessellation                 120 LOC  )___ 550 LOC Bitmap creation
-//   Bitmap management                  100 LOC  )
-//   Baked bitmap interface              70 LOC  )
-//   Font name matching & access        150 LOC  ---- 150 
-//   C runtime library abstraction       60 LOC  ----  60
-//
-//
 // PERFORMANCE MEASUREMENTS FOR 1.06:
 //
 //                      32-bit     64-bit

+ 10 - 10
stb_voxel_render.h

@@ -2370,16 +2370,16 @@ static unsigned short stbvox_face_visible[STBVOX_FT_count] =
 {
    // we encode the table by listing which cases cause *obscuration*, and bitwise inverting that
    // table is pre-shifted by 5 to save a shift when it's accessed
-   (unsigned short) ((~0x07ff                                          )<<5),  // none is completely obscured by everything
-   (unsigned short) ((~((1<<STBVOX_FT_solid) | (1<<STBVOX_FT_upper)   ))<<5),  // upper
-   (unsigned short) ((~((1<<STBVOX_FT_solid) | (1<<STBVOX_FT_lower)   ))<<5),  // lower
-   (unsigned short) ((~((1<<STBVOX_FT_solid)                          ))<<5),  // solid is only completely obscured only by solid
-   (unsigned short) ((~((1<<STBVOX_FT_solid) | (1<<STBVOX_FT_diag_013)))<<5),  // diag012 matches diag013
-   (unsigned short) ((~((1<<STBVOX_FT_solid) | (1<<STBVOX_FT_diag_123)))<<5),  // diag023 matches diag123
-   (unsigned short) ((~((1<<STBVOX_FT_solid) | (1<<STBVOX_FT_diag_012)))<<5),  // diag013 matches diag012
-   (unsigned short) ((~((1<<STBVOX_FT_solid) | (1<<STBVOX_FT_diag_023)))<<5),  // diag123 matches diag023
-   (unsigned short) ((~0                                               )<<5),  // force is always rendered regardless, always forces neighbor
-   (unsigned short) ((~((1<<STBVOX_FT_solid)                          ))<<5),  // partial is only completely obscured only by solid
+   (unsigned short) ((~0x07ffu                                          )<<5),  // none is completely obscured by everything
+   (unsigned short) ((~((1u<<STBVOX_FT_solid) | (1<<STBVOX_FT_upper)   ))<<5),  // upper
+   (unsigned short) ((~((1u<<STBVOX_FT_solid) | (1<<STBVOX_FT_lower)   ))<<5),  // lower
+   (unsigned short) ((~((1u<<STBVOX_FT_solid)                          ))<<5),  // solid is only completely obscured only by solid
+   (unsigned short) ((~((1u<<STBVOX_FT_solid) | (1<<STBVOX_FT_diag_013)))<<5),  // diag012 matches diag013
+   (unsigned short) ((~((1u<<STBVOX_FT_solid) | (1<<STBVOX_FT_diag_123)))<<5),  // diag023 matches diag123
+   (unsigned short) ((~((1u<<STBVOX_FT_solid) | (1<<STBVOX_FT_diag_012)))<<5),  // diag013 matches diag012
+   (unsigned short) ((~((1u<<STBVOX_FT_solid) | (1<<STBVOX_FT_diag_023)))<<5),  // diag123 matches diag023
+   (unsigned short) ((~0u                                               )<<5),  // force is always rendered regardless, always forces neighbor
+   (unsigned short) ((~((1u<<STBVOX_FT_solid)                          ))<<5),  // partial is only completely obscured only by solid
 };
 
 // the vertex heights of the block types, in binary vertex order (zyx):