WIP: Des chercheurs qui cherchent, on en trouve; mais des chercheurs qui trouvent,...
This commit is contained in:
parent
89f6ffb83a
commit
111f6b57af
|
@ -39,7 +39,7 @@ typedef struct arrow_t {
|
|||
};
|
||||
|
||||
int write_one_arrow_vertex (int space_X, int space_Y, int space_Z,
|
||||
int weight, int site, int x, int y, int z);
|
||||
int weight, int site, int x, int y, int z, int print);
|
||||
|
||||
int write_one_arrow_line(int offset_vertex);
|
||||
int write_one_arrow_line(int offset_vertex, int print);
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
*/
|
||||
|
||||
int write_one_arrow_vertex (int space_X_int, int space_Y_int, int space_Z_int,
|
||||
int weight, int site, int arrow_x, int arrow_y, int arrow_z)
|
||||
int weight, int site, int arrow_x, int arrow_y, int arrow_z, int print)
|
||||
{
|
||||
|
||||
float max = fmax(space_X_int, space_Y_int);
|
||||
|
@ -46,8 +46,6 @@ int write_one_arrow_vertex (int space_X_int, int space_Y_int, int space_Z_int,
|
|||
vy = (2 * j / space_Y_int - 1) * space_Y_int / max + (1 / max),
|
||||
vz = (2 * k / space_Z_int - 1) * space_Z_int / max + (1 / max);
|
||||
|
||||
int print = 0;
|
||||
|
||||
graphics_write_vertex(vx, vy, vz, print);
|
||||
graphics_write_color(0.3f, 0.3f, 0.3f);
|
||||
|
||||
|
@ -87,9 +85,8 @@ int write_one_arrow_vertex (int space_X_int, int space_Y_int, int space_Z_int,
|
|||
}
|
||||
|
||||
|
||||
int write_one_arrow_line(int offset_vertex)
|
||||
int write_one_arrow_line(int offset_vertex, int print)
|
||||
{
|
||||
int print = 0;
|
||||
graphics_write_line (offset_vertex + 0, offset_vertex + 1, print);
|
||||
return 2;
|
||||
}
|
||||
|
|
|
@ -138,8 +138,8 @@ void graphics_write_vertex (GLfloat x, GLfloat y, GLfloat z, int print)
|
|||
buffer_vertex_origin[buffer_vertex_size + 1] = y;
|
||||
buffer_vertex_origin[buffer_vertex_size + 2] = z;
|
||||
|
||||
if (print) printf("In graphics_write_vertex() buffer_vertex_size => [%2d > %2d] (%6.3f,%6.3f,%6.3f)\n",\
|
||||
buffer_vertex_size + 0, buffer_vertex_size + 2, x, y, z);
|
||||
if (print) printf("In graphics_write_vertex() buffer_vertex_size => [%2d] [%2d > %2d] (%6.3f,%6.3f,%6.3f)\n",\
|
||||
buffer_vertex_size / 3, buffer_vertex_size + 0, buffer_vertex_size + 2, x, y, z);
|
||||
|
||||
buffer_vertex_size += 3;
|
||||
}
|
||||
|
@ -182,8 +182,8 @@ void graphics_write_line (GLuint a, GLuint b, int print)
|
|||
buffer_lines_origin[buffer_lines_size + 0] = a;
|
||||
buffer_lines_origin[buffer_lines_size + 1] = b;
|
||||
|
||||
if (print) printf("In graphics_write_line() buffer_lines_size => [%2d > %2d] (%2u > %2u)\n",\
|
||||
buffer_lines_size + 0, buffer_lines_size + 1, a, b);
|
||||
if (print) printf("In graphics_write_line() buffer_lines_size => [%2d] [%2d > %2d] (%3u > %3u ) (= buffer_vertex_size / 3 - 2 > -1)\n",\
|
||||
buffer_lines_size / 2, buffer_lines_size + 0, buffer_lines_size + 1, a, b);
|
||||
|
||||
buffer_lines_size += 2;
|
||||
}
|
||||
|
@ -588,18 +588,16 @@ static inline int create_arrow (int arrows_nb,
|
|||
arrows_ptr[arrows_nb].y = y;
|
||||
arrows_ptr[arrows_nb].z = z;
|
||||
|
||||
if (0) printf("In create_arrow() buffer_vertex_size => [%2d > %2d]\n",\
|
||||
buffer_vertex_size + 0, buffer_vertex_size + 2);
|
||||
|
||||
int print = 1;
|
||||
write_one_arrow_vertex(space_X, space_Y, space_Z,
|
||||
load, site, x, y, z);
|
||||
load, site, x, y, z, print);
|
||||
buffer_colors_size = buffer_vertex_size;
|
||||
|
||||
write_one_arrow_line (buffer_vertex_size / 3 - 2);
|
||||
write_one_arrow_line (buffer_vertex_size / 3 - 2, print);
|
||||
|
||||
arrows_nb ++;
|
||||
|
||||
if (0) print_arrows_array (arrows_ptr, arrows_nb, 1);
|
||||
if (1) print_arrows_array (arrows_ptr, arrows_nb, 1);
|
||||
|
||||
return arrows_nb;
|
||||
}
|
||||
|
@ -625,6 +623,8 @@ static inline int erase_arrow (int arrows_nb, int address, int site, int x, int
|
|||
|
||||
if (arrows_nb > 0) {
|
||||
|
||||
int some_nb = 12; if (arrows_nb == 1) some_nb = 9;
|
||||
|
||||
void *new_arrows_list_ptr = g_realloc(arrows_ptr, arrows_nb * sizeof(struct arrow_t));
|
||||
if (new_arrows_list_ptr) arrows_ptr = new_arrows_list_ptr;
|
||||
else perror("In erase arrow, can't re_allocate for arrow list.\n");
|
||||
|
@ -635,16 +635,17 @@ static inline int erase_arrow (int arrows_nb, int address, int site, int x, int
|
|||
/* for (int i = 24; i < 36; i ++) printf(" %5.2f", buffer_vertex_origin[i]); printf("\n"); */
|
||||
|
||||
if (0) printf("buffer_vertex_0_arrow = %d arrows_nb * 3 = %d <<<<\n", buffer_vertex_0_arrow, arrows_nb * 3);
|
||||
void *new_arrows_vertex_ptr = g_realloc(buffer_vertex_origin, buffer_vertex_0_arrow + 9 * 3 * sizeof(GLfloat));
|
||||
void *new_arrows_vertex_ptr = g_realloc(buffer_vertex_origin, buffer_vertex_0_arrow + some_nb * 3 * sizeof(GLfloat));
|
||||
if (new_arrows_vertex_ptr) buffer_vertex_origin = new_arrows_vertex_ptr;
|
||||
else perror("In erase arrow, can't re_allocate for arrow vertex buffer.\n");
|
||||
|
||||
if (0) printf("buffer_lines_0_arrow = %d arrows_nb * 2 = %d <<<<\n", buffer_lines_0_arrow, arrows_nb * 2);
|
||||
void *new_arrows_lines_ptr = g_realloc(buffer_lines_origin, buffer_lines_0_arrow + 9 * 2 * sizeof(GLfloat));
|
||||
void *new_arrows_lines_ptr = g_realloc(buffer_lines_origin, buffer_lines_0_arrow + some_nb * 2 * sizeof(GLfloat));
|
||||
if (new_arrows_lines_ptr) buffer_lines_origin = new_arrows_lines_ptr;
|
||||
else perror("In erase arrow, can't re_allocate for arrow lines buffer.\n");
|
||||
}
|
||||
|
||||
printf(" >> bf_vrtx = %d bf_ln = %d\n", (buffer_vertex_size - 6) / 3, (buffer_lines_size - 4) / 2);
|
||||
print_arrows_array (arrows_ptr, arrows_nb,0);
|
||||
|
||||
return arrows_nb;
|
||||
|
@ -682,11 +683,10 @@ static inline int set_arrow (struct arrow_t *arrows_ptr, int arrows_nb,
|
|||
}
|
||||
}
|
||||
}
|
||||
printf("in set_arrow(), arrows_nb = %d address = %d\n", arrows_nb, address);
|
||||
// print_vertex_and_lines_buffers (arrows_ptr, arrows_nb, address, requested_weight, current_weight, site, x, y, z);
|
||||
|
||||
print_vertex_and_lines_buffers (arrows_ptr, arrows_nb, address, requested_weight, current_weight, site, x, y, z);
|
||||
|
||||
if (requested_weight == 0) printf(" - set_arrow() invoked with requested weight = %2d\n", requested_weight);
|
||||
if (requested_weight == 0) printf(" - set_arrow() invoked with requested weight = %2d bf_vrtx = %d bf_ln = %d add: %d",\
|
||||
requested_weight, buffer_vertex_size / 3, buffer_lines_size / 2, address);
|
||||
|
||||
if (TEST) show_user_action(arrows_ptr, arrows_nb, address, requested_weight, current_weight, site, x, y, z);
|
||||
|
||||
|
@ -707,7 +707,7 @@ static inline int set_arrow (struct arrow_t *arrows_ptr, int arrows_nb,
|
|||
}
|
||||
|
||||
static inline void print_buffers_array_head () {printf(" [rank] load | site x y z [address] buffer-vertex-1 buffer-vertex-2 buffer-lines\n");}
|
||||
static inline void print_empty_buffers_array () {printf(" [NULL] ---- | ---- --- --- --- -1 --- --- ---\n");}
|
||||
static inline void print_empty_buffers_array () {printf(" [NULL] ---- | ---- --- --- --- -1 --- --- ---\n");}
|
||||
|
||||
static void print_one_arrow_in_buffers (struct arrow_t *arrows, int i, int arrows_nb, int address) {
|
||||
printf(" [%4d] = %2d | %2d, %2d, %2d, %2d, (%2d) %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f\n",\
|
||||
|
@ -887,21 +887,28 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
|
|||
|
||||
/* if (1) print_user_choices(arrows_ptr, arrows_nb, space_X, space_Y, space_Z, print_arrows_data, 0); */
|
||||
|
||||
/* arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z, */
|
||||
/* 0,//rand() % arbitrary + 1, // load / weight */
|
||||
/* 0,//rand() % 6, // site, */
|
||||
/* 0,//rand() % space_X, // x */
|
||||
/* 0,//rand() % space_Y, // y */
|
||||
/* 0);//rand() % space_Z); // z */
|
||||
arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z,
|
||||
0,//rand() % arbitrary + 1, // load / weight
|
||||
0,//rand() % 6, // site,
|
||||
0,//rand() % space_X, // x
|
||||
0,//rand() % space_Y, // y
|
||||
0);//rand() % space_Z); // z
|
||||
|
||||
/* print_user_choices(arrows_ptr, arrows_nb, space_X, space_Y, space_Z, print_arrows_data, 0); */
|
||||
|
||||
/* arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z, */
|
||||
/* 0,//rand() % arbitrary + 1, // load / weight */
|
||||
/* 1,//rand() % 6, // site, */
|
||||
/* 0,//rand() % space_X, // x */
|
||||
/* 0,//rand() % space_Y, // y */
|
||||
/* 0);//rand() % space_Z); // z */
|
||||
arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z,
|
||||
rand() % arbitrary + 1, // load / weight
|
||||
2,//rand() % 6, // site,
|
||||
0,//rand() % space_X, // x
|
||||
0,//rand() % space_Y, // y
|
||||
0);//rand() % space_Z); // z
|
||||
|
||||
arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z,
|
||||
0,//rand() % arbitrary + 1, // load / weight
|
||||
1,//rand() % 6, // site,
|
||||
0,//rand() % space_X, // x
|
||||
0,//rand() % space_Y, // y
|
||||
0);//rand() % space_Z); // z
|
||||
|
||||
/* print_user_choices(arrows_ptr, arrows_nb, space_X, space_Y, space_Z, print_arrows_data, 0); */
|
||||
|
||||
|
|
Loading…
Reference in New Issue