commit 1807e4be19d4adb1bd24c1fedb86e84801aefc24
parent 2d32ffff33b6d235f1db514771cdea13a19f07d1
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Thu, 14 May 2020 10:39:43 +0200
Bugfix: enclosures with Nz=0 everywhere are broken
Diffstat:
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/senc3d_scene_analyze.c b/src/senc3d_scene_analyze.c
@@ -248,7 +248,7 @@ extract_connex_components
double max_nz;
side_id_t max_nz_side_id;
const side_id_t last_side = media_use->last;
- int component_canceled = 0, max_z_is_2sided = 0;
+ int component_canceled = 0, max_z_is_2sided = 0, fst_nz = 1;
res_T tmp_res = RES_OK;
ATOMIC id;
@@ -428,6 +428,7 @@ extract_connex_components
/* Compute component area and volume, and record information on the
* max_z side of the component to help find out if the component is
* inner or outer */
+ fst_nz = 1;
max_nz = 0;
max_nz_side_id = SIDE_NULL__;
FOR_EACH(ii, 0, sz) {
@@ -472,19 +473,21 @@ extract_connex_components
ASSERT(trg_comp->component[side] != COMPONENT_NULL__); (void)side;
if(trg_tmp->max_z == max_z) {
int i;
- /* candidate to define the max_z normal */
+ /* Candidate to define max_nz (triangle using max_z_vrtx) */
FOR_EACH(i, 0, 3) {
if(cc->max_z_vrtx_id == trg_in->vertice_id[i]) {
- if(fabs(normal[2]) > fabs(max_nz)) {
+ if(fst_nz || fabs(normal[2]) > fabs(max_nz)) {
max_nz_side_id = s_id;
max_nz = normal[2];
max_z_is_2sided = is_2sided;
- break;
+ fst_nz = 0;
}
+ break;
}
}
}
}
+ ASSERT(!fst_nz);
/* Determine if this component can be an inner part inside another
* component (creating a hole) as only these components will need
* to search for their possible outer component when grouping