sg2_senc2d_helper.h (2514B)
1 /* Copyright (C) 2019, 2020, 2023 |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 #ifndef SG2D_SENC_2D_HELPER_H__ 17 #define SG2D_SENC_2D_HELPER_H__ 18 19 #include "sg2.h" 20 #include <star/senc2d.h> 21 22 #include <rsys/rsys.h> 23 24 /* Get vertex indices for the iseg_th segment. 25 * Suitable for use as get_indices callback in senc2d_scene_create calls. */ 26 static FINLINE void 27 sg2d_senc_geometry_get_indices 28 (const unsigned iseg, 29 unsigned indices[SG2D_GEOMETRY_DIMENSION], 30 void* ctx) 31 { 32 const struct sg2d_geometry* geometry = ctx; 33 res_T r; 34 ASSERT(indices && geometry); 35 r = sg2d_geometry_get_unique_segment_vertices(geometry, iseg, indices); 36 ASSERT(r == RES_OK); (void)r; 37 } 38 39 /* Get vertex indices for the iseg_th segment. 40 * Suitable for use as get_media callback in senc2d_scene_create calls. */ 41 static FINLINE void 42 sg2d_senc_geometry_get_media 43 (const unsigned iseg, 44 unsigned media[2], 45 void* ctx) 46 { 47 const struct sg2d_geometry* geometry = ctx; 48 unsigned tmp[SG2D_PROP_TYPES_COUNT__]; 49 res_T r; 50 ASSERT(media && geometry); 51 r = sg2d_geometry_get_unique_segment_properties(geometry, iseg, tmp); 52 ASSERT(r == RES_OK); (void)r; 53 media[SENC2D_FRONT] = (tmp[SG2D_FRONT] == SG2D_UNSPECIFIED_PROPERTY) 54 ? SENC2D_UNSPECIFIED_MEDIUM : tmp[SG2D_FRONT]; 55 media[SENC2D_BACK] = (tmp[SG2D_BACK] == SG2D_UNSPECIFIED_PROPERTY) 56 ? SENC2D_UNSPECIFIED_MEDIUM : tmp[SG2D_BACK]; 57 } 58 59 /* Get vertex indices for the iseg_th segment. 60 * Suitable for use as get_position callback in senc2d_scene_create calls. */ 61 static FINLINE void 62 sg2d_senc_geometry_get_position 63 (const unsigned ivert, 64 double coord[SG2D_GEOMETRY_DIMENSION], 65 void* ctx) 66 { 67 const struct sg2d_geometry* geometry = ctx; 68 res_T r; 69 ASSERT(coord && geometry); 70 r = sg2d_geometry_get_unique_vertex(geometry, ivert, coord); 71 ASSERT(r == RES_OK); (void)r; 72 } 73 74 END_DECLS 75 76 #endif /* SG2D_SENC_2D_HELPER_H__ */