sdis_heat_path_conductive_Xd.h (2333B)
1 /* Copyright (C) 2016-2025 |Méso|Star> (contact@meso-star.com) 2 * 3 * This program is free software: you can redistribute it and/or modify 4 * it under the terms of the GNU General Public License as published by 5 * the Free Software Foundation, either version 3 of the License, or 6 * (at your option) any later version. 7 * 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU General Public License for more details. 12 * 13 * You should have received a copy of the GNU General Public License 14 * along with this program. If not, see <http://www.gnu.org/licenses/>. */ 15 16 #include "sdis.h" 17 #include "sdis_heat_path.h" 18 #include "sdis_heat_path_conductive_c.h" 19 #include "sdis_log.h" 20 #include "sdis_medium_c.h" 21 #include "sdis_scene_c.h" 22 23 #include <rsys/cstr.h> 24 25 #include "sdis_Xd_begin.h" 26 27 /******************************************************************************* 28 * Local functions 29 ******************************************************************************/ 30 res_T 31 XD(conductive_path) 32 (struct sdis_scene* scn, 33 struct rwalk_context* ctx, 34 struct rwalk* rwalk, 35 struct ssp_rng* rng, 36 struct temperature* T) 37 { 38 struct sdis_medium* mdm = NULL; 39 unsigned enc_id = ENCLOSURE_ID_NULL; 40 res_T res = RES_OK; 41 ASSERT(ctx && rwalk); 42 43 res = scene_get_enclosure_id_in_closed_boundaries(scn, rwalk->vtx.P, &enc_id); 44 if(res != RES_OK) goto error; 45 res = scene_get_enclosure_medium(scn, scene_get_enclosure(scn, enc_id), &mdm); 46 if(res != RES_OK) goto error; 47 ASSERT(sdis_medium_get_type(mdm) == SDIS_SOLID); 48 49 /* The caller defined a custom function to sample the solid path */ 50 if(mdm->shader.solid.sample_path != NULL) { 51 res = XD(conductive_path_custom)(scn, enc_id, mdm, rwalk, rng, T); 52 if(res != RES_OK) goto error; 53 54 } else { 55 switch(ctx->diff_algo) { 56 case SDIS_DIFFUSION_DELTA_SPHERE: 57 res = XD(conductive_path_delta_sphere)(scn, ctx, rwalk, rng, T); 58 break; 59 case SDIS_DIFFUSION_WOS: 60 res = XD(conductive_path_wos)(scn, ctx, rwalk, rng, T); 61 break; 62 default: FATAL("Unreachable code.\n"); break; 63 } 64 if(res != RES_OK) goto error; 65 } 66 67 exit: 68 return res; 69 error: 70 goto exit; 71 } 72 73 #include "sdis_Xd_end.h"