s3d_geometry.h (2327B)
1 /* Copyright (C) 2015-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 S3D_GEOMETRY_H 17 #define S3D_GEOMETRY_H 18 19 #include "s3d.h" 20 #include "s3d_backend.h" 21 #include <rsys/float3.h> 22 #include <rsys/ref_count.h> 23 24 enum geometry_type { 25 GEOM_MESH, 26 GEOM_INSTANCE, 27 GEOM_SPHERE, 28 GEOM_TYPES_COUNT__, 29 GEOM_NONE = GEOM_TYPES_COUNT__ 30 }; 31 32 enum embree_attrib { 33 EMBREE_ENABLE = BIT(0), 34 EMBREE_FILTER_FUNCTION = BIT(1), 35 EMBREE_INDICES = BIT(2), 36 EMBREE_TRANSFORM = BIT(3), 37 EMBREE_VERTICES = BIT(4), 38 EMBREE_USER_GEOMETRY = BIT(5) 39 }; 40 41 /* Backend geometry */ 42 struct geometry { 43 unsigned name; /* Client side identifier */ 44 RTCGeometry rtc; /* Embree geometry */ 45 enum RTCBuildQuality rtc_build_quality; /* BVH build quality */ 46 unsigned rtc_id; /* Embree geometry identifier */ 47 unsigned scene_prim_id_offset; /* Offset from local to scene prim_id */ 48 49 int embree_outdated_mask; /* Combination of embree_attrib */ 50 51 char flip_surface; /* Is the geometry surface flipped? */ 52 char is_enabled; /* Is the geometry enabled? */ 53 54 enum geometry_type type; 55 union { 56 struct instance* instance; 57 struct mesh* mesh; 58 struct sphere* sphere; 59 } data; 60 61 struct s3d_device* dev; 62 ref_T ref; 63 }; 64 65 extern LOCAL_SYM res_T 66 geometry_create 67 (struct s3d_device* dev, 68 struct geometry** geom); 69 70 extern LOCAL_SYM void 71 geometry_ref_get 72 (struct geometry* geometry); 73 74 extern LOCAL_SYM void 75 geometry_ref_put 76 (struct geometry* geometry); 77 78 extern LOCAL_SYM void 79 geometry_rtc_sphere_bounds 80 (const struct RTCBoundsFunctionArguments* args); 81 82 extern LOCAL_SYM void 83 geometry_rtc_sphere_intersect 84 (const struct RTCIntersectFunctionNArguments* args); 85 86 #endif /* S3D_GEOMETRY_H */