-
Notifications
You must be signed in to change notification settings - Fork 0
/
dist.c
54 lines (49 loc) · 2.13 KB
/
dist.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* dist.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jserrano <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/10/20 11:30:12 by jserrano #+# #+# */
/* Updated: 2020/10/28 12:53:38 by jserrano ### ########.fr */
/* */
/* ************************************************************************** */
#include "dist/dist.h"
static void obj_dist_p1(t_data *param, double *dist, double *aux)
{
*dist = sp_dist(param);
param->cam.ray.obj_c = (*dist < 2147483647) ?
param->sp[param->cam.ray.obj_n]->col : param->cam.ray.obj_c;
*aux = pl_dist(param);
param->cam.ray.obj_c = (*aux < *dist) ?
param->pl[param->cam.ray.obj_n]->col : param->cam.ray.obj_c;
*dist = (*aux < *dist) ? *aux : *dist;
*aux = cy_dist(param);
param->cam.ray.obj_c = (*aux < *dist) ?
param->cy[param->cam.ray.obj_n]->col : param->cam.ray.obj_c;
*dist = (*aux < *dist) ? *aux : *dist;
}
static void obj_dist_p2(t_data *param, double *dist, double *aux)
{
*aux = sq_dist(param);
param->cam.ray.obj_c = (*aux < *dist) ?
param->sq[param->cam.ray.obj_n]->col : param->cam.ray.obj_c;
*dist = (*aux < *dist) ? *aux : *dist;
*aux = bx_dist(param);
param->cam.ray.obj_c = (*aux < *dist) ?
param->bx[param->cam.ray.obj_n]->col : param->cam.ray.obj_c;
*dist = (*aux < *dist) ? *aux : *dist;
*aux = tr_dist(param);
param->cam.ray.obj_c = (*aux < *dist) ?
param->tr[param->cam.ray.obj_n]->col : param->cam.ray.obj_c;
*dist = (*aux < *dist) ? *aux : *dist;
}
double obj_dist(t_data *param)
{
double dist;
double aux;
obj_dist_p1(param, &dist, &aux);
obj_dist_p2(param, &dist, &aux);
return (dist);
}