aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_sort_s_t.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ft_sort_s_t.c')
-rw-r--r--src/ft_sort_s_t.c45
1 files changed, 25 insertions, 20 deletions
diff --git a/src/ft_sort_s_t.c b/src/ft_sort_s_t.c
index 24ed358..18007dd 100644
--- a/src/ft_sort_s_t.c
+++ b/src/ft_sort_s_t.c
@@ -12,36 +12,41 @@
#include <libft.h>
#include <cub3d.h>
+#include <stdlib.h>
#include <stdint.h>
static void
- ft_init_st(uint16_t sprite_var, int32_t st_o[8])
+ ft_init_st(int32_t *st_o)
{
- int8_t i;
+ int8_t i;
- i = -1;
- while (++i < sprite_var)
+ i = 0;
+ while (i < FT_TOTAL_SPRT)
+ {
st_o[i] = i;
+ i++;
+ }
}
void
- ft_sort_s_t(t_cub *cl, float dist_tab[8][4096])
+ ft_sort_s_t(t_cub *cl, float **dist_tab)
{
- int16_t i;
- int32_t tmp;
- float tmp_i[4096];
+ int32_t i;
+ ft_init_st(cl->mlist.st_o);
+ i = -1;
+ while (++i < cl->big_t_val)
+ ft_memdel((void*)&cl->big_t[i]);
+ ft_memdel((void*)&cl->big_t);
+ i = -1;
+ cl->big_t_val = 0;
+ while (++i < FT_TOTAL_SPRT)
+ cl->big_t_val += cl->mlist.sprite_nbr[i];
+ ft_alloc_big_t(cl);
+ ft_fill_big_t(dist_tab, cl);
+ ft_sort_big_t(cl);
i = -1;
- ft_init_st(cl->mlist.sprite_var, cl->mlist.st_o);
- while (++i < cl->mlist.sprite_var)
- if (dist_tab[i][0] < dist_tab[i + 1][0])
- {
- tmp = cl->mlist.st_o[i];
- cl->mlist.st_o[i] = cl->mlist.st_o[i + 1];
- cl->mlist.st_o[i + 1] = tmp;
- ft_memcpy(tmp_i, dist_tab[i], 4096);
- ft_memcpy(dist_tab[i], dist_tab[i + 1], 4096);
- ft_memcpy(dist_tab[i + 1], tmp_i, 4096);
- i = -1;
- }
+ while (++i < FT_TOTAL_SPRT + 1)
+ ft_memdel((void*)&dist_tab[i]);
+ ft_memdel((void*)&dist_tab);
}