commit bee5ecfc7a03f3a4016c2ac4558ce87686b39e9e
parent c2ab9ef13240c53f7a15f0f009b004770a026a4b
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Mon, 10 Oct 2016 10:45:49 +0200
Clean some temporary code; to help replace it when final
Diffstat:
4 files changed, 19 insertions(+), 30 deletions(-)
diff --git a/src/ssol_c.h b/src/ssol_c.h
@@ -61,5 +61,22 @@ hit_filter_function
#define RECEIVER_ID_MASK 0x7FFFFFFF
#define BACK_FLAG 0x80000000
+#include "ssol_instance_c.h"
+static FINLINE res_T
+get_receiver_id(struct ssol_instance* instance, const int front_face, uint32_t* id) {
+ struct str* rec;
+
+ if (!instance || !id)
+ return RES_BAD_ARG;
+ rec = front_face ? &instance->receiver_front : &instance->receiver_back;
+ if (str_is_empty(rec))
+ return RES_BAD_ARG;
+
+ S3D(shape_get_id(instance->shape_rt, id));
+ ASSERT((*id & RECEIVER_ID_MASK) == *id);
+ *id |= (front_face ? FRONT_FLAG : BACK_FLAG);
+ return RES_OK;
+}
+
#endif /* SSOL_C_H */
diff --git a/src/ssol_scene.c b/src/ssol_scene.c
@@ -342,7 +342,6 @@ hit_filter_function
struct ssol_instance* inst;
const struct ssol_shape* shape;
const struct str* receiver_name;
- uint32_t receiver_id;
struct realisation* rs = realisation;
struct segment* seg;
@@ -408,27 +407,22 @@ hit_filter_function
if(seg->hit_front) {
seg->hit_material = inst->object->mtl_front;
receiver_name = &inst->receiver_front;
- receiver_id = FRONT_FLAG;
} else {
d3_muld(seg->hit_normal, seg->hit_normal, -1);
seg->hit_material = inst->object->mtl_back;
receiver_name = &inst->receiver_back;
- receiver_id = BACK_FLAG;
}
/* Check if the hit surface is a receiver that registers hit data */
/* impacts on receivers before sampled surfaces are not registered */
if (!seg->sun_segment && !str_is_empty(receiver_name)) {
struct receiver_record candidate;
- uint32_t id;
f3_set_d3(candidate.dir, seg->dir);
candidate.hit_distance = (float)seg->hit_distance;
f3_set_d3(candidate.hit_normal, seg->hit_normal);
f3_set_d3(candidate.hit_pos, seg->hit_pos);
candidate.instance = inst;
- S3D(shape_get_id(inst->shape_rt, &id));
- ASSERT((id & RECEIVER_ID_MASK) == id);
- candidate.receiver_id = receiver_id | id;
+ SSOL(get_receiver_id(inst, seg->hit_front, &candidate.receiver_id));
f2_set(candidate.uv, seg->hit.uv);
darray_receiver_record_push_back(
&rs->data.receiver_record_candidates, &candidate);
@@ -441,4 +435,3 @@ hit_filter_function
seg->hit_instance = inst;
return 0;
}
-
diff --git a/src/test_ssol_utils.c b/src/test_ssol_utils.c
@@ -16,6 +16,7 @@
#define _POSIX_C_SOURCE 200809L /* snprintf support */
#include "test_ssol_utils.h"
+#include "ssol_c.h"
#include <rsys/math.h>
@@ -23,24 +24,6 @@
#include <stdio.h>
#include <string.h>
-/* hack until the needed API comes from a merge */
-#include "ssol_instance_c.h"
-#include "ssol_c.h"
-res_T
-get_receiver_id (struct ssol_instance* instance, const int front_face, uint32_t* id) {
- struct str* rec;
-
- if (!instance || !id)
- return RES_BAD_ARG;
- rec = front_face ? &instance->receiver_front : &instance->receiver_back;
- if(str_is_empty(rec))
- return RES_BAD_ARG;
-
- S3D(shape_get_id(instance->shape_rt, id));
- *id |= (front_face ? FRONT_FLAG : BACK_FLAG);
- return RES_OK;
-}
-
res_T
pp_sum
(FILE* f,
diff --git a/src/test_ssol_utils.h b/src/test_ssol_utils.h
@@ -46,8 +46,4 @@ pp_sum
double* mean,
double* std);
-/* hack until the needed API comes from a merge */
-struct ssol_instance;
-res_T get_receiver_id(struct ssol_instance* instance, const int front_face, uint32_t* id);
-
#endif /* TEST_SSOL_UTILS_H */