WIP: nettoyage Il y a une erreur dans set_arrow() ou dans son affichage
This commit is contained in:
parent
e58d86a58f
commit
6bbc3a3aa8
|
@ -42,7 +42,5 @@ int write_one_arrow_vertex (int offset_vertex,
|
||||||
int space_X, int space_Y, int space_Z,
|
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 write_one_arrow_lines (int offset_vertex,
|
int write_one_arrow_line(int offset_vertex);
|
||||||
int space_X, int space_Y, int space_Z,
|
|
||||||
int weight, int site, int x, int y, int z);
|
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,8 @@
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
int write_space_ridges_vertex (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z);
|
int write_space_ridges_vertex (long offset_vertex, long x, long y, long z);
|
||||||
int write_space_ridges_lines (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z);
|
int write_space_ridges_lines ();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Writes grid lines on space faces
|
* Writes grid lines on space faces
|
||||||
|
@ -44,6 +44,6 @@ int write_space_ridges_lines (long offset_vertex, long offset_colors, long offse
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
long write_grids_on_space_faces_vertex (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z, int style);
|
long write_grids_on_space_faces_vertex (long x, long y, long z);
|
||||||
long write_grids_on_space_faces_lines (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z, int style);
|
long write_grids_on_space_faces_lines (long offset_vertex, long x, long y, long z);
|
||||||
|
|
||||||
|
|
|
@ -33,83 +33,6 @@
|
||||||
* Z - Z = NORTH - SOUTH = bleu - jaune
|
* Z - Z = NORTH - SOUTH = bleu - jaune
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
|
||||||
* Writes basis and tip for all arrows into vertex and color buffers
|
|
||||||
*
|
|
||||||
* @param dimensions (x,y,z)
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Writes lines for arrow oriented towards east or west into lines buffer
|
|
||||||
*
|
|
||||||
* @param offset,
|
|
||||||
* weight,
|
|
||||||
* site
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
static void write_arrow_lines_east_west (long offset, int weight, int site)
|
|
||||||
{
|
|
||||||
graphics_write_line (offset + 2, offset + 6 + site % 2);
|
|
||||||
graphics_write_line (offset + 3, offset + 6 + site % 2);
|
|
||||||
graphics_write_line (offset + 4, offset + 6 + site % 2);
|
|
||||||
graphics_write_line (offset + 5, offset + 6 + site % 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Writes lines for arrow oriented towards zenith or nadir into lines buffer
|
|
||||||
*
|
|
||||||
* @param offset,
|
|
||||||
* weight,
|
|
||||||
* site
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
static void write_arrow_lines_zenith_nadir (long offset, int weight, int site)
|
|
||||||
{
|
|
||||||
graphics_write_line (offset + 0, offset + 8 + site % 2);
|
|
||||||
graphics_write_line (offset + 1, offset + 8 + site % 2);
|
|
||||||
graphics_write_line (offset + 4, offset + 8 + site % 2);
|
|
||||||
graphics_write_line (offset + 5, offset + 8 + site % 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Writes lines for arrow oriented towards south or north into lines buffer
|
|
||||||
*
|
|
||||||
* @param offset,
|
|
||||||
* weight,
|
|
||||||
* site
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
static void write_arrow_lines_south_north (long offset, int weight, int site)
|
|
||||||
{
|
|
||||||
graphics_write_line (offset + 0, offset + 10 + site % 2);
|
|
||||||
graphics_write_line (offset + 1, offset + 10 + site % 2);
|
|
||||||
graphics_write_line (offset + 2, offset + 10 + site % 2);
|
|
||||||
graphics_write_line (offset + 3, offset + 10 + site % 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Writes lines for arrow basis into lines buffer
|
|
||||||
*
|
|
||||||
* @param offset
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
static void arrows_write_basis(long offset)
|
|
||||||
{
|
|
||||||
graphics_write_line (offset + 0, offset + 1);
|
|
||||||
graphics_write_line (offset + 2, offset + 3);
|
|
||||||
graphics_write_line (offset + 4, offset + 5);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
int write_one_arrow_vertex (int offset_vertex,
|
int write_one_arrow_vertex (int offset_vertex,
|
||||||
int space_X_int, int space_Y_int, int space_Z_int,
|
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)
|
||||||
|
@ -166,17 +89,9 @@ int write_one_arrow_vertex (int offset_vertex,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int write_one_arrow_lines(int offset_vertex,
|
int write_one_arrow_line(int offset_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)
|
|
||||||
{
|
{
|
||||||
switch(site){
|
graphics_write_line (offset_vertex + 0, offset_vertex + 1);
|
||||||
case EAST: case WEST: graphics_write_line (offset_vertex + 0, offset_vertex + 1); break;
|
|
||||||
case ZENITH: case NADIR: graphics_write_line (offset_vertex + 0, offset_vertex + 1); break;
|
|
||||||
case SOUTH: case NORTH: graphics_write_line (offset_vertex + 0, offset_vertex + 1); break;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
#define VERTEX_SHADER_FILE "src/shaders/shader.vert"
|
#define VERTEX_SHADER_FILE "src/shaders/shader.vert"
|
||||||
#define FRAG_SHADER_FILE "src/shaders/shader.frag"
|
#define FRAG_SHADER_FILE "src/shaders/shader.frag"
|
||||||
|
|
||||||
static struct arrow_t *arrows;
|
static struct arrow_t *sworra;
|
||||||
static GLfloat *buffer_vertex_origin = NULL;
|
static GLfloat *buffer_vertex_origin = NULL;
|
||||||
static GLfloat *buffer_colors_origin = NULL;
|
static GLfloat *buffer_colors_origin = NULL;
|
||||||
static GLuint *buffer_lines_origin = NULL;
|
static GLuint *buffer_lines_origin = NULL;
|
||||||
|
@ -549,10 +549,10 @@ bool graphics_shutdown(const void *gl_area)
|
||||||
*/
|
*/
|
||||||
static int rewrite_arrow (int arrows_nb, int address, int load, int site, int x, int y, int z)
|
static int rewrite_arrow (int arrows_nb, int address, int load, int site, int x, int y, int z)
|
||||||
{
|
{
|
||||||
arrows[address].load = load;
|
sworra[address].load = load;
|
||||||
|
|
||||||
// if (! TEST)
|
// if (! TEST)
|
||||||
// print_arrows_array (arrows, arrows_nb);
|
// print_arrows_array (sworra, arrows_nb);
|
||||||
|
|
||||||
return arrows_nb;
|
return arrows_nb;
|
||||||
}
|
}
|
||||||
|
@ -563,23 +563,23 @@ static int rewrite_arrow (int arrows_nb, int address, int load, int site, int x,
|
||||||
*/
|
*/
|
||||||
static inline int create_arrow (int arrows_nb, int load, int site, int x, int y, int z)
|
static inline int create_arrow (int arrows_nb, int load, int site, int x, int y, int z)
|
||||||
{
|
{
|
||||||
void *newptr = g_realloc(arrows, (arrows_nb + 1) * sizeof(struct arrow_t));
|
void *newptr = g_realloc(sworra, (arrows_nb + 1) * sizeof(struct arrow_t));
|
||||||
|
|
||||||
if (newptr)
|
if (newptr)
|
||||||
arrows = newptr;
|
sworra = newptr;
|
||||||
else
|
else
|
||||||
perror("Can't allocate new arrow buffer!\n");
|
perror("Can't allocate new arrow buffer!\n");
|
||||||
|
|
||||||
arrows[arrows_nb].load = load;
|
sworra[arrows_nb].load = load;
|
||||||
arrows[arrows_nb].site = site;
|
sworra[arrows_nb].site = site;
|
||||||
arrows[arrows_nb].x = x;
|
sworra[arrows_nb].x = x;
|
||||||
arrows[arrows_nb].y = y;
|
sworra[arrows_nb].y = y;
|
||||||
arrows[arrows_nb].z = z;
|
sworra[arrows_nb].z = z;
|
||||||
|
|
||||||
arrows_nb ++;
|
arrows_nb ++;
|
||||||
|
|
||||||
// if (! TEST)
|
// if (! TEST)
|
||||||
// print_arrows_array (arrows, arrows_nb);
|
// print_arrows_array (sworra, arrows_nb);
|
||||||
|
|
||||||
return arrows_nb;
|
return arrows_nb;
|
||||||
}
|
}
|
||||||
|
@ -593,27 +593,27 @@ static inline int erase_arrow (int arrows_nb, int address, int site, int x, int
|
||||||
|
|
||||||
if (arrows_nb > 0)
|
if (arrows_nb > 0)
|
||||||
{
|
{
|
||||||
arrows[address].load = arrows[arrows_nb].load;
|
sworra[address].load = sworra[arrows_nb].load;
|
||||||
arrows[address].site = arrows[arrows_nb].site;
|
sworra[address].site = sworra[arrows_nb].site;
|
||||||
arrows[address].x = arrows[arrows_nb].x;
|
sworra[address].x = sworra[arrows_nb].x;
|
||||||
arrows[address].y = arrows[arrows_nb].y;
|
sworra[address].y = sworra[arrows_nb].y;
|
||||||
arrows[address].z = arrows[arrows_nb].z;
|
sworra[address].z = sworra[arrows_nb].z;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *newptr = g_realloc(arrows, arrows_nb * sizeof(struct arrow_t));
|
void *newptr = g_realloc(sworra, arrows_nb * sizeof(struct arrow_t));
|
||||||
|
|
||||||
if (newptr)
|
if (newptr)
|
||||||
arrows = newptr;
|
sworra = newptr;
|
||||||
else
|
else
|
||||||
perror("Can't allocate new arrow buffer!\n");
|
perror("Can't allocate new arrow buffer!\n");
|
||||||
|
|
||||||
// if (! TEST)
|
// if (! TEST)
|
||||||
// print_arrows_array (arrows, arrows_nb);
|
// print_arrows_array (sworra, arrows_nb);
|
||||||
|
|
||||||
return arrows_nb;
|
return arrows_nb;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void show_user_action(struct arrow_t *arrows, int arrows_nb, int address, int requested_weight,
|
static inline void show_user_action(struct arrow_t *sworra, int arrows_nb, int address, int requested_weight,
|
||||||
int current_weight, int site, int x, int y, int z);
|
int current_weight, int site, int x, int y, int z);
|
||||||
/*
|
/*
|
||||||
* Calls one of the functions create_arrow(), erase_arrow() or rewrite_arrow()
|
* Calls one of the functions create_arrow(), erase_arrow() or rewrite_arrow()
|
||||||
|
@ -623,27 +623,27 @@ static inline void show_user_action(struct arrow_t *arrows, int arrows_nb, int a
|
||||||
* - Current_weight of an arrow located at the requested address == requested_weight
|
* - Current_weight of an arrow located at the requested address == requested_weight
|
||||||
* - No arrow was found at the requested addres AND current_weight == requested_weight
|
* - No arrow was found at the requested addres AND current_weight == requested_weight
|
||||||
*/
|
*/
|
||||||
static inline int set_arrow (struct arrow_t *arrows, int arrows_nb, int requested_weight, int site, int x, int y, int z)
|
static inline int set_arrow (struct arrow_t *sworra, int arrows_nb, int requested_weight, int site, int x, int y, int z)
|
||||||
{
|
{
|
||||||
int address = -1, current_weight = -1;
|
int address = -1, current_weight = -1;
|
||||||
|
|
||||||
#pragma omp parallel schedule(static, 12)
|
#pragma omp parallel schedule(static, 12)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < arrows_nb; i++) {
|
for (int i = 0; i < arrows_nb; i++) {
|
||||||
if ((site == arrows[i].site)
|
if ((site == sworra[i].site)
|
||||||
&& (x == arrows[i].x)
|
&& (x == sworra[i].x)
|
||||||
&& (y == arrows[i].y)
|
&& (y == sworra[i].y)
|
||||||
&& (z == arrows[i].z))
|
&& (z == sworra[i].z))
|
||||||
{
|
{
|
||||||
address = i * 5;
|
address = i * 5;
|
||||||
current_weight = arrows[i].load;
|
current_weight = sworra[i].load;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//printf("\n[%d]set_arrow() invoked with requested weight = %2d + ", arrows_nb, requested_weight);
|
//printf("\n[%d]set_arrow() invoked with requested weight = %2d + ", arrows_nb, requested_weight);
|
||||||
|
|
||||||
if (TEST) show_user_action(arrows, arrows_nb, address, requested_weight, current_weight, site, x, y, z);
|
if (TEST) show_user_action(sworra, arrows_nb, address, requested_weight, current_weight, site, x, y, z);
|
||||||
|
|
||||||
if (address == -1 && requested_weight > 0)
|
if (address == -1 && requested_weight > 0)
|
||||||
return create_arrow (arrows_nb, requested_weight, site, x, y, z);
|
return create_arrow (arrows_nb, requested_weight, site, x, y, z);
|
||||||
|
@ -654,9 +654,9 @@ static inline int set_arrow (struct arrow_t *arrows, int arrows_nb, int requeste
|
||||||
if (address >= 0 && current_weight != requested_weight)
|
if (address >= 0 && current_weight != requested_weight)
|
||||||
return rewrite_arrow (arrows_nb, address/5, requested_weight, site, x, y, z);
|
return rewrite_arrow (arrows_nb, address/5, requested_weight, site, x, y, z);
|
||||||
|
|
||||||
// if (! TEST && address >= 0 && current_weight == requested_weight) print_arrows_array(arrows, arrows_nb, x, y, z);
|
// if (! TEST && address >= 0 && current_weight == requested_weight) print_arrows_array(sworra, arrows_nb, x, y, z);
|
||||||
|
|
||||||
// if (! TEST && address == -1 && requested_weight == 0) print_arrows_array(arrows, arrows_nb, x, y, z);
|
// if (! TEST && address == -1 && requested_weight == 0) print_arrows_array(sworra, arrows_nb, x, y, z);
|
||||||
|
|
||||||
return arrows_nb;
|
return arrows_nb;
|
||||||
}
|
}
|
||||||
|
@ -680,14 +680,14 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
|
||||||
int rand(void);
|
int rand(void);
|
||||||
void srand(unsigned int seed); // printf ("Valeur max : %d\n", RAND_MAX); min + rand() % (max+1 - min);
|
void srand(unsigned int seed); // printf ("Valeur max : %d\n", RAND_MAX); min + rand() % (max+1 - min);
|
||||||
|
|
||||||
int arbitrary = 200;
|
int arbitrary = 5;
|
||||||
int space_X = 1 + rand() % arbitrary,
|
int space_X = 1 + rand() % arbitrary,
|
||||||
space_Y = 1 + rand() % arbitrary,
|
space_Y = 1 + rand() % arbitrary,
|
||||||
space_Z = 1 + rand() % arbitrary;
|
space_Z = 1 + rand() % arbitrary;
|
||||||
int density_max = space_X * space_Y * space_Z;
|
int density_max = space_X * space_Y * space_Z;
|
||||||
int max = fmax(space_X, space_Y); max = fmax(max, space_Z);
|
int max = fmax(space_X, space_Y); max = fmax(max, space_Z);
|
||||||
|
|
||||||
int show_space_design = 1, print_arrows_data = 0;
|
int print_arrows_data = 1;
|
||||||
|
|
||||||
int load = 0, site = 0, x = 0, y = 0, z = 0;
|
int load = 0, site = 0, x = 0, y = 0, z = 0;
|
||||||
int specif_arrows_nb = rand() % density_max;
|
int specif_arrows_nb = rand() % density_max;
|
||||||
|
@ -698,7 +698,7 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
|
||||||
#pragma omp parallel
|
#pragma omp parallel
|
||||||
{
|
{
|
||||||
while (arrows_nb < specif_arrows_nb){
|
while (arrows_nb < specif_arrows_nb){
|
||||||
arrows_nb = set_arrow (arrows, arrows_nb,
|
arrows_nb = set_arrow (sworra, arrows_nb,
|
||||||
rand() % arbitrary + 1, // load / weight
|
rand() % arbitrary + 1, // load / weight
|
||||||
rand() % 6, // site,
|
rand() % 6, // site,
|
||||||
rand() % space_X, // x
|
rand() % space_X, // x
|
||||||
|
@ -719,13 +719,13 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
|
||||||
/* arbitrary = 26; */
|
/* arbitrary = 26; */
|
||||||
/* space_X = arbitrary; space_Y = arbitrary; space_Z = arbitrary; */
|
/* space_X = arbitrary; space_Y = arbitrary; space_Z = arbitrary; */
|
||||||
/* density_max = space_X * space_Y * space_Z;
|
/* density_max = space_X * space_Y * space_Z;
|
||||||
* C E T T E T R I P L E B O U C L E
|
* C E T T E Q U A D R U P L E B O U C L E
|
||||||
* S A T U R E L ' E S P A C E S Y S T É M A T I Q U E M E N T */
|
* S A T U R E L ' E S P A C E S Y S T É M A T I Q U E M E N T */
|
||||||
/* for (int i =0; i < space_X; i++) */
|
/* for (int i =0; i < space_X; i++) */
|
||||||
/* for (int j =0; j < space_Y; j++) */
|
/* for (int j =0; j < space_Y; j++) */
|
||||||
/* for (int k =0; k < space_Z; k++) */
|
/* for (int k =0; k < space_Z; k++) */
|
||||||
/* for (int u =0; u < 6; u++) */
|
/* for (int u =0; u < 6; u++) */
|
||||||
/* arrows_nb = set_arrow (arrows, arrows_nb, */
|
/* arrows_nb = set_arrow (sworra, arrows_nb, */
|
||||||
/* 1, // load / weight */
|
/* 1, // load / weight */
|
||||||
/* u,//i % 6, // site, */
|
/* u,//i % 6, // site, */
|
||||||
/* i,//i % space_X, // x */
|
/* i,//i % space_X, // x */
|
||||||
|
@ -734,7 +734,7 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
|
||||||
/* ); */
|
/* ); */
|
||||||
// end = clock(); printf("Elapsed time %ld\n", end - start);
|
// end = clock(); printf("Elapsed time %ld\n", end - start);
|
||||||
|
|
||||||
print_user_choices(arrows, arrows_nb, space_X, space_Y, space_Z, print_arrows_data, show_space_design);
|
print_user_choices(sworra, arrows_nb, space_X, space_Y, space_Z, print_arrows_data);
|
||||||
|
|
||||||
/* D A T A A R E N O W A L L S P E C I F I E D */
|
/* D A T A A R E N O W A L L S P E C I F I E D */
|
||||||
|
|
||||||
|
@ -748,12 +748,13 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
|
||||||
|
|
||||||
/* S P A C E */
|
/* S P A C E */
|
||||||
|
|
||||||
offset_vertex += write_space_ridges_vertex (offset_vertex, offset_colors, offset_lines, space_X, space_Y, space_Z);
|
// float max = fmax(x, y); max = fmax(max, z);
|
||||||
|
offset_vertex += write_space_ridges_vertex (offset_vertex, space_X, space_Y, space_Z);
|
||||||
offset_colors = offset_vertex;
|
offset_colors = offset_vertex;
|
||||||
|
|
||||||
if (0) printf("offset_vertex after writing_space_ridges_vertex : %d (x 3 = %d)\n\n", offset_vertex, offset_vertex * 3);
|
if (0) printf("offset_vertex after writing_space_ridges_vertex : %d (x 3 = %d)\n\n", offset_vertex, offset_vertex * 3);
|
||||||
|
|
||||||
offset_vertex += write_grids_on_space_faces_vertex (offset_vertex, offset_colors, offset_lines, space_X, space_Y, space_Z, show_space_design);
|
offset_vertex += write_grids_on_space_faces_vertex (space_X, space_Y, space_Z);
|
||||||
offset_colors = offset_vertex;
|
offset_colors = offset_vertex;
|
||||||
|
|
||||||
if (0) printf("offset_vertex after writing_space_faces_vertex = %4d - 8 = %3d (x 3 = %4d)\n", offset_vertex, offset_vertex - 8, (offset_vertex - 8) * 3);
|
if (0) printf("offset_vertex after writing_space_faces_vertex = %4d - 8 = %3d (x 3 = %4d)\n", offset_vertex, offset_vertex - 8, (offset_vertex - 8) * 3);
|
||||||
|
@ -764,11 +765,11 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
|
||||||
/* A R R O W S */
|
/* A R R O W S */
|
||||||
|
|
||||||
for (int i = 0; i < arrows_nb; i++) {
|
for (int i = 0; i < arrows_nb; i++) {
|
||||||
load = arrows[i].load;
|
load = sworra[i].load;
|
||||||
site = arrows[i].site;
|
site = sworra[i].site;
|
||||||
x = arrows[i].x;
|
x = sworra[i].x;
|
||||||
y = arrows[i].y;
|
y = sworra[i].y;
|
||||||
z = arrows[i].z;
|
z = sworra[i].z;
|
||||||
|
|
||||||
offset_vertex += write_one_arrow_vertex(offset_vertex,
|
offset_vertex += write_one_arrow_vertex(offset_vertex,
|
||||||
space_X, space_Y, space_Z,
|
space_X, space_Y, space_Z,
|
||||||
|
@ -787,46 +788,72 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
|
||||||
|
|
||||||
/* S P A C E */
|
/* S P A C E */
|
||||||
|
|
||||||
offset_vertex += write_space_ridges_lines (offset_vertex, offset_colors, offset_lines, space_X, space_Y, space_Z);
|
offset_vertex += write_space_ridges_lines ();
|
||||||
|
|
||||||
offset_vertex += write_grids_on_space_faces_lines (offset_vertex, offset_colors, offset_lines, space_X, space_Y, space_Z, show_space_design);
|
offset_vertex += write_grids_on_space_faces_lines (offset_vertex, space_X, space_Y, space_Z);
|
||||||
|
|
||||||
/* A R R O W S */
|
/* A R R O W S */
|
||||||
|
|
||||||
for (int i = 0; i < arrows_nb; i++) {
|
for (int i = 0; i < arrows_nb; i++) {
|
||||||
load = arrows[i].load;
|
load = sworra[i].load;
|
||||||
site = arrows[i].site;
|
site = sworra[i].site;
|
||||||
x = arrows[i].x;
|
x = sworra[i].x;
|
||||||
y = arrows[i].y;
|
y = sworra[i].y;
|
||||||
z = arrows[i].z;
|
z = sworra[i].z;
|
||||||
|
|
||||||
offset_vertex += write_one_arrow_lines (offset_vertex, space_X, space_Y, space_Z,
|
offset_vertex += write_one_arrow_line (offset_vertex);
|
||||||
load, site, x, y, z);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assert : arrows_nb > arbitrary;
|
/* assert : arrows_nb > arbitrary; */
|
||||||
int random_choice, modified = 0, deleted = 0;
|
/* int random_choice, modified = 0, deleted = 0; */
|
||||||
|
|
||||||
#pragma omp parallel
|
/* #pragma omp parallel */
|
||||||
{
|
/* { */
|
||||||
while (modified < arbitrary) {
|
/* while (modified < arbitrary) { */
|
||||||
|
|
||||||
random_choice = rand() % 6;
|
/* random_choice = rand() % 6; */
|
||||||
if (random_choice == 0) deleted++;
|
/* if (random_choice == 0) deleted++; */
|
||||||
|
|
||||||
modified = set_arrow (arrows, modified,
|
/* modified = set_arrow (sworra, arrows_nb + modified, */
|
||||||
random_choice, // load / weight
|
/* random_choice, // load / weight */
|
||||||
rand() % 6, // site,
|
/* rand() % 6, // site, */
|
||||||
rand() % space_X, // x
|
/* rand() % space_X, // x */
|
||||||
rand() % space_Y, // y
|
/* rand() % space_Y, // y */
|
||||||
rand() % space_Z); // z
|
/* rand() % space_Z); // z */
|
||||||
}
|
/* } */
|
||||||
}
|
/* } */
|
||||||
print_evolution (arrows, arrows_nb, arbitrary, deleted, print_arrows_data);
|
|
||||||
|
/* #pragma omp parallel */
|
||||||
|
/* { */
|
||||||
|
/* for (int i = 0; i < arrows_nb + modified; i++) { */
|
||||||
|
/* load = sworra[i].load; */
|
||||||
|
/* site = sworra[i].site; */
|
||||||
|
/* x = sworra[i].x; */
|
||||||
|
/* y = sworra[i].y; */
|
||||||
|
/* z = sworra[i].z; */
|
||||||
|
|
||||||
|
/* offset_vertex += write_one_arrow_vertex(offset_vertex, */
|
||||||
|
/* space_X, space_Y, space_Z, */
|
||||||
|
/* load, site, x, y, z); */
|
||||||
|
/* offset_colors = offset_vertex; */
|
||||||
|
/* } */
|
||||||
|
|
||||||
|
/* for (int i = 0; i < arrows_nb + modified; i++) { */
|
||||||
|
/* load = sworra[i].load; */
|
||||||
|
/* site = sworra[i].site; */
|
||||||
|
/* x = sworra[i].x; */
|
||||||
|
/* y = sworra[i].y; */
|
||||||
|
/* z = sworra[i].z; */
|
||||||
|
|
||||||
|
/* offset_vertex += write_one_arrow_line (offset_vertex); */
|
||||||
|
/* } */
|
||||||
|
/* } */
|
||||||
|
|
||||||
|
/* print_evolution (sworra, arrows_nb, arbitrary, deleted, print_arrows_data); */
|
||||||
|
|
||||||
|
|
||||||
// ? free (space) TODO
|
// ? free (space) TODO
|
||||||
free(arrows);
|
free(sworra);
|
||||||
arrows = NULL;
|
sworra = NULL;
|
||||||
arrows_nb = 0;
|
arrows_nb = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,9 +25,10 @@
|
||||||
#include "../../include/base.h"
|
#include "../../include/base.h"
|
||||||
#include "../../include/graphics.h"
|
#include "../../include/graphics.h"
|
||||||
|
|
||||||
int write_space_ridges_vertex (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z)
|
int write_space_ridges_vertex (long offset_vertex, long x, long y, long z)
|
||||||
{
|
{
|
||||||
float max = fmax(x, y); max = fmax(max, z);
|
float max = fmax(x, y); max = fmax(max, z);
|
||||||
|
|
||||||
graphics_write_vertex (offset_vertex - x / max, offset_vertex - y / max, - z / max);
|
graphics_write_vertex (offset_vertex - x / max, offset_vertex - y / max, - z / max);
|
||||||
|
|
||||||
graphics_write_vertex (offset_vertex + x / max, offset_vertex - y / max, - z / max);
|
graphics_write_vertex (offset_vertex + x / max, offset_vertex - y / max, - z / max);
|
||||||
|
@ -52,7 +53,7 @@ int write_space_ridges_vertex (long offset_vertex, long offset_colors, long offs
|
||||||
return 8;
|
return 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
int write_space_ridges_lines (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z)
|
int write_space_ridges_lines ()
|
||||||
{
|
{
|
||||||
graphics_write_line ( 0, 1); graphics_write_line ( 7, 4);
|
graphics_write_line ( 0, 1); graphics_write_line ( 7, 4);
|
||||||
graphics_write_line ( 0, 2); graphics_write_line ( 7, 5);
|
graphics_write_line ( 0, 2); graphics_write_line ( 7, 5);
|
||||||
|
@ -65,7 +66,7 @@ int write_space_ridges_lines (long offset_vertex, long offset_colors, long offse
|
||||||
return 12;
|
return 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
long write_grids_on_space_faces_vertex (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z, int design)
|
long write_grids_on_space_faces_vertex (long x, long y, long z)
|
||||||
{
|
{
|
||||||
float i, max = fmax(x, y); max = fmax(max, z);
|
float i, max = fmax(x, y); max = fmax(max, z);
|
||||||
|
|
||||||
|
@ -82,8 +83,7 @@ long write_grids_on_space_faces_vertex (long offset_vertex, long offset_colors,
|
||||||
graphics_write_color (0.5f, 0.5f, 0.5f);
|
graphics_write_color (0.5f, 0.5f, 0.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
offset_vertex += (x - 1) * 4;
|
/* offset_vertex += (x - 1) * 4; */ /* offset_colors += (x - 1) * 4; */
|
||||||
offset_colors += (x - 1) * 4;
|
|
||||||
|
|
||||||
for (i = 1; i < y; i++) {
|
for (i = 1; i < y; i++) {
|
||||||
|
|
||||||
|
@ -98,8 +98,7 @@ long write_grids_on_space_faces_vertex (long offset_vertex, long offset_colors,
|
||||||
graphics_write_color (0.5f, 0.5f, 0.5f);
|
graphics_write_color (0.5f, 0.5f, 0.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
offset_vertex += (y - 1) * 4;
|
/* offset_vertex += (y - 1) * 4; */ /* offset_colors += (y - 1) * 4; */
|
||||||
offset_colors += (y - 1) * 4;
|
|
||||||
|
|
||||||
for (i = 1; i < z; i++) {
|
for (i = 1; i < z; i++) {
|
||||||
|
|
||||||
|
@ -118,48 +117,36 @@ long write_grids_on_space_faces_vertex (long offset_vertex, long offset_colors,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
long write_grids_on_space_faces_lines (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z, int design)
|
long write_grids_on_space_faces_lines (long offset_vertex, long x, long y, long z)
|
||||||
{
|
{
|
||||||
float i, max = fmax(x, y); max = fmax(max, z);
|
for (int i = 0; i < x - 1; i ++) {
|
||||||
|
|
||||||
design = 0;
|
/* 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); */
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < x - 1; i ++) {
|
offset_vertex += (x - 1) * 4;
|
||||||
|
|
||||||
if (design)
|
for (int i = 0; i < y - 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);
|
/* graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1); */
|
||||||
graphics_write_line (offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3);
|
/* graphics_write_line (offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2); */
|
||||||
if (design)
|
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);
|
graphics_write_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (design) offset_vertex += (x - 1) * 2; else offset_vertex += (x - 1) * 4;
|
offset_vertex += (y - 1) * 4;
|
||||||
|
|
||||||
for (i = 0; i < y - 1; i ++) {
|
for (int i = 0; i < z - 1; i ++) {
|
||||||
|
|
||||||
if (design)
|
|
||||||
graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1);
|
graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1);
|
||||||
if (design)
|
/* graphics_write_line (offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2); */
|
||||||
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 + 2, offset_vertex + i * 4 + 3);
|
graphics_write_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0);
|
||||||
graphics_write_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (design) offset_vertex += (y - 1) * 2; else offset_vertex += (y - 1) * 4;
|
|
||||||
|
|
||||||
for (i = 0; i < z - 1; i ++) {
|
|
||||||
|
|
||||||
graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1);
|
|
||||||
if (design)
|
|
||||||
graphics_write_line (offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2);
|
|
||||||
if (design)
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (x + y + z - 3) * 4;
|
return (x + y + z - 3) * 4;
|
||||||
/* if (design) offset_lines += 2 * (space_X + space_Y + space_Z - 3); */
|
|
||||||
/* else offset_lines += 4 * (space_X + space_Y + space_Z - 3); */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue