aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_sort_s_t.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-25 17:16:48 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-25 17:16:48 +0100
commita88662bebb21d598c7d06f09433950ba10155cff (patch)
tree42af13d4544744253fa55fbea0e9cbd40a6354e4 /src/ft_sort_s_t.c
parentGet normed (diff)
parentpourquoi se priver de stack (diff)
download42-cub3d-a88662bebb21d598c7d06f09433950ba10155cff.tar.gz
42-cub3d-a88662bebb21d598c7d06f09433950ba10155cff.tar.bz2
42-cub3d-a88662bebb21d598c7d06f09433950ba10155cff.tar.xz
42-cub3d-a88662bebb21d598c7d06f09433950ba10155cff.tar.zst
42-cub3d-a88662bebb21d598c7d06f09433950ba10155cff.zip
Merge branch 'better_m_s'
Diffstat (limited to 'src/ft_sort_s_t.c')
-rw-r--r--src/ft_sort_s_t.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/ft_sort_s_t.c b/src/ft_sort_s_t.c
new file mode 100644
index 0000000..24ed358
--- /dev/null
+++ b/src/ft_sort_s_t.c
@@ -0,0 +1,47 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_sort_s_t.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/24 20:22:45 by rbousset #+# #+# */
+/* Updated: 2020/03/09 18:56:01 by rbousset ### ########lyon.fr */
+/* */
+/* ************************************************************************** */
+
+#include <libft.h>
+#include <cub3d.h>
+#include <stdint.h>
+
+static void
+ ft_init_st(uint16_t sprite_var, int32_t st_o[8])
+{
+ int8_t i;
+
+ i = -1;
+ while (++i < sprite_var)
+ st_o[i] = i;
+}
+
+void
+ ft_sort_s_t(t_cub *cl, float dist_tab[8][4096])
+{
+ int16_t i;
+ int32_t tmp;
+ float tmp_i[4096];
+
+ 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;
+ }
+}