rngrd_c.h (3917B)
1 /* Copyright (C) 2022, 2023, 2025 Centre National de la Recherche Scientifique 2 * Copyright (C) 2022, 2023, 2025 Institut Pierre-Simon Laplace 3 * Copyright (C) 2022, 2023, 2025 Institut de Physique du Globe de Paris 4 * Copyright (C) 2022, 2023, 2025 |Méso|Star> (contact@meso-star.com) 5 * Copyright (C) 2022, 2023, 2025 Observatoire de Paris 6 * Copyright (C) 2022, 2023, 2025 Université de Reims Champagne-Ardenne 7 * Copyright (C) 2022, 2023, 2025 Université de Versaille Saint-Quentin 8 * Copyright (C) 2022, 2023, 2025 Université Paul Sabatier 9 * 10 * This program is free software: you can redistribute it and/or modify 11 * it under the terms of the GNU General Public License as published by 12 * the Free Software Foundation, either version 3 of the License, or 13 * (at your option) any later version. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with this program. If not, see <http://www.gnu.org/licenses/>. */ 22 23 #ifndef RNGRD_C_H 24 #define RNGRD_C_H 25 26 #include <rsys/dynamic_array.h> 27 #include <rsys/logger.h> 28 #include <rsys/ref_count.h> 29 #include <rsys/str.h> 30 31 struct rngrd_create_args; 32 struct mrumtl; 33 struct ssf_bsdf; 34 35 /******************************************************************************* 36 * BSDF 37 ******************************************************************************/ 38 extern LOCAL_SYM res_T 39 bsdf_init 40 (struct mem_allocator* allocator, 41 struct ssf_bsdf** bsdf); 42 43 extern LOCAL_SYM void 44 bsdf_release 45 (struct ssf_bsdf** bsdf); 46 47 extern LOCAL_SYM res_T 48 bsdf_copy 49 (struct ssf_bsdf** dst, 50 struct ssf_bsdf* const* src); 51 52 extern LOCAL_SYM res_T 53 bsdf_copy_and_release 54 (struct ssf_bsdf** dst, 55 struct ssf_bsdf** src); 56 57 /* Generate the dynamic array of BSDFs */ 58 #define DARRAY_NAME bsdf 59 #define DARRAY_DATA struct ssf_bsdf* 60 #define DARRAY_FUNCTOR_INIT bsdf_init 61 #define DARRAY_FUNCTOR_RELEASE bsdf_release 62 #define DARRAY_FUNCTOR_COPY bsdf_copy 63 #define DARRAY_FUNCTOR_COPY_AND_RELEASE bsdf_copy_and_release 64 #include <rsys/dynamic_array.h> 65 66 /******************************************************************************* 67 * Material 68 ******************************************************************************/ 69 struct mtl { 70 struct mrumtl* mrumtl; 71 struct darray_bsdf bsdf_lst; 72 }; 73 74 extern LOCAL_SYM res_T 75 mtl_init 76 (struct mem_allocator* allocator, 77 struct mtl* mtl); 78 79 extern LOCAL_SYM void 80 mtl_release 81 (struct mtl* mtl); 82 83 extern LOCAL_SYM res_T 84 mtl_copy 85 (struct mtl* dst, 86 const struct mtl* src); 87 88 extern LOCAL_SYM res_T 89 mtl_copy_and_release 90 (struct mtl* dst, 91 struct mtl* src); 92 93 /* Generate the dynamic array of materials */ 94 #define DARRAY_NAME mtl 95 #define DARRAY_DATA struct mtl 96 #define DARRAY_FUNCTOR_INIT mtl_init 97 #define DARRAY_FUNCTOR_RELEASE mtl_release 98 #define DARRAY_FUNCTOR_COPY mtl_copy 99 #define DARRAY_FUNCTOR_COPY_AND_RELEASE mtl_copy_and_release 100 #include <rsys/dynamic_array.h> 101 102 /******************************************************************************* 103 * Ground 104 ******************************************************************************/ 105 struct rngrd { 106 /* Geometry */ 107 struct s3d_device* s3d; 108 struct s3d_scene_view* s3d_view; 109 size_t ntriangles; 110 111 /* Properties */ 112 struct darray_mtl mtls; 113 struct sbuf* props; 114 115 struct str name; 116 117 int verbose; 118 struct logger* logger; 119 struct logger logger__; 120 struct mem_allocator* allocator; 121 ref_T ref; 122 }; 123 124 extern LOCAL_SYM res_T 125 setup_mesh 126 (struct rngrd* ground, 127 const struct rngrd_create_args* args); 128 129 extern LOCAL_SYM res_T 130 setup_properties 131 (struct rngrd* ground, 132 const struct rngrd_create_args* args); 133 134 extern LOCAL_SYM res_T 135 check_properties 136 (const struct rngrd* ground); 137 138 #endif /* RNGRD_C_H */