commit 650d5b902d1b5e421495475ccfc3955b5b93b3cd
parent 4771b799d57415955ba4049ad706b307d7174a0d
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Thu, 2 Aug 2018 11:43:56 +0200
Fix side_id/side_flag confusion
Diffstat:
3 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/src/senc_internal_types.h b/src/senc_internal_types.h
@@ -84,6 +84,12 @@ typedef enclosure_id_t component_id_t;
#define COMPONENT_MAX__ ENCLOSURE_MAX__
#define COMPONENT_NULL__ ENCLOSURE_NULL__
+/* This one is used as flag */
+enum side_flag {
+ FLAG_FRONT = BIT(0),
+ FLAG_BACK = BIT(1)
+};
+
/* This one is used as an index to arrays */
enum side_id {
SIDE_FRONT = 0,
@@ -107,6 +113,11 @@ TRGSIDE_2_SIDE(side_id_t s) {
return (s & 1) ? SIDE_BACK : SIDE_FRONT;
}
+static FINLINE enum side_flag
+SEGSIDE_2_SIDEFLAG(side_id_t s) {
+ return (s & 1) ? FLAG_BACK : FLAG_FRONT;
+}
+
static FINLINE side_id_t
TRGIDxSIDE_2_TRGSIDE(trg_id_t t, enum side_id i) {
ASSERT((((size_t)t << 1) | (i == SIDE_BACK)) < SIDE_MAX__);
diff --git a/src/senc_scene_analyze.c b/src/senc_scene_analyze.c
@@ -280,9 +280,9 @@ extract_connex_components
#ifndef NDEBUG
{
trg_id_t tid = TRGSIDE_2_TRG(start_side_id);
- enum side_flag s = TRGSIDE_2_SIDE(start_side_id);
+ enum side_flag f = SEGSIDE_2_SIDEFLAG(start_side_id);
medium_id_t side_med
- = darray_triangle_in_data_get(&desc->scene->triangles_in)[tid].medium[s];
+ = darray_triangle_in_data_get(&desc->scene->triangles_in)[tid].medium[f];
ASSERT(side_med == m);
}
#endif
@@ -301,7 +301,7 @@ extract_connex_components
for(;;) { /* Process all sides of this component */
int i;
- enum side_flag crt_side_flag = TRGSIDE_2_SIDE(crt_side_id);
+ enum side_id s = TRGSIDE_2_SIDE(crt_side_id);
struct trgside* crt_side = trgsides + crt_side_id;
const trg_id_t crt_trg_id = TRGSIDE_2_TRG(crt_side_id);
const struct triangle_in* trg_in =
@@ -353,8 +353,8 @@ extract_connex_components
/* Record crt_side both as component and triangle level */
cc->side_count++;
trgsides[crt_side_id].list_id = FLAG_LIST_COMPONENT;
- ASSERT(trg_comp->component[crt_side_flag] == COMPONENT_NULL__);
- trg_comp->component[crt_side_flag] = cc->cc_id;
+ ASSERT(trg_comp->component[s] == COMPONENT_NULL__);
+ trg_comp->component[s] = cc->cc_id;
#ifndef NDEBUG
crt_side->member_of_cc = cc->cc_id;
#endif
diff --git a/src/senc_scene_analyze_c.h b/src/senc_scene_analyze_c.h
@@ -24,13 +24,6 @@
#include <rsys/hash_table.h>
#include <rsys/double3.h>
-
-/* This one is used as flag */
-enum side_flag {
- FLAG_FRONT = BIT(0),
- FLAG_BACK = BIT(1)
-};
-
enum list_id {
FLAG_NO_LIST = 0,
FLAG_LIST_SIDE_LIST = BIT(1),