void	set_val_sphere(t_env *env, double t, t_ray *ray)
{
	OBJ.new_start = vector_add(ray->start, vector_scale(t, ray->dir));
	OBJ.normal = vector_sub(OBJ.new_start, SP_POS(OBJ.cur_sphere));
	if (vector_dot(OBJ.normal, OBJ.normal) == 0)
	{
		env->br = 1;
		return ;
	}
	OBJ.normal = vector_scale(1.0f / ABSV(OBJ.normal), OBJ.normal);
	OBJ.cur_mat = env->obj.mats[SPHERES[OBJ.cur_sphere].shape.material];
}
Beispiel #2
0
void	set_val_sphere(t_env *env, float t, t_ray ray)
{
	t_vector	scaled;

	scaled = vector_scale(t, &ray.dir);
	OBJ.new_start = vector_add(&ray.start, &scaled);
	OBJ.normal = vector_sub(&OBJ.new_start, &SP_POS(OBJ.cur_sphere));
	if (vector_dot(&OBJ.normal, &OBJ.normal) == 0)
	{
		env->br = 1;
		return ;
	}
	OBJ.normal = vector_scale(1.0f / ABSV(OBJ.normal), &OBJ.normal);
	OBJ.cur_mat = env->obj.mats[SPHERES[OBJ.cur_sphere].shape.material];
}