star-3d

Surface structuring for efficient 3D geometric queries
git clone git://git.meso-star.com/star-3d.git
Log | Files | Refs | README | LICENSE

s3d_geometry.h (2354B)


      1 /* Copyright (C) 2015-2023, 2026 |Méso|Star> (contact@meso-star.com)
      2  *
      3  * This file is part of Star-3D.
      4  *
      5  * Star-3D is free software: you can redistribute it and/or modify
      6  * it under the terms of the GNU General Public License as published by
      7  * the Free Software Foundation, either version 3 of the License, or
      8  * (at your option) any later version.
      9  *
     10  * Star-3D is distributed in the hope that it will be useful,
     11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     13  * GNU General Public License for more details.
     14  *
     15  * You should have received a copy of the GNU General Public License
     16  * along with Star-3D. If not, see <http://www.gnu.org/licenses/>. */
     17 
     18 #ifndef S3D_GEOMETRY_H
     19 #define S3D_GEOMETRY_H
     20 
     21 #include "s3d.h"
     22 #include "s3d_backend.h"
     23 #include <rsys/float3.h>
     24 #include <rsys/ref_count.h>
     25 
     26 enum geometry_type {
     27   GEOM_MESH,
     28   GEOM_INSTANCE,
     29   GEOM_SPHERE,
     30   GEOM_TYPES_COUNT__,
     31   GEOM_NONE = GEOM_TYPES_COUNT__
     32 };
     33 
     34 enum embree_attrib {
     35   EMBREE_ENABLE = BIT(0),
     36   EMBREE_FILTER_FUNCTION = BIT(1),
     37   EMBREE_INDICES = BIT(2),
     38   EMBREE_TRANSFORM = BIT(3),
     39   EMBREE_VERTICES = BIT(4),
     40   EMBREE_USER_GEOMETRY = BIT(5)
     41 };
     42 
     43 /* Backend geometry */
     44 struct geometry {
     45   unsigned name; /* Client side identifier */
     46   RTCGeometry rtc; /* Embree geometry */
     47   enum RTCBuildQuality rtc_build_quality; /* BVH build quality */
     48   unsigned rtc_id; /* Embree geometry identifier */
     49   unsigned scene_prim_id_offset; /* Offset from local to scene prim_id */
     50 
     51   int embree_outdated_mask; /* Combination of embree_attrib */
     52 
     53   char flip_surface; /* Is the geometry surface flipped? */
     54   char is_enabled; /* Is the geometry enabled? */
     55 
     56   enum geometry_type type;
     57   union {
     58     struct instance* instance;
     59     struct mesh* mesh;
     60     struct sphere* sphere;
     61   } data;
     62 
     63   struct s3d_device* dev;
     64   ref_T ref;
     65 };
     66 
     67 extern LOCAL_SYM res_T
     68 geometry_create
     69   (struct s3d_device* dev,
     70    struct geometry** geom);
     71 
     72 extern LOCAL_SYM void
     73 geometry_ref_get
     74   (struct geometry* geometry);
     75 
     76 extern LOCAL_SYM void
     77 geometry_ref_put
     78   (struct geometry* geometry);
     79 
     80 extern LOCAL_SYM void
     81 geometry_rtc_sphere_bounds
     82   (const struct RTCBoundsFunctionArguments* args);
     83 
     84 extern LOCAL_SYM void
     85 geometry_rtc_sphere_intersect
     86   (const struct RTCIntersectFunctionNArguments* args);
     87 
     88 #endif /* S3D_GEOMETRY_H */