diff --git a/include/grid.h b/include/grid.h index 05b982c..745bd30 100644 --- a/include/grid.h +++ b/include/grid.h @@ -29,7 +29,7 @@ void write_space_ridges (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z); -void write_space_faces_grids (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z, int style); +void write_grids_on_space_faces (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z, int style); /* * Writes grid lines intersections to vertex and color buffers diff --git a/src/graphics/graphics.c b/src/graphics/graphics.c index 2a437ff..f482059 100644 --- a/src/graphics/graphics.c +++ b/src/graphics/graphics.c @@ -895,7 +895,7 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void) write_space_ridges (offset_vertex, offset_colors, offset_lines, space_X, space_Y, space_Z); offset_vertex = 8, offset_colors = 8, offset_lines = 12; // if space edges are drawn - write_space_faces_grids (offset_vertex, offset_colors, offset_lines, space_X, space_Y, space_Z, style); + write_grids_on_space_faces (offset_vertex, offset_colors, offset_lines, space_X, space_Y, space_Z, style); /* ARROWS */ diff --git a/src/graphics/grid.c b/src/graphics/grid.c index ab181dc..233dfb7 100644 --- a/src/graphics/grid.c +++ b/src/graphics/grid.c @@ -59,11 +59,11 @@ void write_space_ridges (long offset_vertex, long offset_colors, long offset_lin graphics_write_line ( 2, 6); graphics_write_line ( 3, 6); } -void write_space_faces_grids (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z, int style) +void write_grids_on_space_faces (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z, int style) { float i, max = fmax(x, y); max = fmax(max, z); - if (style != 1) for (i = 1; i < x; i++) { // (x - 2) * 4 + for (i = 1; i < x; i++) { // (x - 2) * 4 graphics_write_vertex ((2 * i / x - 1) * x / max, - y / max, - z / max); graphics_write_vertex ((2 * i / x - 1) * x / max, - y / max, z / max); @@ -76,17 +76,19 @@ void write_space_faces_grids (long offset_vertex, long offset_colors, long offse graphics_write_color (0.5f, 0.5f, 0.5f); } - if (style != 1) for (i = 0; i < x; i ++) { + for (i = 0; i < x - 1; i ++) { - graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1); + if (style != 1) + graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1); graphics_write_line (offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2); graphics_write_line (offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3); - graphics_write_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0); + if (style != 1) + graphics_write_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0); } - if (style != 1) offset_vertex += (x - 1) * 4; - if (style != 1) offset_colors += (x - 1) * 4; - if (style != 1) offset_lines += 0; else offset_lines += (x - 1) * 4; + offset_vertex += (x - 1) * 4; + offset_colors += (x - 1) * 4; + if (style != 1) offset_lines += 2; else offset_lines += (x - 1) * 4; for (i = 1; i < y; i++) { // (y - 2) * 4 @@ -104,15 +106,16 @@ void write_space_faces_grids (long offset_vertex, long offset_colors, long offse for (i = 0; i < y - 1; i ++) { if (style != 1) - graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1); - graphics_write_line (offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2); + graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1); + if (style != 1) + graphics_write_line (offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2); graphics_write_line (offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3); graphics_write_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0); } offset_vertex += (y - 1) * 4; offset_colors += (y - 1) * 4; - if (style != 1) offset_lines += (x - 1) * 3; else offset_lines += (x - 1) * 4; + if (style != 1) offset_lines += (x - 1) * 2; else offset_lines += (x - 1) * 4; for (i = 1; i < z; i++) { // (z - 2) * 4 @@ -127,12 +130,13 @@ void write_space_faces_grids (long offset_vertex, long offset_colors, long offse graphics_write_color (0.5f, 0.5f, 0.5f); } - for (i = 0; i <= z; i ++) { + for (i = 0; i < z - 1; i ++) { graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1); - graphics_write_line (offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2); - if (! style) - graphics_write_line (offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3); + if (style != 1) + graphics_write_line (offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2); + if (style != 1) + graphics_write_line (offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3); graphics_write_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0); } }