commit bb7592f99259806ef5d69045f43538a2a5eb2456
parent 3e81de4b5b8021567606bafc289f8235ef52486f
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Wed, 13 Nov 2019 12:26:28 +0100
Merge branch 'hotfix_0.6.2'
Diffstat:
5 files changed, 29 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/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
@@ -58,7 +58,7 @@ endif()
################################################################################
set(VERSION_MAJOR 0)
set(VERSION_MINOR 6)
-set(VERSION_PATCH 1)
+set(VERSION_PATCH 2)
set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
set(S3D_FILES_SRC
diff --git a/src/s3d_scene_view.c b/src/s3d_scene_view.c
@@ -1577,13 +1577,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
@@ -131,6 +131,8 @@ test_miscellaneous
{
struct s3d_scene* scn;
struct s3d_scene_view* scnview;
+ float V;
+ float A;
int mask;
CHK(s3d_scene_create(dev, &scn) == RES_OK);
@@ -142,7 +144,6 @@ test_miscellaneous
CHK(s3d_scene_view_create(NULL, S3D_SAMPLE, NULL) == RES_BAD_ARG);
CHK(s3d_scene_view_create(scn, S3D_SAMPLE, NULL) == RES_BAD_ARG);
CHK(s3d_scene_view_create(NULL, 0, &scnview) == RES_BAD_ARG);
- CHK(s3d_scene_view_create(scn, 0, &scnview) == RES_BAD_ARG);
CHK(s3d_scene_view_create(NULL, S3D_SAMPLE, &scnview) == RES_BAD_ARG);
CHK(s3d_scene_view_create(scn, S3D_SAMPLE, &scnview) == RES_OK);
@@ -170,6 +171,23 @@ test_miscellaneous
CHK((mask & S3D_GET_PRIMITIVE) == S3D_GET_PRIMITIVE);
CHK(s3d_scene_view_ref_put(scnview) == RES_OK);
+ CHK(s3d_scene_detach_shape(scn, plane) == RES_OK);
+ CHK(s3d_scene_view_create(scn, S3D_TRACE, &scnview) == RES_OK);
+ CHK(s3d_scene_view_get_mask(scnview, &mask) == RES_OK);
+ CHK(mask == S3D_TRACE);
+ 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));
+
+ 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));
+
CHK(s3d_scene_ref_put(scn) == RES_OK);
}