test_ssol_geometries.h (2267B)
1 /* Copyright (C) 2018-2026 |Meso|Star> (contact@meso-star.com) 2 * Copyright (C) 2016, 2018 CNRS 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 17 #ifndef TEST_SSOL_GEOMETRIES_H 18 #define TEST_SSOL_GEOMETRIES_H 19 20 struct desc { 21 const float* vertices; 22 const unsigned* indices; 23 }; 24 25 /******************************************************************************* 26 * Callbacks 27 ******************************************************************************/ 28 static INLINE void 29 get_ids(const unsigned itri, unsigned ids[3], void* data) 30 { 31 const unsigned id = itri * 3; 32 struct desc* desc = data; 33 CHK(desc != NULL); 34 CHK(ids != NULL); 35 ids[0] = desc->indices[id + 0]; 36 ids[1] = desc->indices[id + 1]; 37 ids[2] = desc->indices[id + 2]; 38 } 39 40 static INLINE void 41 get_position(const unsigned ivert, float position[3], void* data) 42 { 43 struct desc* desc = data; 44 CHK(desc != NULL); 45 CHK(position != NULL); 46 position[0] = desc->vertices[ivert * 3 + 0]; 47 position[1] = desc->vertices[ivert * 3 + 1]; 48 position[2] = desc->vertices[ivert * 3 + 2]; 49 } 50 51 static INLINE void 52 get_normal(const unsigned ivert, float normal[3], void* data) 53 { 54 (void)ivert, (void)data; 55 CHK(normal != NULL); 56 normal[0] = 1.f; 57 normal[1] = 0.f; 58 normal[2] = 0.f; 59 } 60 61 static INLINE void 62 get_uv(const unsigned ivert, float uv[2], void* data) 63 { 64 (void)ivert, (void)data; 65 CHK(uv != NULL); 66 uv[0] = -1.f; 67 uv[1] = 1.f; 68 } 69 70 static INLINE void 71 get_polygon_vertices(const size_t ivert, double position[2], void* ctx) 72 { 73 const double* verts = ctx; 74 CHK(position != NULL); 75 CHK(ctx != NULL); 76 position[0] = verts[ivert*2+0]; 77 position[1] = verts[ivert*2+1]; 78 } 79 80 #endif /* TEST_SSOL_GEOMETRIES_H */