sg3d_sencXd_helper.h (2371B)
1 /* Copyright (C) 2019, 2020, 2023, 2024 |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 SG3D_SENC3D_HELPER_H__ 17 #define SG3D_SENC3D_HELPER_H__ 18 19 #include "sg3d.h" 20 #include <star/senc3d.h> 21 22 #include <rsys/rsys.h> 23 24 /* Get vertex indices for the itri_th triangle. 25 * Suitable for use as get_indices callback in senc_scene_create calls. */ 26 static FINLINE void 27 sg3d_sencXd_geometry_get_indices 28 (const unsigned itri, 29 unsigned indices[SG3D_GEOMETRY_DIMENSION], 30 void* ctx) 31 { 32 const struct sg3d_geometry* geometry = ctx; 33 ASSERT(indices && geometry); 34 SG3D(geometry_get_unique_triangle_vertices(geometry, itri, indices)); 35 } 36 37 /* Get vertex indices for the itri_th triangle. 38 * Suitable for use as get_media callback in senc_scene_create calls. */ 39 static FINLINE void 40 sg3d_sencXd_geometry_get_media 41 (const unsigned itri, 42 unsigned media[2], 43 void* ctx) 44 { 45 const struct sg3d_geometry* geometry = ctx; 46 unsigned tmp[SG3D_PROP_TYPES_COUNT__]; 47 ASSERT(media && geometry); 48 SG3D(geometry_get_unique_triangle_properties(geometry, itri, tmp)); 49 media[SENC3D_FRONT] = (tmp[SG3D_FRONT] == SG3D_UNSPECIFIED_PROPERTY) 50 ? SENC3D_UNSPECIFIED_MEDIUM : tmp[SG3D_FRONT]; 51 media[SENC3D_BACK] = (tmp[SG3D_BACK] == SG3D_UNSPECIFIED_PROPERTY) 52 ? SENC3D_UNSPECIFIED_MEDIUM : tmp[SG3D_BACK]; 53 } 54 55 /* Get vertex indices for the itri_th triangle. 56 * Suitable for use as get_position callback in senc_scene_create calls. */ 57 static FINLINE void 58 sg3d_sencXd_geometry_get_position 59 (const unsigned ivert, 60 double coord[SG3D_GEOMETRY_DIMENSION], 61 void* ctx) 62 { 63 const struct sg3d_geometry* geometry = ctx; 64 ASSERT(coord && geometry); 65 SG3D(geometry_get_unique_vertex(geometry, ivert, coord)); 66 } 67 68 #endif /* SG2_SENC3D_HELPER_H__ */