aboutsummaryrefslogtreecommitdiff
path: root/render.c
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-01-15 15:15:24 +0100
committerCharles <sircharlesaze@gmail.com>2020-01-15 15:15:24 +0100
commit83ca51f2cc760dca7635232b4b6e40db9616534f (patch)
treef23f413f5f24ad89102d4c05dff8cbce832959bf /render.c
parent58261e54bfd281273a67c4c8e06ffc5164ad8ba1 (diff)
downloadcub3d-83ca51f2cc760dca7635232b4b6e40db9616534f.tar.gz
cub3d-83ca51f2cc760dca7635232b4b6e40db9616534f.tar.bz2
cub3d-83ca51f2cc760dca7635232b4b6e40db9616534f.zip
raycasting local -> t_render_state, algo helper in render_state.c
Diffstat (limited to 'render.c')
-rw-r--r--render.c98
1 files changed, 49 insertions, 49 deletions
diff --git a/render.c b/render.c
index 77eb3b9..e584621 100644
--- a/render.c
+++ b/render.c
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/01/11 13:37:17 by cacharle #+# #+# */
-/* Updated: 2020/01/12 15:45:03 by cacharle ### ########.fr */
+/* Updated: 2020/01/15 15:09:32 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -40,65 +40,65 @@ void render_update_window(t_state *state)
void render_column(t_state *state, int x)
{
- t_vector ray;
- t_vector map_pos;
- t_vector delta;
- t_side side;
- int line_height;
+ t_render_state rstate;
- ray = get_ray(state, x);
- map_pos = vector_new((double)((int)state->pos.x), (double)((int)state->pos.y));
- delta = get_delta(ray);
- current = get_init_delta(state, ray, map_pos, delta);
- map_step = vector_new(ray.x < 0.0 ? -1.0 : 1.0, ray.y < 0.0 ? -1.0 : 1.0));
+ rstate.x = x;
+ rstate_ray(state, &rstate);
+ vector_new((double)((int)state->pos.x), (double)((int)state->pos.y));
+ rstate_delta(&rstate);
+ rstate_init_probe(state, &rstate);
+ vector_new(rstate.ray.x < 0.0 ? -1.0 : 1.0, rstate.ray.y < 0.0 ? -1.0 : 1.0);
while (TRUE)
{
- side = current.x < current.y ? SIDE_WE : SIDE_WE;
- helper_ray_next(&current, map_pos, delta, map_step);
- if (state->map[(int)map_pos.y][(int)map_pos.x] == CELL_WALL)
- break;
+ rstate.side = rstate.probe.x < rstate.probe.y ? SIDE_WE : SIDE_WE;
+ rstate_next_probe(&rstate);
+ if (state->map[(int)rstate.map_pos.y][(int)rstate.map_pos.x] == CELL_WALL)
+ break ;
}
- line_height = get_line_height(state, get_perp_dist(state, &current, side), side);
- render_window_column(state, x, side, WINDOW_MID_HEIGHT(state) - line_height / 2,
- WINDOW_MID_HEIGHT(state) + line_height / 2);
+ rstate_line_height(state, &rstate);
+ render_window_column(state, &rstate);
+ // WINDOW_MID_HEIGHT(state) - line_height / 2
+ // WINDOW_MID_HEIGHT(state) + line_height / 2
}
-void render_window_column(t_state *state, int x, t_side side, int start, int end)
+void render_window_column(t_state *state, t_render_state *rstate)
{
int i;
t_color white;
white.hexcode = 0x00ffffff;
i = -1;
- while (++i < draw_start)
- ((t_color*)state->window.data)[i * state->window.width + x] = state->ceilling_color;
- i = render_texture(state, side, start, end);
- while (++i < state->window_height)
- ((t_color*)state->window.data)[i * state->window.width + x] = state->floor_color;
+ /* while (++i < draw_start) */
+ /* ((t_color*)state->window.data)[i * state->window.width + rstate->x] = */
+ /* state->ceilling_color; */
+ /* i = render_texture(state, rstate); */
+ /* while (++i < state->window_height) */
+ /* ((t_color*)state->window.data)[i * state->window.width + rstate->x] = */
+ /* state->floor_color; */
}
-int render_texture(t_state *state, t_side side, int start, int end)
-{
- int i;
- int tex_x;
- double step;
- double tex_pos;
- int tex_y;
- t_image *texture;
-
- texture = get_tex(state, side);
- tex_x = get_tex_x();
-
- step = 1.0 * texture->height / line_height;
- texPos = (start - state->window.height / 2 + line_height / 2) * step;
-
- i = start - 1;
- while (++i < end)
- {
- tex_y = (int)tex_pos & (texture->height - 1);
- tex_pos += step;
- ((t_color*)state->window.data)[i * state->window.width + x] =
- texture[texHeight * texY + texX];
- }
- return (end);
-}
+/* int render_texture(t_state *state, t_render_state *rstate)) */
+/* { */
+ /* int i; */
+ /* int tex_x; */
+ /* double step; */
+ /* double tex_pos; */
+ /* int tex_y; */
+ /* t_image *texture; */
+ /* */
+ /* texture = get_tex(state, side); */
+ /* tex_x = get_tex_x(); */
+ /* */
+ /* step = 1.0 * texture->height / line_height; */
+ /* texPos = (start - state->window.height / 2 + line_height / 2) * step; */
+ /* */
+ /* i = start - 1; */
+ /* while (++i < end) */
+ /* { */
+ /* tex_y = (int)tex_pos & (texture->height - 1); */
+ /* tex_pos += step; */
+ /* ((t_color*)state->window.data)[i * state->window.width + x] = */
+ /* texture[texHeight * texY + texX]; */
+ /* } */
+ /* return (end); */
+/* } */