WIP: Ça s'éclaircit: il faut une table d'initialisation des flèches et une table d'état (variable selon les 'set_arrow()') Yep !

This commit is contained in:
Jean Sirmai 2023-09-25 23:44:15 +02:00
parent 38480de7ae
commit 7c7bde073d
Signed by: jean
GPG Key ID: FB3115C340E057E3
1 changed files with 113 additions and 21 deletions

View File

@ -38,9 +38,9 @@ static GLuint *buffer_lines_origin = NULL;
static GLuint *buffer_plans_origin = NULL; static GLuint *buffer_plans_origin = NULL;
static volatile int buffer_vertex_size = 0; static volatile int buffer_vertex_size = 0;
static int buffer_colors_size = 0; static volatile int buffer_lines_size = 0;
static int buffer_lines_size = 0; static volatile int buffer_colors_size = 0;
static int buffer_plans_size = 0; static volatile int buffer_plans_size = 0;
// model_data_and_user_preferences : // model_data_and_user_preferences :
@ -56,8 +56,8 @@ static int zzz = 0;
// par model_space_size_x, y, z et le nombre de sites // par model_space_size_x, y, z et le nombre de sites
static GLuint arrows[] = { static GLuint arrows[] = {
1, 0, 0, 0, 0, 1, 0, 0, 0, 0,
1, 1, 0, 0, 0, /* 1, 1, 0, 0, 0, */
1, 1, 1, 0, 0, /* 1, 1, 1, 0, 0, */
/* 1, 2, 0, 0, 0, */ /* 1, 2, 0, 0, 0, */
/* 1, 3, 0, 0, 0, */ /* 1, 3, 0, 0, 0, */
/* 1, 4, 0, 0, 0, */ /* 1, 4, 0, 0, 0, */
@ -82,7 +82,7 @@ static void show_user_choices(int space_size_x,
if (prefer == 1) printf("prefer = %d <> show no grid", prefer); if (prefer == 1) printf("prefer = %d <> show no grid", prefer);
if (prefer > 1) printf("pref_show_grids = %d", prefer); if (prefer > 1) printf("pref_show_grids = %d", prefer);
if (show_all) { if (show_all) {
printf("\tbuffer_vertex_size = %d\t lines = %d", buffer_vertex_size, buffer_lines_size); printf("\n\t\t\t\t\tbuffer_vertex_size = %d\t buffer_lines_size = %d", buffer_vertex_size, buffer_lines_size);
if (arrows_nb > 0) printf("\n [%2d] load | site x y z \n -------------------------------", arrows_nb); if (arrows_nb > 0) printf("\n [%2d] load | site x y z \n -------------------------------", arrows_nb);
for (int i = 0; i < arrows_nb; i++) printf("\n [%2d] = %2d | %2d %2d %2d %2d",\ for (int i = 0; i < arrows_nb; i++) printf("\n [%2d] = %2d | %2d %2d %2d %2d",\
i, *(arrows + i * 5 + 0), *(arrows + i * 5 + 1), *(arrows + i * 5 + 2), *(arrows + i * 5 + 3), *(arrows + i * 5 + 4)); i, *(arrows + i * 5 + 0), *(arrows + i * 5 + 1), *(arrows + i * 5 + 2), *(arrows + i * 5 + 3), *(arrows + i * 5 + 4));
@ -108,10 +108,38 @@ static void get_model_data_and_user_preferences()
#define DETAIL 0
static bool rewrite_arrow (int address, int weight, int site, int x, int y, int z) static bool rewrite_arrow (int address, int weight, int site, int x, int y, int z)
{ {
if (DETAIL) printf("write the arrow weight to %d at (%d, %d, %d, %d)\n",\ if (0) printf("write the arrow weight to %d at (%d, %d, %d, %d)\n",\
weight, site, x, y, z); weight, site, x, y, z);
*(arrows + address + 0) = weight; *(arrows + address + 0) = weight;
@ -137,9 +165,9 @@ static bool create_arrow (int weight, int site, int x, int y, int z)
static bool erase_arrow (int address, int site, int x, int y, int z) static bool erase_arrow (int address, int site, int x, int y, int z)
{ {
int arrows_nb = get_arrows_nb(); int arrows_nb = get_arrows_nb();
if (1) printf("erase arrow at address %d with values (%d, %d, %d, %d)",\ if (0) printf("erase arrow at address %d with values (%d, %d, %d, %d)",\
address / 5, site, x, y, z); address / 5, site, x, y, z);
if (1) printf(" last arrow is %d, %d, %d, %d, %d\n", if (0) printf(" last arrow is %d, %d, %d, %d, %d\n",
*(arrows + (arrows_nb - 1) * 5 + 0), *(arrows + (arrows_nb - 1) * 5 + 0),
*(arrows + (arrows_nb - 1) * 5 + 1), *(arrows + (arrows_nb - 1) * 5 + 1),
*(arrows + (arrows_nb - 1) * 5 + 2), *(arrows + (arrows_nb - 1) * 5 + 2),
@ -163,13 +191,13 @@ static void show_arrows_array (int arrows_nb, int address, int current_weigh, in
{ {
printf("\nset_arrow (%d | %2d %2d %2d %2d) <> ", weight, site, x, y, z); printf("\nset_arrow (%d | %2d %2d %2d %2d) <> ", weight, site, x, y, z);
if (arrows_nb == 0 && weight == 0) printf("no arrow in space + no arrows to be created > end function set_arrow()\n"); if (arrows_nb == 0 && weight == 0) printf("buffer_lines : %d\tno arrow in space + no arrows to be created > end function set_arrow()\n", buffer_lines_size);
if (address == -1 && weight == 0) printf("arrow not found + no arrows to be created > end function set_arrow()\n"); if (address == -1 && weight == 0) printf("buffer_lines : %d\tarrow not found + no arrows to be created > end function set_arrow()\n", buffer_lines_size);
if (address == -1 && weight > 0) printf("arrow not found > new arrow will be created at line [%d]\n", arrows_nb); if (address == -1 && weight > 0) printf("buffer_lines : %d\tarrow not found > new arrow will be created at line [%d]\n", buffer_lines_size, arrows_nb);
if (address >= 0 && weight == 0) printf("arrow found at line [%d] > will be erased\n", address / 5); if (address >= 0 && weight == 0) printf("buffer_lines : %d\tarrow found at line [%d] > will be erased\n", buffer_lines_size, address / 5);
if (address >= 0 && weight > 0) { if (address >= 0 && weight > 0) {
if (current_weigh != weight) printf("arrow found at line [%d] > will be modified\n", address / 5); if (current_weigh != weight) printf("buffer_lines : %d\tarrow found at line [%d] > will be modified\n", buffer_lines_size, address / 5);
if (current_weigh == weight) printf("arrow found at line [%d] > will not be modified\n", address / 5); if (current_weigh == weight) printf("buffer_lines : %d\tarrow found at line [%d] > will not be modified\n", buffer_lines_size, address / 5);
} }
printf(" [rank] load | site x y z\n"); printf(" [rank] load | site x y z\n");
@ -192,6 +220,25 @@ static void show_arrows_array (int arrows_nb, int address, int current_weigh, in
} }
} }
static int set_arrow (int weight, int site, int x, int y, int z) static int set_arrow (int weight, int site, int x, int y, int z)
{ {
@ -241,6 +288,43 @@ static int set_arrow (int weight, int site, int x, int y, int z)
@ -772,6 +856,7 @@ void main_test_graphics (void)
if (pref_show_grids > 0) grid_write_ridges (xxx, yyy, zzz); if (pref_show_grids > 0) grid_write_ridges (xxx, yyy, zzz);
int offset_after_grids = buffer_vertex_size / 3; int offset_after_grids = buffer_vertex_size / 3;
int buffer_lines_size_after_cubes = buffer_lines_size;
/* ARROWS */ /* ARROWS */
arrows_write_terminations (xxx, yyy, zzz); arrows_write_terminations (xxx, yyy, zzz);
@ -797,9 +882,9 @@ void main_test_graphics (void)
} }
} }
set_arrow (0, 1, 1, 0, 0); /* set_arrow (0, 1, 1, 0, 0); */
set_arrow (0, 1, 0, 0, 0); /* set_arrow (0, 1, 0, 0, 0); */
set_arrow (0, 0, 0, 0, 0); /* set_arrow (0, 0, 0, 0, 0); */
/* set_arrow (1, 0, 1, 0, 0); */ /* set_arrow (1, 0, 1, 0, 0); */
/* set_arrow (1, 1, 1, 0, 0); */ /* set_arrow (1, 1, 1, 0, 0); */
@ -807,11 +892,18 @@ void main_test_graphics (void)
int offset_after_arrows = buffer_vertex_size / 3, difference = offset_after_arrows - offset_after_grids; int offset_after_arrows = buffer_vertex_size / 3, difference = offset_after_arrows - offset_after_grids;
if (1) printf("\nbuffer_vertex_offset_after grids = %d (x+1)*(y+1)*(z+1) = %d (x,y,z = %d,%d,%d)",\ if (1) printf("\nbuffer_vertex_offset_after grids = %d\t\t(x+1)*(y+1)*(z+1) = %d (x,y,z = %d,%d,%d)",\
offset_after_grids, (xxx + 1)*(yyy + 1)*(zzz + 1), xxx, yyy, zzz); offset_after_grids, (xxx + 1)*(yyy + 1)*(zzz + 1), xxx, yyy, zzz);
if (1) printf("\nbuffer_vertex_offset_after arrows = %d (%d - %d = %d, %d / 12 <> %d cubes)\n",\ if (1) printf("\nbuffer_vertex_offset_after arrows = %d\t\t(%d - %d = %d, %d / 12 <> %d cubes)",\
offset_after_arrows, offset_after_arrows, offset_after_grids,\ offset_after_arrows, offset_after_arrows, offset_after_grids,\
difference, difference, difference / 12); difference, difference, difference / 12);
if (1) printf("\nbuffer_lines_size after cubes = %d\t\t(%d x %d = %d\t%d x %d = %d\t%d x %d = %d\t%d + %d + %d = %d x 2 = %d)",\
buffer_lines_size_after_cubes, xxx+1, yyy+1, (xxx+1) * (yyy+1), xxx+1, zzz+1, (xxx+1) * (zzz+1), yyy+1, zzz+1, (yyy+1) * (zzz+1),\
(xxx+1) * (yyy+1), (xxx+1) * (zzz+1), (yyy+1) * (zzz+1), (xxx+1) * (yyy+1) + (xxx+1) * (zzz+1) + (yyy+1) * (zzz+1),\
((xxx+1) * (yyy+1) + (xxx+1) * (zzz+1) + (yyy+1) * (zzz+1)) * 2);
if (1) printf("\nbuffer_lines_size after arrows = %d\t\t(%d - %d = %d;\t3 + 4 = 7\t7 x 2 = 14\n", buffer_lines_size,\
buffer_lines_size, buffer_lines_size_after_cubes, buffer_lines_size - buffer_lines_size_after_cubes);
if (0) printf("main_test_graphics [ok]\n"); if (0) printf("main_test_graphics [ok]\n");
} }