commit c2ed0b6bbb27ddec8e19bd5b064caa1d541755de
parent 71fb54322bf795a082f6cb3a081894140d379c45
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Tue, 28 Jun 2016 15:31:13 +0200
Rename the box getter functions in the test utils
Diffstat:
6 files changed, 24 insertions(+), 22 deletions(-)
diff --git a/src/test_s2d_primitive.c b/src/test_s2d_primitive.c
@@ -69,10 +69,10 @@ main(int argc, char** argv)
vdata.usage = S2D_POSITION;
vdata.type = S2D_FLOAT2;
- vdata.get = box_get_position;
+ vdata.get = line_segments_get_position;
CHECK(s2d_line_segments_setup_indexed_vertices
- (shape, box_nsegs, box_get_ids, box_nverts, &vdata, 1, (void*)&box_desc),
- RES_OK);
+ (shape, box_nsegs, line_segments_get_ids, box_nverts, &vdata, 1,
+ (void*)&box_desc), RES_OK);
CHECK(s2d_scene_begin_session(scn, S2D_SAMPLE), RES_OK);
CHECK(s2d_scene_sample(scn, 0, 0, &prim, &s), RES_OK);
diff --git a/src/test_s2d_sample.c b/src/test_s2d_sample.c
@@ -101,10 +101,10 @@ main(int argc, char** argv)
vdata.usage = S2D_POSITION;
vdata.type = S2D_FLOAT2;
- vdata.get = box_get_position;
+ vdata.get = line_segments_get_position;
CHECK(s2d_line_segments_setup_indexed_vertices
- (shape, box_nsegs, box_get_ids, box_nverts, &vdata, 1, (void*)&box_desc),
- RES_OK);
+ (shape, box_nsegs, line_segments_get_ids, box_nverts, &vdata, 1,
+ (void*)&box_desc), RES_OK);
CHECK(s2d_scene_sample(scn, 0, 0, &prim, &s), RES_OK);
CHECK(S2D_PRIMITIVE_EQ(&prim, &S2D_PRIMITIVE_NULL), 1);
diff --git a/src/test_s2d_scene.c b/src/test_s2d_scene.c
@@ -115,10 +115,10 @@ main(int argc, char** argv)
attrib.type = S2D_FLOAT2;
attrib.usage = S2D_POSITION;
- attrib.get = box_get_position;
+ attrib.get = line_segments_get_position;
CHECK(s2d_line_segments_setup_indexed_vertices
- (shape, box_nsegs, box_get_ids, box_nverts, &attrib, 1, (void*)&box_desc),
- RES_OK);
+ (shape, box_nsegs, line_segments_get_ids, box_nverts, &attrib, 1,
+ (void*)&box_desc), RES_OK);
CHECK(s2d_scene_attach_shape(scn, shape), RES_OK);
CHECK(s2d_scene_begin_session(scn, S2D_TRACE), RES_OK);
diff --git a/src/test_s2d_shape.c b/src/test_s2d_shape.c
@@ -92,9 +92,10 @@ main(int argc, char** argv)
vdata[0].type = S2D_FLOAT2;
vdata[0].usage = S2D_POSITION;
- vdata[0].get = box_get_position;
+ vdata[0].get = line_segments_get_position;
#define SETUP s2d_line_segments_setup_indexed_vertices
+ #define box_get_ids line_segments_get_ids
CHECK(SETUP(NULL, 0, NULL, 0, NULL, 0, data), RES_BAD_ARG);
CHECK(SETUP(shape, 0, NULL, 0, NULL, 0, data), RES_BAD_ARG);
CHECK(SETUP(NULL, nsegs, NULL, 0, NULL, 0, data), RES_BAD_ARG);
@@ -168,8 +169,9 @@ main(int argc, char** argv)
vdata[0].get = S2D_KEEP;
CHECK(SETUP(shape, nsegs, box_get_ids, nverts, vdata, 1, data), RES_OK);
- vdata[0].get = box_get_position;
+ vdata[0].get = line_segments_get_position;
CHECK(SETUP(shape, nsegs, box_get_ids, nverts, vdata, 1, data), RES_OK);
+ #undef box_get_ids
#undef SETUP
CHECK(s2d_line_segments_get_vertices_count(NULL, NULL), RES_BAD_ARG);
@@ -203,7 +205,7 @@ main(int argc, char** argv)
FOR_EACH(id, 0, nverts) {
float pos[2];
- box_get_position(id, pos, data);
+ line_segments_get_position(id, pos, data);
CHECK(GET_ATTR(shape, id, S2D_POSITION, &attr), RES_OK);
CHECK(attr.type, S2D_FLOAT2);
CHECK(attr.usage, S2D_POSITION);
@@ -221,7 +223,7 @@ main(int argc, char** argv)
FOR_EACH(id, 0, nsegs) {
unsigned indices[2];
- box_get_ids(id, indices, data);
+ line_segments_get_ids(id, indices, data);
CHECK(s2d_line_segments_get_segment_indices(shape, id, ids), RES_OK);
CHECK(ids[0], indices[0]);
CHECK(ids[1], indices[1]);
diff --git a/src/test_s2d_trace_ray.c b/src/test_s2d_trace_ray.c
@@ -52,10 +52,10 @@ main(int argc, char** argv)
vdata.type = S2D_FLOAT2;
vdata.usage = S2D_POSITION;
- vdata.get = box_get_position;
+ vdata.get = line_segments_get_position;
CHECK(s2d_line_segments_setup_indexed_vertices
- (shape, box_nsegs, box_get_ids, box_nverts, &vdata, 1, (void*)&box_desc),
- RES_OK);
+ (shape, box_nsegs, line_segments_get_ids, box_nverts, &vdata, 1,
+ (void*)&box_desc), RES_OK);
CHECK(s2d_scene_attach_shape(scn, shape), RES_OK);
diff --git a/src/test_s2d_utils.h b/src/test_s2d_utils.h
@@ -32,7 +32,7 @@
#include <rsys/mem_allocator.h>
#include <stdio.h>
-struct box_desc {
+struct line_segments_desc {
const float* vertices;
const unsigned* indices;
};
@@ -56,23 +56,23 @@ const unsigned box_ids[] = {
};
const unsigned box_nsegs = sizeof(box_ids)/sizeof(unsigned[2]);
-static const struct box_desc box_desc = { box_verts, box_ids };
+static const struct line_segments_desc box_desc = { box_verts, box_ids };
static INLINE void
-box_get_ids(const unsigned isegment, unsigned ids[2], void* data)
+line_segments_get_ids(const unsigned isegment, unsigned ids[2], void* data)
{
const unsigned id = isegment * 2;
- const struct box_desc* desc = data;
+ const struct line_segments_desc* desc = data;
NCHECK(desc, NULL);
ids[0] = desc->indices[id + 0];
ids[1] = desc->indices[id + 1];
}
static INLINE void
-box_get_position(const unsigned ivert, float position[2], void* data)
+line_segments_get_position(const unsigned ivert, float position[2], void* data)
{
const unsigned id = ivert * 2;
- const struct box_desc* desc = data;
+ const struct line_segments_desc* desc = data;
NCHECK(desc, NULL);
position[0] = desc->vertices[id + 0];
position[1] = desc->vertices[id + 1];