star-geometry-3d

Clean and decorate 3D geometries
git clone git://git.meso-star.fr/star-geometry-3d.git
Log | Files | Refs | README | LICENSE

commit 4a8529893889a5248f3fa4d8cb2fff5785620753
parent c58035b877b13930a9e2cb8f46d9e06e1f202958
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date:   Wed, 10 Apr 2024 09:49:38 +0200

Merge branch 'release_0.1.3'

Diffstat:
MREADME.md | 5+++++
Mcmake/CMakeLists.txt | 2+-
Msrc/sg3d_geometry.c | 41++++++++++++++++++++++-------------------
Msrc/test_sg3d_utils.h | 2++
Msrc/test_sg3d_utils2.h | 2+-
5 files changed, 31 insertions(+), 21 deletions(-)

diff --git a/README.md b/README.md @@ -23,6 +23,11 @@ variable the install directories of its dependencies. ## Release notes +### Version 0.1.3 + +- BugFix: when property conflicts where found, a wrong triangle was flaged. + As a consequence, geometry dumps of conflicting geometries where wrong. + ### Version 0.1.2 - Fix OBJ dump. diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -62,7 +62,7 @@ endif() ################################################################################ set(VERSION_MAJOR 0) set(VERSION_MINOR 1) -set(VERSION_PATCH 2) +set(VERSION_PATCH 3) set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) set(SG3D_FILES_SRC diff --git a/src/sg3d_geometry.c b/src/sg3d_geometry.c @@ -483,65 +483,68 @@ sg3d_geometry_add p_trg = htable_trg_find(&geom->unique_triangles_ids, &trg_key); if(p_trg) { /* Duplicate triangle. Need to check duplicate validity */ + trg_id_t trg_id = *p_trg; struct vrtx_id3 utrg_key; - int ureversed = trg_make_key(&utrg_key, trg[*p_trg].vertex_ids); + int ureversed = trg_make_key(&utrg_key, trg[trg_id].vertex_ids); int same = (reversed == ureversed); int already_conflict; ASSERT(trg_key_eq(&trg_key, &utrg_key)); - unique_id = *p_trg; - ERR(geometry_enlarge_trg_descriptions(geom, 1 + unique_id)); + unique_id = trg_id; + ERR(geometry_enlarge_trg_descriptions(geom, 1 + trg_id)); trg_descriptions = darray_trg_descriptions_data_get(&geom->trg_descriptions); if(!same) SWAP(prop_id_t, tmp.properties[SG3D_FRONT], tmp.properties[SG3D_BACK]); - already_conflict = trg_descriptions[nt].merge_conflict; + already_conflict = trg_descriptions[trg_id].merge_conflict; if(mrg_trg) { /* Let the client app rule. */ - ERR(mrg_trg(unique_id, nt, !same, trg[*p_trg].properties, - tmp.properties, ctx, &trg_descriptions[nt].merge_conflict)); + ERR(mrg_trg(trg_id, nt, !same, trg[trg_id].properties, + tmp.properties, ctx, &trg_descriptions[trg_id].merge_conflict)); } else { FOR_EACH(j, 0, SG3D_PROP_TYPES_COUNT__) { - if(!sg3d_compatible_property(trg[*p_trg].properties[j], + if(!sg3d_compatible_property(trg[trg_id].properties[j], tmp.properties[j])) { - trg_descriptions[nt].merge_conflict = 1; + trg_descriptions[trg_id].merge_conflict = 1; break; } } } - if(trg_descriptions[nt].merge_conflict && !already_conflict) + if(trg_descriptions[trg_id].merge_conflict && !already_conflict) geom->merge_conflict_count++; /* Replace SG3D_UNSPECIFIED_PROPERTY properties */ FOR_EACH(j, 0, SG3D_PROP_TYPES_COUNT__) { - if(trg[*p_trg].properties[j] == SG3D_UNSPECIFIED_PROPERTY + if(trg[trg_id].properties[j] == SG3D_UNSPECIFIED_PROPERTY && tmp.properties[j] != SG3D_UNSPECIFIED_PROPERTY) { - trg[*p_trg].properties[j] = tmp.properties[j]; + trg[trg_id].properties[j] = tmp.properties[j]; if(j == SG3D_FRONT || j == SG3D_BACK) geom->sides_with_defined_medium_count++; } } } else { /* New triangle */ - ASSERT(nutris + n_new_utris <= TRG_MAX__); - unique_id = (trg_id_t)(nutris + n_new_utris); + trg_id_t new_id = (trg_id_t)(nutris + n_new_utris); + ASSERT(new_id <= TRG_MAX__); + unique_id = new_id; tmp.user_id = geom->triangle_count_including_duplicates + nt; - if(add_trg) ERR(add_trg(unique_id, nt, ctx)); - ERR(geometry_enlarge_trg_descriptions(geom, 1 + unique_id)); + if(add_trg) ERR(add_trg(new_id, nt, ctx)); + ERR(geometry_enlarge_trg_descriptions(geom, 1 + new_id)); trg_descriptions = darray_trg_descriptions_data_get(&geom->trg_descriptions); ERR(darray_triangle_push_back(&geom->unique_triangles, &tmp)); + trg = darray_triangle_data_get(&geom->unique_triangles); FOR_EACH(j, 0, SG3D_PROP_TYPES_COUNT__) { if((j == SG3D_FRONT || j == SG3D_BACK) && tmp.properties[j] != SG3D_UNSPECIFIED_PROPERTY) geom->sides_with_defined_medium_count++; } - ASSERT(unique_id == htable_trg_size_get(&geom->unique_triangles_ids)); - ERR(htable_trg_set(&geom->unique_triangles_ids, &trg_key, &unique_id)); + ASSERT(new_id == htable_trg_size_get(&geom->unique_triangles_ids)); + ERR(htable_trg_set(&geom->unique_triangles_ids, &trg_key, &new_id)); n_new_utris++; } ERR(geometry_register_triangle(geom, &tmp, unique_id, geom->set_id, - trg_descriptions[nt].properties_conflict)); - if(trg_descriptions[nt].properties_conflict) + trg_descriptions[unique_id].properties_conflict)); + if(trg_descriptions[unique_id].properties_conflict) geom->merge_conflict_count++; } diff --git a/src/test_sg3d_utils.h b/src/test_sg3d_utils.h @@ -16,6 +16,8 @@ #ifndef TEST_SG3D_UTILS_H #define TEST_SG3D_UTILS_H +#include <star/sg3d.h> + #include <rsys/mem_allocator.h> #include <rsys/double3.h> diff --git a/src/test_sg3d_utils2.h b/src/test_sg3d_utils2.h @@ -16,7 +16,7 @@ #ifndef TEST_SG3D_UTILS2_H #define TEST_SG3D_UTILS2_H -#include "test_sg3d_utils.h" +#include <star/sg3d.h> #include <rsys/double3.h> #include <star/s3dut.h>