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 3c5a447ef53fed504aa337041a56e4f5c1562d82
parent fe17633c4b475d27e98dff1b65af6c9155c44f2b
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Wed, 13 Nov 2019 12:32:54 +0100

Merge branch 'hotfix_0.6.2' into develop

Diffstat:
MREADME.md | 7++++++-
Msrc/s3d_scene_view.c | 5++---
Msrc/s3d_scene_view_c.h | 2+-
Msrc/test_s3d_scene_view.c | 12++++++++++--
4 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/README.md b/README.md @@ -116,9 +116,14 @@ with `<STAR3D_INSTALL_DIR>` the install directory of Star-3D and ## Release notes +### Version 0.6.2 + +- Fix an issue in `s3d_scene_view_compute_area`: the returned area was wrong + when the scene view was created with the `S3D_SAMPLE` flag. + ### Version 0.6.1 -- Fix an issue in `s3d_scene_view_sample`: the samples were not uniformaly +- Fix an issue in `s3d_scene_view_sample`: the samples were not uniformly distributed if the scene contained meshes and spheres. ### Version 0.6 diff --git a/src/s3d_scene_view.c b/src/s3d_scene_view.c @@ -1488,13 +1488,12 @@ s3d_scene_view_compute_area(struct s3d_scene_view* scnview, float* out_area) } if((scnview->mask & S3D_SAMPLE) != 0) { /* Retrieve the overall scene area from the scene cumulative distribution - * function. Note that the CDF stores the cumulative triangle area - * multiplied by 2; the real scene area is thus the CDF upper bound / 2 */ + * function */ size_t len = darray_fltui_size_get(&scnview->cdf); if(!len) { area = 0.f; } else { - area = darray_fltui_cdata_get(&scnview->cdf)[len - 1].flt * 0.5f; + area = darray_fltui_cdata_get(&scnview->cdf)[len - 1].flt; } } else { struct htable_geom_iterator it, end; diff --git a/src/s3d_scene_view_c.h b/src/s3d_scene_view_c.h @@ -74,7 +74,7 @@ struct s3d_scene_view { struct list_node node; /* Attachment point to the scene scene_views pool */ struct htable_geom cached_geoms; /* Cached shape geometries */ - struct darray_fltui cdf; /* Unormalized CDF */ + struct darray_fltui cdf; /* Unormalized cumulative of the primitive areas */ struct darray_nprims_cdf nprims_cdf; /* Map an instantiated scene to its scene view */ diff --git a/src/test_s3d_scene_view.c b/src/test_s3d_scene_view.c @@ -176,10 +176,18 @@ test_miscellaneous CHK(s3d_scene_view_get_mask(scnview, &mask) == RES_OK); CHK(mask == 0); CHK(s3d_scene_view_compute_volume(scnview, &V) == RES_OK); - CHK(s3d_scene_view_compute_volume(scnview, &A) == RES_OK); + CHK(s3d_scene_view_compute_area(scnview, &A) == RES_OK); CHK(s3d_scene_view_ref_put(scnview) == RES_OK); + CHK(eq_eps(A, 6.f, 1.e-6f)); + CHK(eq_eps(V, 1.f, 1.e-6f)); + + CHK(s3d_scene_view_create(scn, S3D_SAMPLE, &scnview) == RES_OK); + CHK(s3d_scene_view_compute_volume(scnview, &V) == RES_OK); + CHK(s3d_scene_view_compute_area(scnview, &A) == RES_OK); + CHK(s3d_scene_view_ref_put(scnview) == RES_OK); + CHK(eq_eps(A, 6.f, 1.e-6f)); + CHK(eq_eps(V, 1.f, 1.e-6f)); - printf("Cube volume = %g; Cube area = %g\n", V, A); CHK(s3d_scene_ref_put(scn) == RES_OK); }