htrdr_combustion_geometry_ray_filter.c (2845B)
1 /* Copyright (C) 2018-2019, 2022-2025 Centre National de la Recherche Scientifique 2 * Copyright (C) 2020-2022 Institut Mines Télécom Albi-Carmaux 3 * Copyright (C) 2022-2025 Institut Pierre-Simon Laplace 4 * Copyright (C) 2022-2025 Institut de Physique du Globe de Paris 5 * Copyright (C) 2018-2025 |Méso|Star> (contact@meso-star.com) 6 * Copyright (C) 2022-2025 Observatoire de Paris 7 * Copyright (C) 2022-2025 Université de Reims Champagne-Ardenne 8 * Copyright (C) 2022-2025 Université de Versaille Saint-Quentin 9 * Copyright (C) 2018-2019, 2022-2025 Université Paul Sabatier 10 * 11 * This program is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation, either version 3 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program. If not, see <http://www.gnu.org/licenses/>. */ 23 24 #include "combustion/htrdr_combustion_geometry_ray_filter.h" 25 26 #include "core/htrdr_interface.h" 27 #include "core/htrdr_geometry.h" 28 29 #include <rsys/float3.h> 30 31 #include <string.h> 32 33 /******************************************************************************* 34 * Local functions 35 ******************************************************************************/ 36 int 37 geometry_ray_filter_discard_medium_interface 38 (const struct s3d_hit* hit, 39 const float ray_org[3], 40 const float ray_dir[3], 41 const float ray_range[2], 42 void* ray_data, 43 void* filter_data) 44 { 45 struct geometry_ray_filter_context* ctx = ray_data; 46 struct htrdr_interface interf = HTRDR_INTERFACE_NULL; 47 const struct htrdr_mtl* mtl = NULL; 48 float N[3]; 49 int hit_front; 50 int discard = 0; 51 ASSERT(hit && ray_org && ray_dir && ray_range && ray_data && !S3D_HIT_NONE(hit)); 52 (void)ray_org, (void)ray_dir, (void)ray_range, (void)filter_data; 53 54 /* Recover the interface of the intersected surface */ 55 htrdr_geometry_get_interface(ctx->geom, hit, &interf); 56 57 /* Define if the ray intersects the front face of the surface */ 58 f3_normalize(N, hit->normal); /* Limit the numerical instabilities */ 59 hit_front = f3_dot(ray_dir, N) < 0; 60 61 /* Recover the material in which the ray is traced */ 62 if(hit_front) { 63 mtl = &interf.mtl_front; 64 } else { 65 mtl = &interf.mtl_back; 66 } 67 68 /* The material should be semi-transparent and thus could not have a BRDF */ 69 ASSERT(mtl->mrumtl == NULL); 70 71 /* Discard the intersection if the ray comes from the material to filter */ 72 discard = !strcmp(mtl->name, ctx->medium_name); 73 return discard; 74 } 75