DEBOGAGE
This commit is contained in:
@@ -6,14 +6,14 @@
|
||||
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/17 18:54:45 by yantoine #+# #+# */
|
||||
/* Updated: 2025/02/17 18:54:46 by yantoine ### ########.fr */
|
||||
/* Updated: 2025/02/17 21:28:56 by yantoine ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "miniRT.h"
|
||||
|
||||
// Initialise les variables de calcul et les coefficients du polynôme d'intersection
|
||||
static int init_intersection(Ray ray, Cylinder cy, t_calc *calc) {
|
||||
static int init_intersection(t_ray ray, t_cylinder cy, t_calc *calc) {
|
||||
calc->d = ray.dir;
|
||||
calc->oc = vec3_sub(ray.origin, cy.center);
|
||||
calc->v = cy.axis;
|
||||
@@ -34,7 +34,7 @@ static int init_intersection(Ray ray, Cylinder cy, t_calc *calc) {
|
||||
}
|
||||
|
||||
// Calcule l'intersection sur la surface latérale du cylindre
|
||||
static void compute_side_intersection(Ray ray, Cylinder cy, t_calc *calc) {
|
||||
static void compute_side_intersection(t_cylinder cy, t_calc *calc) {
|
||||
calc->t_side = -1;
|
||||
if (calc->t0 > 1e-3f) {
|
||||
calc->y = calc->oc_dot_v + calc->t0 * calc->d_dot_v;
|
||||
@@ -49,7 +49,7 @@ static void compute_side_intersection(Ray ray, Cylinder cy, t_calc *calc) {
|
||||
}
|
||||
|
||||
// Calcule l'intersection sur les capuchons supérieur et inférieur
|
||||
static void compute_cap_intersection(Ray ray, Cylinder cy, t_calc *calc) {
|
||||
static void compute_cap_intersection(t_ray ray, t_cylinder cy, t_calc *calc) {
|
||||
calc->t_cap = -1;
|
||||
if (fabs(calc->d_dot_v) > 1e-6f) {
|
||||
calc->t_bot = ((-cy.height / 2.0f) - calc->oc_dot_v) / calc->d_dot_v;
|
||||
@@ -83,7 +83,7 @@ static float select_final_intersection(t_calc *calc) {
|
||||
}
|
||||
|
||||
// Calcule la normale au point d'intersection
|
||||
static void compute_hit_normal(Ray ray, Cylinder cy, t_calc *calc, t_vec3 *hitNormal) {
|
||||
static void compute_hit_normal(t_ray ray, t_cylinder cy, t_calc *calc, t_vec3 *hitNormal) {
|
||||
calc->hitPoint = vec3_add(ray.origin, vec3_scale(calc->d, calc->t_final));
|
||||
calc->cp = vec3_sub(calc->hitPoint, cy.center);
|
||||
calc->proj = vec3_dot(calc->cp, calc->v);
|
||||
@@ -96,11 +96,11 @@ static void compute_hit_normal(Ray ray, Cylinder cy, t_calc *calc, t_vec3 *hitNo
|
||||
}
|
||||
|
||||
// Fonction principale d'intersection du cylindre
|
||||
float intersectCylinder(Ray ray, Cylinder cy, t_vec3 *hitNormal) {
|
||||
float intersectCylinder(t_ray ray, t_cylinder cy, t_vec3 *hitNormal) {
|
||||
t_calc calc;
|
||||
if (init_intersection(ray, cy, &calc) < 0)
|
||||
return -1;
|
||||
compute_side_intersection(ray, cy, &calc);
|
||||
compute_side_intersection(cy, &calc);
|
||||
compute_cap_intersection(ray, cy, &calc);
|
||||
if (select_final_intersection(&calc) < 0)
|
||||
return -1;
|
||||
|
||||
Reference in New Issue
Block a user