star-3d

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

commit 3f523f7f198cc870aec21c2d5e252d2b5a249180
parent 695c9179ef4c54fe26b7690c373dc21f981e3698
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Tue,  1 Oct 2019 09:54:00 +0200

Rename the rt_accel_struct_conf struct and constants

Rename the data structures and constants used to configure the
acceleration structure.

Diffstat:
Msrc/s3d.h | 53++++++++++++++++++++++++++---------------------------
Msrc/s3d_scene_view.c | 56++++++++++++++++++++++++++++----------------------------
2 files changed, 54 insertions(+), 55 deletions(-)

diff --git a/src/s3d.h b/src/s3d.h @@ -144,7 +144,7 @@ static const struct s3d_vertex_data S3D_VERTEX_DATA_NULL = S3D_VERTEX_DATA_NULL_ /* Intersection point */ struct s3d_hit { struct s3d_primitive prim; /* Intersected primitive */ - float normal[3]; /* Unnormalized geometry normal */ + float normal[3]; /* Un-normalized geometry normal */ float uv[2]; /* Barycentric coordinates of the hit onto `prim' */ float distance; /* Hit distance from the ray origin */ }; @@ -169,41 +169,40 @@ enum s3d_scene_view_flag { * intersects a shape or not */ #define S3D_HIT_NONE(Hit) ((Hit)->distance >= FLT_MAX) -/* Quality of the partitioning data structure used tu accelerate the - * ray-tracing procedure. The lowest the structure quality is, the fastest it - * is built. On the counterpart, a weak structure quality means that the - * partitioning of the geometry is sub-optimal, leading to lower ray-tracing - * performances. */ -enum s3d_rt_accel_struct_quality { - S3D_RT_ACCEL_STRUCT_QUALITY_LOW, - S3D_RT_ACCEL_STRUCT_QUALITY_MEDIUM, - S3D_RT_ACCEL_STRUCT_QUALITY_HIGH +/* Quality of the partitioning data structure used to accelerate geometry + * queries. The lowest the structure quality is, the fastest it is built. On + * the counterpart, a weak structure quality means that the partitioning of the + * geometry is sub-optimal, leading to lower geometry query performances. */ +enum s3d_accel_struct_quality { + S3D_ACCEL_STRUCT_QUALITY_LOW, + S3D_ACCEL_STRUCT_QUALITY_MEDIUM, + S3D_ACCEL_STRUCT_QUALITY_HIGH }; /* Define the properties of the partitioning data structure used to accelerate - * the ray-tracing procedure. */ -enum s3d_rt_accel_struct_flag { + * geometry queries */ +enum s3d_accel_struct_flag { /* Avoid optimisations that reduce arithmetic accuracy */ - S3D_RT_ACCEL_STRUCT_FLAG_ROBUST = BIT(0), + S3D_ACCEL_STRUCT_FLAG_ROBUST = BIT(0), /* Improve the building performances of the acceleration structure for * dynamic scenes */ - S3D_RT_ACCEL_STRUCT_FLAG_DYNAMIC = BIT(1), + S3D_ACCEL_STRUCT_FLAG_DYNAMIC = BIT(1), /* Reduce the memory consumption of the acceleration structure */ - S3D_RT_ACCEL_STRUCT_FLAG_COMPACT = BIT(2) + S3D_ACCEL_STRUCT_FLAG_COMPACT = BIT(2) }; -/* Configuration of the acceleration data structure used to accelerate the - * ray-tracing procedure */ -struct s3d_rt_accel_struct_conf { - enum s3d_rt_accel_struct_quality quality; - int mask; /* combination of s3d_rt_accel_struct_flag */ +/* Configuration of the partitioning structure used to accelerate geometry + * queries */ +struct s3d_accel_struct_conf { + enum s3d_accel_struct_quality quality; + int mask; /* combination of s3d_accel_struct_flag */ }; -#define S3D_RT_ACCEL_STRUCT_CONF_DEFAULT__ { \ - S3D_RT_ACCEL_STRUCT_QUALITY_MEDIUM, \ - S3D_RT_ACCEL_STRUCT_FLAG_ROBUST \ +#define S3D_ACCEL_STRUCT_CONF_DEFAULT__ { \ + S3D_ACCEL_STRUCT_QUALITY_MEDIUM, \ + S3D_ACCEL_STRUCT_FLAG_ROBUST \ } -static const struct s3d_rt_accel_struct_conf S3D_RT_ACCEL_STRUCT_CONF_DEFAULT = - S3D_RT_ACCEL_STRUCT_CONF_DEFAULT__; +static const struct s3d_accel_struct_conf S3D_ACCEL_STRUCT_CONF_DEFAULT = + S3D_ACCEL_STRUCT_CONF_DEFAULT__; /* Filter function data type. One can define such function to discard * intersections along a ray with respect to user defined criteria, e.g.: @@ -323,8 +322,8 @@ s3d_scene_view_create2 (struct s3d_scene* scn, const int mask, /* Combination of s3d_scene_view_flag */ /* Ignored if (mask & S3D_TRACE) == 0 - * NULL <=> use S3D_RT_ACCEL_STRUCT_CONF_DEFAULT */ - const struct s3d_rt_accel_struct_conf* cfg, + * NULL <=> use S3D_ACCEL_STRUCT_CONF_DEFAULT */ + const struct s3d_accel_struct_conf* cfg, struct s3d_scene_view** scnview); S3D_API res_T diff --git a/src/s3d_scene_view.c b/src/s3d_scene_view.c @@ -233,18 +233,18 @@ hit_setup } static INLINE enum RTCBuildQuality -rt_accel_struct_quality_to_rtc_build_quality - (enum s3d_rt_accel_struct_quality quality) +accel_struct_quality_to_rtc_build_quality + (enum s3d_accel_struct_quality quality) { enum RTCBuildQuality rtc_quality = RTC_BUILD_QUALITY_MEDIUM; switch(quality) { - case S3D_RT_ACCEL_STRUCT_QUALITY_LOW: + case S3D_ACCEL_STRUCT_QUALITY_LOW: rtc_quality = RTC_BUILD_QUALITY_LOW; break; - case S3D_RT_ACCEL_STRUCT_QUALITY_MEDIUM: + case S3D_ACCEL_STRUCT_QUALITY_MEDIUM: rtc_quality = RTC_BUILD_QUALITY_MEDIUM; break; - case S3D_RT_ACCEL_STRUCT_QUALITY_HIGH: + case S3D_ACCEL_STRUCT_QUALITY_HIGH: rtc_quality = RTC_BUILD_QUALITY_HIGH; break; default: FATAL("Unreachable code\n"); break; @@ -253,14 +253,14 @@ rt_accel_struct_quality_to_rtc_build_quality } static INLINE int -rt_accel_struct_mask_to_rtc_scene_flags(const int mask) +accel_struct_mask_to_rtc_scene_flags(const int mask) { int rtc_scene_flags = 0; - if(mask & S3D_RT_ACCEL_STRUCT_FLAG_ROBUST) + if(mask & S3D_ACCEL_STRUCT_FLAG_ROBUST) rtc_scene_flags |= RTC_SCENE_FLAG_ROBUST; - if(mask & S3D_RT_ACCEL_STRUCT_FLAG_DYNAMIC) + if(mask & S3D_ACCEL_STRUCT_FLAG_DYNAMIC) rtc_scene_flags |= RTC_SCENE_FLAG_DYNAMIC; - if(mask & S3D_RT_ACCEL_STRUCT_FLAG_COMPACT) + if(mask & S3D_ACCEL_STRUCT_FLAG_COMPACT) rtc_scene_flags |= RTC_SCENE_FLAG_COMPACT; return rtc_scene_flags; } @@ -269,13 +269,13 @@ static res_T embree_geometry_register (struct s3d_scene_view* scnview, struct geometry* geom, - const struct s3d_rt_accel_struct_conf* rt_accel_struct_conf) + const struct s3d_accel_struct_conf* accel_struct_conf) { enum RTCBuildQuality rtc_build_quality = RTC_BUILD_QUALITY_MEDIUM; - ASSERT(scnview && geom && rt_accel_struct_conf); + ASSERT(scnview && geom && accel_struct_conf); - rtc_build_quality = rt_accel_struct_quality_to_rtc_build_quality - (rt_accel_struct_conf->quality); + rtc_build_quality = accel_struct_quality_to_rtc_build_quality + (accel_struct_conf->quality); /* Create the Embree geometry if it is not valid */ if(geom->rtc != NULL) { @@ -444,7 +444,7 @@ embree_geometry_setup_transform static INLINE res_T scene_view_setup_embree (struct s3d_scene_view* scnview, - const struct s3d_rt_accel_struct_conf* rt_accel_struct_conf) + const struct s3d_accel_struct_conf* accel_struct_conf) { struct htable_geom_iterator it, end; int rtc_outdated = 0; @@ -453,10 +453,10 @@ scene_view_setup_embree res_T res = RES_OK; ASSERT(scnview); - rtc_scn_flags = rt_accel_struct_mask_to_rtc_scene_flags - (rt_accel_struct_conf->mask); - rtc_scn_build_quality = rt_accel_struct_quality_to_rtc_build_quality - (rt_accel_struct_conf->quality); + rtc_scn_flags = accel_struct_mask_to_rtc_scene_flags + (accel_struct_conf->mask); + rtc_scn_build_quality = accel_struct_quality_to_rtc_build_quality + (accel_struct_conf->quality); /* The rtc_scn could be already allocated since the scene views are cached */ if(!scnview->rtc_scn) { @@ -497,7 +497,7 @@ scene_view_setup_embree rtc_outdated = 1; /* Register the embree geometry */ - res = embree_geometry_register(scnview, geom, rt_accel_struct_conf); + res = embree_geometry_register(scnview, geom, accel_struct_conf); if(res != RES_OK) goto error; /* Flush the embree geometry states */ @@ -1015,12 +1015,12 @@ static res_T scene_view_sync (struct s3d_scene_view* scnview, const int mask, - const struct s3d_rt_accel_struct_conf* rt_accel_struct_conf) + const struct s3d_accel_struct_conf* accel_struct_conf) { struct htable_shape_iterator it, end; res_T res = RES_OK; - ASSERT(scnview && rt_accel_struct_conf); + ASSERT(scnview && accel_struct_conf); ASSERT((mask & (S3D_TRACE|S3D_SAMPLE|S3D_GET_PRIMITIVE)) != 0); /* Commit the scene shape to the scnview */ @@ -1050,7 +1050,7 @@ scene_view_sync /* Setup the scene for the S3D_TRACE scnview */ if((mask & S3D_TRACE) != 0) { - res = scene_view_setup_embree(scnview, rt_accel_struct_conf); + res = scene_view_setup_embree(scnview, accel_struct_conf); if(res != RES_OK) goto error; } /* Setup the scene for the S3D_SAMPLE scnview */ @@ -1185,18 +1185,18 @@ s3d_scene_view_create struct s3d_scene_view** out_scnview) { return s3d_scene_view_create2 - (scn, mask, &S3D_RT_ACCEL_STRUCT_CONF_DEFAULT, out_scnview); + (scn, mask, &S3D_ACCEL_STRUCT_CONF_DEFAULT, out_scnview); } res_T s3d_scene_view_create2 (struct s3d_scene* scn, const int mask, - const struct s3d_rt_accel_struct_conf* cfg, + const struct s3d_accel_struct_conf* cfg, struct s3d_scene_view** out_scnview) { struct s3d_scene_view* scnview = NULL; - const struct s3d_rt_accel_struct_conf* rt_accel_struct_conf = cfg; + const struct s3d_accel_struct_conf* accel_struct_conf = cfg; res_T res = RES_OK; if(!scn || !out_scnview) { @@ -1204,8 +1204,8 @@ s3d_scene_view_create2 goto error; } - if(!rt_accel_struct_conf && (mask & S3D_TRACE)) { - rt_accel_struct_conf = &S3D_RT_ACCEL_STRUCT_CONF_DEFAULT; + if(!accel_struct_conf && (mask & S3D_TRACE)) { + accel_struct_conf = &S3D_ACCEL_STRUCT_CONF_DEFAULT; } if(!(mask & S3D_TRACE) @@ -1219,7 +1219,7 @@ s3d_scene_view_create2 res = scene_view_create(scn, &scnview); if(res != RES_OK) goto error; - res = scene_view_sync(scnview, mask, rt_accel_struct_conf); + res = scene_view_sync(scnview, mask, accel_struct_conf); if(res != RES_OK) goto error; exit: