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 5ff28db5e5f26b69e6d58f68a36461534ed93300
parent 5f7f9d1fd17f4c1bf0ce1ef5f012d7994a8842e4
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date:   Tue,  9 Apr 2024 17:57:45 +0200

Improve readability (try to)

Diffstat:
Msrc/sg3d_geometry.c | 36+++++++++++++++++++-----------------
1 file changed, 19 insertions(+), 17 deletions(-)

diff --git a/src/sg3d_geometry.c b/src/sg3d_geometry.c @@ -483,50 +483,52 @@ 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[unique_id].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[unique_id].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[unique_id].merge_conflict = 1; + trg_descriptions[trg_id].merge_conflict = 1; break; } } } - if(trg_descriptions[unique_id].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)); @@ -536,8 +538,8 @@ sg3d_geometry_add && 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,