WIP: optimisation: les vertex d'abord, les lignes ensuite. (1èr essai)
This commit is contained in:
parent
01fcc4f69e
commit
fc271cf2ef
|
@ -38,7 +38,11 @@ typedef struct arrow_t {
|
|||
GLuint z;
|
||||
};
|
||||
|
||||
int write_one_arrow(int offset_vertex,
|
||||
int write_one_arrow_vertex (int offset_vertex,
|
||||
int space_X, int space_Y, int space_Z,
|
||||
int weight, int site, int x, int y, int z);
|
||||
|
||||
int write_one_arrow_lines (int offset_vertex,
|
||||
int space_X, int space_Y, int space_Z,
|
||||
int weight, int site, int x, int y, int z);
|
||||
|
||||
|
|
|
@ -34,7 +34,8 @@
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
int write_space_ridges (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z);
|
||||
int write_space_ridges_vertex (long offset_vertex, long offset_colors, long offset_lines, 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);
|
||||
|
||||
/*
|
||||
* Writes grid lines on space faces
|
||||
|
@ -43,5 +44,6 @@ int write_space_ridges (long offset_vertex, long offset_colors, long offset_line
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
long write_grids_on_space_faces (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 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 offset_colors, long offset_lines, long x, long y, long z, int style);
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ static void arrows_write_basis(long offset)
|
|||
|
||||
/******************************************************************************/
|
||||
|
||||
int write_one_arrow(int offset_vertex,
|
||||
int write_one_arrow_vertex (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)
|
||||
{
|
||||
|
@ -149,11 +149,6 @@ int write_one_arrow(int offset_vertex,
|
|||
graphics_write_color(0.3f, 0.3f, 0.3f);
|
||||
graphics_write_color(0.3f, 0.3f, 0.3f);
|
||||
|
||||
/* graphics_write_line (offset_vertex + 0, offset_vertex + 1); */
|
||||
/* graphics_write_line (offset_vertex + 2, offset_vertex + 3); */
|
||||
/* graphics_write_line (offset_vertex + 4, offset_vertex + 5); */
|
||||
|
||||
|
||||
GLfloat nuance = 0.24f;
|
||||
|
||||
// X - X (EAST - WEST) axis - arrows tips (red - green)
|
||||
|
@ -174,6 +169,17 @@ int write_one_arrow(int offset_vertex,
|
|||
graphics_write_color(0.0f + nuance * 2, 0.0f + nuance * 2, 1.0f - nuance);
|
||||
graphics_write_color(1.0f - nuance / 3, 1.0f - nuance / 3, 0.0f + nuance);
|
||||
|
||||
return 12;
|
||||
}
|
||||
|
||||
|
||||
int write_one_arrow_lines(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)
|
||||
{
|
||||
/* graphics_write_line (offset_vertex + 0, offset_vertex + 1); */
|
||||
/* graphics_write_line (offset_vertex + 2, offset_vertex + 3); */
|
||||
/* graphics_write_line (offset_vertex + 4, offset_vertex + 5); */
|
||||
|
||||
switch(site){
|
||||
case EAST: case WEST: write_arrow_lines_east_west (offset_vertex, weight, site); break;
|
||||
|
|
|
@ -675,7 +675,7 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
|
|||
int rand(void);
|
||||
void srand(unsigned int seed); // printf ("Valeur max : %d\n", RAND_MAX); min + rand() % (max+1 - min);
|
||||
|
||||
int arbitrary = 10;
|
||||
int arbitrary = 1000;
|
||||
int space_X = 1 + rand() % arbitrary,
|
||||
space_Y = 1 + rand() % arbitrary,
|
||||
space_Z = 1 + rand() % arbitrary;
|
||||
|
@ -699,14 +699,22 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
|
|||
|
||||
print_user_choices(arrows, arrows_nb, space_X, space_Y, space_Z, print_arrows_data, show_space_design);
|
||||
|
||||
/* DATA ARE NOW ALL SPECIFIED - DRAWING CAN START */
|
||||
/* D A T A A R E N O W A L L S P E C I F I E D */
|
||||
|
||||
/* D R A W I N G C A N S T A R T */
|
||||
|
||||
/*---------------------------------------------------------------*/
|
||||
|
||||
/* V E R T E X F I R S T */
|
||||
|
||||
int offset_vertex = 0, offset_colors = 0, offset_lines = 0;
|
||||
|
||||
offset_vertex += write_space_ridges (offset_vertex, offset_colors, offset_lines, space_X, space_Y, space_Z);
|
||||
/* S P A C E */
|
||||
|
||||
offset_vertex += write_space_ridges_vertex (offset_vertex, offset_colors, offset_lines, space_X, space_Y, space_Z);
|
||||
offset_colors = offset_vertex;
|
||||
|
||||
offset_vertex += write_grids_on_space_faces (offset_vertex, offset_colors, offset_lines, space_X, space_Y, space_Z, show_space_design);
|
||||
offset_vertex += write_grids_on_space_faces_vertex (offset_vertex, offset_colors, offset_lines, space_X, space_Y, space_Z, show_space_design);
|
||||
offset_colors = offset_vertex;
|
||||
|
||||
/* A R R O W S */
|
||||
|
@ -718,12 +726,38 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
|
|||
y = arrows[i].y;
|
||||
z = arrows[i].z;
|
||||
|
||||
offset_vertex += write_one_arrow(offset_vertex,
|
||||
offset_vertex += write_one_arrow_vertex(offset_vertex,
|
||||
space_X, space_Y, space_Z,
|
||||
load, site, x, y, z);
|
||||
offset_colors = offset_vertex;
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------*/
|
||||
|
||||
/* L I N E S S E C O N D */
|
||||
|
||||
offset_vertex = 0; offset_colors = 0; offset_lines = 0;
|
||||
|
||||
/* 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_grids_on_space_faces_lines (offset_vertex, offset_colors, offset_lines, space_X, space_Y, space_Z, show_space_design);
|
||||
|
||||
/* A R R O W S */
|
||||
|
||||
for (int i = 0; i < arrows_nb; i++) {
|
||||
load = arrows[i].load;
|
||||
site = arrows[i].site;
|
||||
x = arrows[i].x;
|
||||
y = arrows[i].y;
|
||||
z = arrows[i].z;
|
||||
|
||||
offset_vertex += write_one_arrow_lines (offset_vertex, space_X, space_Y, space_Z,
|
||||
load, site, x, y, z);
|
||||
}
|
||||
|
||||
// ? free (space) TODO
|
||||
free(arrows);
|
||||
arrows = NULL;
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "../../include/base.h"
|
||||
#include "../../include/graphics.h"
|
||||
|
||||
int write_space_ridges (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z)
|
||||
int write_space_ridges_vertex (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z)
|
||||
{
|
||||
float max = fmax(x, y); max = fmax(max, z);
|
||||
graphics_write_vertex (offset_vertex - x / max, offset_vertex - y / max, - z / max);
|
||||
|
@ -49,6 +49,11 @@ int write_space_ridges (long offset_vertex, long offset_colors, long offset_line
|
|||
graphics_write_color (0.9f, 0.2f, 0.1f);
|
||||
graphics_write_color (0.9f, 0.2f, 0.1f);
|
||||
|
||||
return 8;
|
||||
}
|
||||
|
||||
int write_space_ridges_lines (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z)
|
||||
{
|
||||
graphics_write_line ( 0, 1); graphics_write_line ( 7, 4);
|
||||
graphics_write_line ( 0, 2); graphics_write_line ( 7, 5);
|
||||
graphics_write_line ( 0, 3); graphics_write_line ( 7, 6);
|
||||
|
@ -60,7 +65,7 @@ int write_space_ridges (long offset_vertex, long offset_colors, long offset_line
|
|||
return 8;
|
||||
}
|
||||
|
||||
long write_grids_on_space_faces (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 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);
|
||||
|
||||
|
@ -77,19 +82,8 @@ long write_grids_on_space_faces (long offset_vertex, long offset_colors, long of
|
|||
graphics_write_color (0.5f, 0.5f, 0.5f);
|
||||
}
|
||||
|
||||
for (i = 0; i < x - 1; i ++) {
|
||||
|
||||
if (style)
|
||||
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);
|
||||
if (style)
|
||||
graphics_write_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0);
|
||||
}
|
||||
|
||||
offset_vertex += (x - 1) * 4;
|
||||
offset_colors += (x - 1) * 4;
|
||||
if (style) offset_lines += (x - 1) * 2; else offset_lines += (x - 1) * 4;
|
||||
|
||||
for (i = 1; i < y; i++) { // (y - 2) * 4
|
||||
|
||||
|
@ -104,19 +98,8 @@ long write_grids_on_space_faces (long offset_vertex, long offset_colors, long of
|
|||
graphics_write_color (0.5f, 0.5f, 0.5f);
|
||||
}
|
||||
|
||||
for (i = 0; i < y - 1; i ++) {
|
||||
|
||||
if (style)
|
||||
graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1);
|
||||
if (style)
|
||||
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) offset_lines += (y - 1) * 2; else offset_lines += (y - 1) * 4;
|
||||
|
||||
for (i = 1; i < z; i++) { // (z - 2) * 4
|
||||
|
||||
|
@ -131,6 +114,38 @@ long write_grids_on_space_faces (long offset_vertex, long offset_colors, long of
|
|||
graphics_write_color (0.5f, 0.5f, 0.5f);
|
||||
}
|
||||
|
||||
return (x + y + z - 3) * 4;
|
||||
}
|
||||
|
||||
|
||||
long write_grids_on_space_faces_lines (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);
|
||||
|
||||
for (i = 0; i < x - 1; i ++) {
|
||||
|
||||
if (style)
|
||||
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);
|
||||
if (style)
|
||||
graphics_write_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0);
|
||||
}
|
||||
|
||||
/* if (style) offset_lines += (x - 1) * 2; else offset_lines += (x - 1) * 4; */
|
||||
|
||||
for (i = 0; i < y - 1; i ++) {
|
||||
|
||||
if (style)
|
||||
graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1);
|
||||
if (style)
|
||||
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) offset_lines += (y - 1) * 2; else offset_lines += (y - 1) * 4; */
|
||||
|
||||
for (i = 0; i < z - 1; i ++) {
|
||||
|
||||
graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1);
|
||||
|
@ -141,6 +156,8 @@ long write_grids_on_space_faces (long offset_vertex, long offset_colors, long of
|
|||
graphics_write_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0);
|
||||
}
|
||||
|
||||
printf("write_grids_on_space_faces_lines\n");
|
||||
|
||||
return (x + y + z - 3) * 4;
|
||||
/* if (style) 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