WIP: Bon. C'est encore la pagaille mais on y voit plus clair, déjà.
This commit is contained in:
parent
c053f02b6c
commit
45b9ac399c
|
@ -62,7 +62,7 @@ static void show_user_choices(GLuint *arrows, int arrows_nb,
|
||||||
if (show_all) {
|
if (show_all) {
|
||||||
printf("\n\t\t\t\t\t buffer_vertex_size = %d\t buffer_lines_size = %d", buffer_vertex_size, buffer_lines_size);
|
printf("\n\t\t\t\t\t buffer_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\
|
if (arrows_nb > 0) printf("\n [%2d] load | site x y z\
|
||||||
< Initial data\n -------------------------------", arrows_nb);
|
< initial data\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));
|
||||||
if (arrows_nb > 0) printf("\n -------------------------------");}
|
if (arrows_nb > 0) printf("\n -------------------------------");}
|
||||||
|
@ -70,7 +70,7 @@ static void show_user_choices(GLuint *arrows, int arrows_nb,
|
||||||
|
|
||||||
static void get_model_data_and_user_preferences(GLuint *arrows, int arrows_nb)
|
static void get_model_data_and_user_preferences(GLuint *arrows, int arrows_nb)
|
||||||
{
|
{
|
||||||
xxx = 2; // 0 < model_space_size_x
|
xxx = 8; // 0 < model_space_size_x
|
||||||
yyy = 1; // 0 < model_space_size_y
|
yyy = 1; // 0 < model_space_size_y
|
||||||
zzz = 1; // 0 < model_space_size_z
|
zzz = 1; // 0 < model_space_size_z
|
||||||
pref_show_grids = 0; // 0, 1, 2, 3, 5, 6, 10, 15, 30, etc
|
pref_show_grids = 0; // 0, 1, 2, 3, 5, 6, 10, 15, 30, etc
|
||||||
|
@ -112,47 +112,44 @@ static void get_model_data_and_user_preferences(GLuint *arrows, int arrows_nb)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void show_arrows_array (GLuint *arrows, int arrows_nb, int address, int current_weigh, int weight, int site, int x, int y, int z);
|
||||||
|
|
||||||
static bool rewrite_arrow (GLuint *arrows, int arrows_nb, int address, int weight, int site, int x, int y, int z)
|
static bool rewrite_arrow (GLuint *arrows, int arrows_nb, int address, int weight, int site, int x, int y, int z)
|
||||||
{
|
{
|
||||||
if (0) printf("write the arrow weight to %d at (%d, %d, %d, %d)\n",\
|
show_arrows_array(arrows, arrows_nb, address, *(arrows + address + 0), weight, site, x, y, z);
|
||||||
weight, site, x, y, z);
|
|
||||||
|
|
||||||
*(arrows + address + 0) = weight;
|
*(arrows + address + 0) = weight;
|
||||||
|
|
||||||
return 1; /* replaces the load of the existing arrow by the load 'weight' */
|
if (1) printf("the new arrow weight is %d at (%d, %d, %d, %d)\n", weight, site, x, y, z);
|
||||||
|
|
||||||
|
return 1; /* replaces the load of the existing arrow by the new load 'weight' */
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool create_arrow (GLuint *arrows, int arrows_nb, int weight, int site, int x, int y, int z)
|
static bool create_arrow (GLuint *arrows, int arrows_nb, int weight, int site, int x, int y, int z)
|
||||||
{
|
{
|
||||||
|
if (1) printf("creating the new arrow (%d, %d, %d, %d, %d)\n",\
|
||||||
|
weight, site, x, y, z);
|
||||||
|
|
||||||
buffer_lines_size += (3 + 4) * 2;
|
buffer_lines_size += (3 + 4) * 2;
|
||||||
buffer_lines_origin = g_realloc(buffer_lines_origin, buffer_lines_size * 2 * sizeof(GLuint));
|
buffer_lines_origin = g_realloc(buffer_lines_origin, buffer_lines_size * 2 * sizeof(GLuint));
|
||||||
|
|
||||||
printf("\nbuffer_lines_size = %d weight = %d site = %d x = %d y = %d z = %d ",\
|
|
||||||
buffer_lines_size, weight, site, x, y, z);
|
|
||||||
|
|
||||||
*(arrows + arrows_nb * 5 + 0) = weight;
|
*(arrows + arrows_nb * 5 + 0) = weight;
|
||||||
*(arrows + arrows_nb * 5 + 1) = site;
|
*(arrows + arrows_nb * 5 + 1) = site;
|
||||||
*(arrows + arrows_nb * 5 + 2) = x;
|
*(arrows + arrows_nb * 5 + 2) = x;
|
||||||
*(arrows + arrows_nb * 5 + 3) = y;
|
*(arrows + arrows_nb * 5 + 3) = y;
|
||||||
*(arrows + arrows_nb * 5 + 4) = z;
|
*(arrows + arrows_nb * 5 + 4) = z;
|
||||||
|
|
||||||
|
show_arrows_array(arrows, arrows_nb, -1, -1, weight, site, x, y, z);
|
||||||
|
printf("\nbuffer_lines_size = %d weight = %d site = %d x = %d y = %d z = %d ",\
|
||||||
|
buffer_lines_size, weight, site, x, y, z);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool erase_arrow (GLuint *arrows, int arrows_nb, int address, int site, int x, int y, int z)
|
static bool erase_arrow (GLuint *arrows, int arrows_nb, int address, int site, int x, int y, int z)
|
||||||
{
|
{
|
||||||
if (1) printf("erase arrow at address (%d) with values (%d, %d, %d, %d)",\
|
|
||||||
address / 5, site, x, y, z);
|
|
||||||
if (1) printf(" last arrow is %d, %d, %d, %d, %d\n",
|
|
||||||
*(arrows + (arrows_nb - 1) * 5 + 0),
|
|
||||||
*(arrows + (arrows_nb - 1) * 5 + 1),
|
|
||||||
*(arrows + (arrows_nb - 1) * 5 + 2),
|
|
||||||
*(arrows + (arrows_nb - 1) * 5 + 3),
|
|
||||||
*(arrows + (arrows_nb - 1) * 5 + 4));
|
|
||||||
|
|
||||||
arrows_nb --;
|
arrows_nb --;
|
||||||
|
|
||||||
if (arrows_nb > 0) {
|
if (arrows_nb > 0) {
|
||||||
*(arrows + address + 0) = *(arrows + arrows_nb * 5 + 0);
|
*(arrows + address + 0) = *(arrows + arrows_nb * 5 + 0);
|
||||||
*(arrows + address + 1) = *(arrows + arrows_nb * 5 + 1);
|
*(arrows + address + 1) = *(arrows + arrows_nb * 5 + 1);
|
||||||
|
@ -163,6 +160,12 @@ static bool erase_arrow (GLuint *arrows, int arrows_nb, int address, int site, i
|
||||||
buffer_lines_size -= (3 + 4) * 2;
|
buffer_lines_size -= (3 + 4) * 2;
|
||||||
buffer_lines_origin = g_realloc(buffer_lines_origin, buffer_lines_size * 2 * sizeof(GLuint));
|
buffer_lines_origin = g_realloc(buffer_lines_origin, buffer_lines_size * 2 * sizeof(GLuint));
|
||||||
|
|
||||||
|
show_arrows_array(arrows, arrows_nb, address, -1, 0, site, x, y, z);
|
||||||
|
|
||||||
|
if (1) printf("arrow previously at address (%d) with values (%d, %d, %d, %d) was erased;\
|
||||||
|
last arrow is now : (%d, %d, %d, %d, %d)\n", address / 5, site, x, y, z, *(arrows + (arrows_nb - 1) * 5 + 0),\
|
||||||
|
*(arrows + (arrows_nb - 1) * 5 + 1), *(arrows + (arrows_nb - 1) * 5 + 2), *(arrows + (arrows_nb - 1) * 5 + 3),\
|
||||||
|
*(arrows + (arrows_nb - 1) * 5 + 4));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,13 +173,13 @@ static void show_arrows_array (GLuint *arrows, int arrows_nb, int address, int c
|
||||||
{
|
{
|
||||||
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("buffer_lines : %d\tno arrow in space + no arrows to be created > end function set_arrow()\n", buffer_lines_size);
|
if (arrows_nb == 0 && weight == 0) printf("buffer_lines_size = %d\tno arrow in space + no arrows to be created > end function set_arrow()\n", buffer_lines_size);
|
||||||
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("buffer_lines_size = %d\tarrow not found + no arrows to be created > end function set_arrow()\n", buffer_lines_size);
|
||||||
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 == -1 && weight > 0) printf("buffer_lines_size = %d\tarrow not found > new arrow will be created at line [%d]\n", buffer_lines_size, arrows_nb);
|
||||||
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) printf("buffer_lines_size = %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("buffer_lines : %d\tarrow found at line [%d] > will be modified\n", buffer_lines_size, address / 5);
|
if (current_weigh != weight) printf("buffer_lines_size = %d\tarrow found at line [%d] > will be modified\n", buffer_lines_size, 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);
|
if (current_weigh == weight) printf("buffer_lines_size = %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");
|
||||||
|
@ -194,7 +197,7 @@ static void show_arrows_array (GLuint *arrows, int arrows_nb, int address, int c
|
||||||
*(arrows + i * 5 + 3), *(arrows + i * 5 + 4), address / 5);
|
*(arrows + i * 5 + 3), *(arrows + i * 5 + 4), address / 5);
|
||||||
if (weight > 0 && current_weigh == weight && i == address / 5) printf(" <");
|
if (weight > 0 && current_weigh == weight && i == address / 5) printf(" <");
|
||||||
if (weight == 0 && i > address / 5 && i < arrows_nb - 1) printf(" |");
|
if (weight == 0 && i > address / 5 && i < arrows_nb - 1) printf(" |");
|
||||||
if (weight == 0 && i == arrows_nb - 1 && i != address / 5) printf(" >>>|");
|
if (weight == 0 && i == arrows_nb - 1 && i != address / 5) printf(" |");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -238,12 +241,10 @@ static int set_arrow (GLuint *arrows, int arrows_nb, int weight, int site, int x
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
show_arrows_array(arrows, arrows_nb, address, current_weight, weight, site, x, y, z);
|
|
||||||
|
|
||||||
if (address == -1 && weight == 0) return 0;
|
if (address == -1 && weight == 0) return 0;
|
||||||
if (address == -1 && weight > 0) return create_arrow (arrows, arrows_nb, weight, site, x, y, z);
|
if (address == -1 && weight > 0) return create_arrow (arrows, arrows_nb, weight, site, x, y, z);
|
||||||
if (address >= 0 && weight == 0) return erase_arrow (arrows, arrows_nb, address, site, x, y, z);
|
if (address >= 0 && weight == 0) return erase_arrow (arrows, arrows_nb, address, site, x, y, z);
|
||||||
if (address >= 0 && weight > 0) return rewrite_arrow (arrows, arrows_nb, address, weight, site, x, y, z);
|
if (address >= 0 && current_weight != weight) return rewrite_arrow (arrows, arrows_nb, address, weight, site, x, y, z);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -824,16 +825,25 @@ void main_test_graphics (void)
|
||||||
|
|
||||||
// assert : l'emplacement des flèches est contraint
|
// assert : l'emplacement des flèches est contraint
|
||||||
// par model_space_size_x, y, z et le nombre de sites. TODO
|
// par model_space_size_x, y, z et le nombre de sites. TODO
|
||||||
// assert : pas de doublons de flèches. TODO
|
// assert : pas de doublons (une seule flèche max par site possible). TODO
|
||||||
|
|
||||||
int arrows[] = {
|
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, 0, 0, 0,
|
||||||
/* 1, 2, 0, 0, 0, */
|
// 1, 0, 2, 0, 0,
|
||||||
/* 1, 3, 0, 0, 0, */
|
1, 1, 1, 0, 0,
|
||||||
/* 1, 4, 0, 0, 0, */
|
1, 1, 2, 0, 0,
|
||||||
/* 1, 5, 0, 0, 0, */
|
1, 1, 3, 0, 0,
|
||||||
|
1, 1, 4, 0, 0,
|
||||||
|
1, 1, 5, 0, 0,
|
||||||
|
1, 1, 6, 0, 0,
|
||||||
|
1, 1, 7, 0, 0,
|
||||||
|
1, 0, 7, 0, 0,
|
||||||
|
// 1, 2, 0, 0, 0,
|
||||||
|
// 1, 3, 0, 0, 0,
|
||||||
|
// 1, 4, 0, 0, 0,
|
||||||
|
// 1, 5, 0, 0, 0,
|
||||||
// load, site, x, y, z
|
// load, site, x, y, z
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -859,6 +869,15 @@ void main_test_graphics (void)
|
||||||
|
|
||||||
arrows_write_terminations (xxx, yyy, zzz); // Independent of the number of arrows
|
arrows_write_terminations (xxx, yyy, zzz); // Independent of the number of arrows
|
||||||
|
|
||||||
|
set_arrow (arrows, arrows_nb, 0, 0, 0, 0, 0); arrows_nb --;
|
||||||
|
set_arrow (arrows, arrows_nb, 0, 0, 7, 0, 0); arrows_nb --;
|
||||||
|
// set_arrow (arrows, arrows_nb, 0, 1, 1, 0, 0); arrows_nb --;
|
||||||
|
// set_arrow (arrows, arrows_nb, 0, 1, 0, 0, 0); arrows_nb --;
|
||||||
|
|
||||||
|
// set_arrow (arrows, arrows_nb, 1, 0, 1, 0, 0); arrows_nb ++;
|
||||||
|
// set_arrow (arrows, arrows_nb, 1, 1, 1, 0, 0); arrows_nb ++;
|
||||||
|
// set_arrow (arrows, arrows_nb, 1, 0, 0, 0, 0); arrows_nb ++;
|
||||||
|
|
||||||
for (int i = 0; i < arrows_nb; i++) {
|
for (int i = 0; i < arrows_nb; i++) {
|
||||||
weight = arrows[i * 5 + 0];
|
weight = arrows[i * 5 + 0];
|
||||||
site = arrows[i * 5 + 1];
|
site = arrows[i * 5 + 1];
|
||||||
|
@ -878,14 +897,6 @@ void main_test_graphics (void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set_arrow (arrows, arrows_nb, 0, 1, 1, 0, 0); */
|
|
||||||
/* set_arrow (arrows, arrows_nb, 0, 1, 0, 0, 0); */
|
|
||||||
set_arrow (arrows, arrows_nb, 0, 0, 0, 0, 0);
|
|
||||||
|
|
||||||
set_arrow (arrows, arrows_nb, 1, 0, 1, 0, 0);
|
|
||||||
/* set_arrow (arrows, arrows_nb, 1, 1, 1, 0, 0); */
|
|
||||||
/* set_arrow (arrows, arrows_nb, 1, 0, 0, 0, 0); */
|
|
||||||
|
|
||||||
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\t\t(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)",\
|
||||||
|
|
Loading…
Reference in New Issue