WIP: fonction erase_arrow() nettoyée (une bête histoire de variable globale/locale sur arrows_nb)
This commit is contained in:
parent
41200d1afe
commit
abc118d8e1
|
@ -594,7 +594,7 @@ static void compute_buffers_sizes(int model_space_size_x,
|
||||||
int model_space_size_y,
|
int model_space_size_y,
|
||||||
int model_space_size_z,
|
int model_space_size_z,
|
||||||
|
|
||||||
int arrows_nb,
|
// int arrows_nb,
|
||||||
|
|
||||||
// int pref_mark_unit_space,
|
// int pref_mark_unit_space,
|
||||||
// int pref_style_lines_planes,
|
// int pref_style_lines_planes,
|
||||||
|
@ -654,8 +654,7 @@ static void compute_buffers_sizes(int model_space_size_x,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static bool rewrite_arrow (GLuint *arrows, int arrows_nb,
|
static bool rewrite_arrow (GLuint *arrows, long address, long weight,
|
||||||
long address, long weight,
|
|
||||||
long site, long x, long y, long z)
|
long site, long x, long y, long z)
|
||||||
{
|
{
|
||||||
printf("write the arrow weight to %ld at (%ld, %ld, %ld, %ld)\n",\
|
printf("write the arrow weight to %ld at (%ld, %ld, %ld, %ld)\n",\
|
||||||
|
@ -663,15 +662,14 @@ static bool rewrite_arrow (GLuint *arrows, int arrows_nb,
|
||||||
return 1; /* replaces the load of the existing arrow by the load 'weight' */
|
return 1; /* replaces the load of the existing arrow by the load 'weight' */
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool create_arrow (GLuint *arrows, int arrows_nb,
|
static bool create_arrow (GLuint *arrows, long weight, long site, long x, long y, long z)
|
||||||
long weight, long site, long x, long y, long z)
|
|
||||||
{
|
{
|
||||||
printf("create a new arrow with weight = %ld at (%ld, %ld, %ld, %ld)\n",\
|
printf("create a new arrow with weight = %ld at (%ld, %ld, %ld, %ld)\n",\
|
||||||
weight, site, x, y, z);
|
weight, site, x, y, z);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool erase_arrow (GLuint *arrows, int arrows_nb, long address,
|
static bool erase_arrow (GLuint *arrows, long address,
|
||||||
long site, long x, long y, long z)
|
long site, long x, long y, long z)
|
||||||
{
|
{
|
||||||
if (1) printf("erase arrow at address %ld with values (%ld, %ld, %ld, %ld)\n",\
|
if (1) printf("erase arrow at address %ld with values (%ld, %ld, %ld, %ld)\n",\
|
||||||
|
@ -689,12 +687,6 @@ static bool erase_arrow (GLuint *arrows, int arrows_nb, long address,
|
||||||
*(arrows + address + 3) = *(arrows + (arrows_nb - 1) * 5 + 3);
|
*(arrows + address + 3) = *(arrows + (arrows_nb - 1) * 5 + 3);
|
||||||
*(arrows + address + 4) = *(arrows + (arrows_nb - 1) * 5 + 4);
|
*(arrows + address + 4) = *(arrows + (arrows_nb - 1) * 5 + 4);
|
||||||
|
|
||||||
/* *(arrows + (arrows_nb - 1) * 5 + 0) = 0; // est-ce bien utile ? */
|
|
||||||
/* *(arrows + (arrows_nb - 1) * 5 + 1) = 0; */
|
|
||||||
/* *(arrows + (arrows_nb - 1) * 5 + 2) = 0; */
|
|
||||||
/* *(arrows + (arrows_nb - 1) * 5 + 3) = 0; */
|
|
||||||
/* *(arrows + (arrows_nb - 1) * 5 + 4) = 0; */
|
|
||||||
|
|
||||||
arrows_nb --;
|
arrows_nb --;
|
||||||
buffer_lines_size -= 14;
|
buffer_lines_size -= 14;
|
||||||
buffer_lines_origin = g_realloc(buffer_lines_origin, buffer_lines_size * 2 * sizeof(GLuint) * 2);
|
buffer_lines_origin = g_realloc(buffer_lines_origin, buffer_lines_size * 2 * sizeof(GLuint) * 2);
|
||||||
|
@ -704,8 +696,7 @@ static bool erase_arrow (GLuint *arrows, int arrows_nb, long address,
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static long check_for_arrow (GLuint *arrows, int arrows_nb,
|
static long check_for_arrow (GLuint *arrows, long site, long x, long y, long z)
|
||||||
long site, long x, long y, long z)
|
|
||||||
{
|
{
|
||||||
long address = -1, f_weight = -1, f_site = -1, f_x = -1, f_y = -1, f_z = -1;
|
long address = -1, f_weight = -1, f_site = -1, f_x = -1, f_y = -1, f_z = -1;
|
||||||
for (int i = 0; i < arrows_nb; i++)
|
for (int i = 0; i < arrows_nb; i++)
|
||||||
|
@ -726,14 +717,13 @@ static long check_for_arrow (GLuint *arrows, int arrows_nb,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool set_arrow (GLuint *arrows, int arrows_nb,
|
static bool set_arrow (GLuint *arrows, long weight, long site, long x, long y, long z)
|
||||||
long weight, long site, long x, long y, long z)
|
|
||||||
{
|
{
|
||||||
long address = (check_for_arrow (arrows, arrows_nb, site, x, y, z));
|
long address = (check_for_arrow (arrows, 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, 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, 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 && weight > 0) return rewrite_arrow (arrows, address, weight, site, x, y, z);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -773,7 +763,7 @@ void graphics_init_buffers(const void *gl_area)
|
||||||
model_space_size_y,
|
model_space_size_y,
|
||||||
model_space_size_z,
|
model_space_size_z,
|
||||||
|
|
||||||
arrows_nb,
|
// arrows_nb,
|
||||||
|
|
||||||
// pref_mark_unit_space,
|
// pref_mark_unit_space,
|
||||||
// pref_style_lines_planes,
|
// pref_style_lines_planes,
|
||||||
|
@ -813,12 +803,12 @@ void graphics_init_buffers(const void *gl_area)
|
||||||
model_space_size_z * model_space_size_y, model_space_size_z,
|
model_space_size_z * model_space_size_y, model_space_size_z,
|
||||||
arrows, arrows_nb);
|
arrows, arrows_nb);
|
||||||
|
|
||||||
set_arrow(arrows, arrows_nb, 0, 4, 3, 0, 0);
|
set_arrow(arrows, 0, 4, 3, 0, 0);
|
||||||
set_arrow(arrows, arrows_nb, 0, 5, 3, 0, 1);
|
set_arrow(arrows, 0, 5, 3, 0, 1);
|
||||||
set_arrow(arrows, arrows_nb, 0, 5, 2, 1, 1);
|
set_arrow(arrows, 0, 5, 2, 1, 1);
|
||||||
set_arrow(arrows, arrows_nb, 0, 4, 2, 1, 0);
|
set_arrow(arrows, 0, 4, 2, 1, 0);
|
||||||
set_arrow(arrows, arrows_nb, 0, 2, 2, 1, 1);
|
set_arrow(arrows, 0, 2, 2, 1, 1);
|
||||||
set_arrow(arrows, arrows_nb, 0, 3, 2, 2, 1);
|
set_arrow(arrows, 0, 3, 2, 2, 1);
|
||||||
|
|
||||||
draw_some_arrows (buffer_lines_origin, s,
|
draw_some_arrows (buffer_lines_origin, s,
|
||||||
model_space_size_z * model_space_size_y, model_space_size_z,
|
model_space_size_z * model_space_size_y, model_space_size_z,
|
||||||
|
|
Loading…
Reference in New Issue