commit f18fbdf1a4ec85fb597d58ac7a13601f31bb4e2a
parent 7d26600da727859c243288f93b9096020c09b710
Author: vaplv <vaplv@free.fr>
Date: Fri, 24 Nov 2017 09:48:47 +0100
Fix deprecations introduced by RSys 0.6
Diffstat:
3 files changed, 112 insertions(+), 116 deletions(-)
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
@@ -26,7 +26,7 @@ set(POLYGON_SOURCE_DIR ${PROJECT_SOURCE_DIR}/../src)
# Dependencies
################################################################################
find_package(RCMake REQUIRED)
-find_package(RSys 0.2 REQUIRED)
+find_package(RSys 0.6 REQUIRED)
include_directories(${RSys_INCLUDE_DIR})
set(CMAKE_MODULE_PATH ${RCMAKE_SOURCE_DIR})
diff --git a/src/test_polygon.c b/src/test_polygon.c
@@ -36,40 +36,40 @@ check_triangulation
ASSERT(poly && indices && nindices && nedges_contour);
contour = mem_calloc(nedges_contour, sizeof(char));
- NCHECK(contour, NULL);
+ CHK(contour != NULL);
memset(contour, 0, nedges_contour * sizeof(char));
- CHECK(nindices % 3, 0);
+ CHK(nindices % 3 == 0);
FOR_EACH(i, 0, nindices/3) {
const uint32_t* tri = indices + (i*3);
float e0[3], e1[3], N[3];
float v0[3], v1[3], v2[3];
float len;
- CHECK(polygon_vertex_get(poly, tri[0], v0), RES_OK);
- CHECK(polygon_vertex_get(poly, tri[1], v1), RES_OK);
- CHECK(polygon_vertex_get(poly, tri[2], v2), RES_OK);
+ CHK(polygon_vertex_get(poly, tri[0], v0) == RES_OK);
+ CHK(polygon_vertex_get(poly, tri[1], v1) == RES_OK);
+ CHK(polygon_vertex_get(poly, tri[2], v2) == RES_OK);
/* Compute the triangle area and add it to the overall polygon area */
f3_sub(e0, v1, v0);
f3_sub(e1, v2, v0);
len = f3_normalize(N, f3_cross(N, e0, e1));
- CHECK(eq_eps(len, 0.f, 1.e-6f), 0);
+ CHK(eq_eps(len, 0.f, 1.e-6f) == 0);
area += len * 0.5f;
/* Update the contour edge flag */
if(tri[1] == (tri[0] + 1) % nedges_contour) {
- CHECK(contour[tri[0]], 0);
+ CHK(contour[tri[0]] == 0);
contour[tri[0]] = 1;
}
if(tri[2] == (tri[1] + 1) % nedges_contour) {
- CHECK(contour[tri[1]], 0);
+ CHK(contour[tri[1]] == 0);
contour[tri[1]] = 1;
}
if(tri[0] == (tri[2] + 1) % nedges_contour) {
- CHECK(contour[tri[2]], 0);
+ CHK(contour[tri[2]] == 0);
contour[tri[2]] = 1;
}
}
FOR_EACH(i, 0, nedges_contour) /* All the contour edges may be found */
- CHECK(contour[i], 1);
+ CHK(contour[i] == 1);
mem_rm(contour);
return area;
@@ -109,138 +109,134 @@ main(int argc, char** argv)
mem_init_proxy_allocator(&allocator_proxy, &mem_default_allocator);
- CHECK(polygon_create(NULL, NULL), RES_BAD_ARG);
- CHECK(polygon_create(&allocator_proxy, NULL), RES_BAD_ARG);
- CHECK(polygon_create(NULL, &poly), RES_OK);
+ CHK(polygon_create(NULL, NULL) == RES_BAD_ARG);
+ CHK(polygon_create(&allocator_proxy, NULL) == RES_BAD_ARG);
+ CHK(polygon_create(NULL, &poly) == RES_OK);
- CHECK(polygon_ref_get(NULL), RES_BAD_ARG);
- CHECK(polygon_ref_get(poly), RES_OK);
- CHECK(polygon_ref_put(NULL), RES_BAD_ARG);
- CHECK(polygon_ref_put(poly), RES_OK);
- CHECK(polygon_ref_put(poly), RES_OK);
+ CHK(polygon_ref_get(NULL) == RES_BAD_ARG);
+ CHK(polygon_ref_get(poly) == RES_OK);
+ CHK(polygon_ref_put(NULL) == RES_BAD_ARG);
+ CHK(polygon_ref_put(poly) == RES_OK);
+ CHK(polygon_ref_put(poly) == RES_OK);
- CHECK(polygon_create(&allocator_proxy, &poly), RES_OK);
+ CHK(polygon_create(&allocator_proxy, &poly) == RES_OK);
- CHECK(polygon_vertices_count_get(NULL, NULL), RES_BAD_ARG);
- CHECK(polygon_vertices_count_get(poly, NULL), RES_BAD_ARG);
- CHECK(polygon_vertices_count_get(NULL, &nvertices), RES_BAD_ARG);
- CHECK(polygon_vertices_count_get(poly, &nvertices), RES_OK);
- CHECK(nvertices, 0);
+ CHK(polygon_vertices_count_get(NULL, NULL) == RES_BAD_ARG);
+ CHK(polygon_vertices_count_get(poly, NULL) == RES_BAD_ARG);
+ CHK(polygon_vertices_count_get(NULL, &nvertices) == RES_BAD_ARG);
+ CHK(polygon_vertices_count_get(poly, &nvertices) == RES_OK);
+ CHK(nvertices == 0);
- CHECK(polygon_vertex_add(NULL, NULL), RES_BAD_ARG);
- CHECK(polygon_vertex_add(poly, NULL), RES_BAD_ARG);
- CHECK(polygon_vertex_add(NULL, vertices + 3), RES_BAD_ARG);
- CHECK(polygon_vertex_add(poly, vertices + 3), RES_OK);
+ CHK(polygon_vertex_add(NULL, NULL) == RES_BAD_ARG);
+ CHK(polygon_vertex_add(poly, NULL) == RES_BAD_ARG);
+ CHK(polygon_vertex_add(NULL, vertices + 3) == RES_BAD_ARG);
+ CHK(polygon_vertex_add(poly, vertices + 3) == RES_OK);
- CHECK(polygon_vertices_count_get(poly, &nvertices), RES_OK);
- CHECK(nvertices, 1);
+ CHK(polygon_vertices_count_get(poly, &nvertices) == RES_OK);
+ CHK(nvertices == 1);
/* The last vertex is equal to the new one => skip it */
- CHECK(polygon_vertex_add(poly, vertices + 3), RES_OK);
- CHECK(polygon_vertices_count_get(poly, &nvertices), RES_OK);
- CHECK(nvertices, 1);
+ CHK(polygon_vertex_add(poly, vertices + 3) == RES_OK);
+ CHK(polygon_vertices_count_get(poly, &nvertices) == RES_OK);
+ CHK(nvertices == 1);
- CHECK(polygon_vertex_add(poly, vertices + 6), RES_OK);
- CHECK(polygon_vertices_count_get(poly, &nvertices), RES_OK);
- CHECK(nvertices, 2);
+ CHK(polygon_vertex_add(poly, vertices + 6) == RES_OK);
+ CHK(polygon_vertices_count_get(poly, &nvertices) == RES_OK);
+ CHK(nvertices == 2);
/* The new vertex is aligned with the 2 previous one => replace the last
* vertex by the new one */
- CHECK(polygon_vertex_add(poly, vertices + 15), RES_OK);
- CHECK(polygon_vertices_count_get(poly, &nvertices), RES_OK);
- CHECK(nvertices, 2);
+ CHK(polygon_vertex_add(poly, vertices + 15) == RES_OK);
+ CHK(polygon_vertices_count_get(poly, &nvertices) == RES_OK);
+ CHK(nvertices == 2);
- CHECK(polygon_vertex_get(NULL, UINT32_MAX, NULL), RES_BAD_ARG);
- CHECK(polygon_vertex_get(poly, UINT32_MAX, NULL), RES_BAD_ARG);
- CHECK(polygon_vertex_get(NULL, 0, NULL), RES_BAD_ARG);
- CHECK(polygon_vertex_get(poly, 0, NULL), RES_BAD_ARG);
- CHECK(polygon_vertex_get(NULL, UINT32_MAX, pos), RES_BAD_ARG);
- CHECK(polygon_vertex_get(poly, UINT32_MAX, pos), RES_BAD_ARG);
- CHECK(polygon_vertex_get(NULL, 0, pos), RES_BAD_ARG);
- CHECK(polygon_vertex_get(poly, 0, pos), RES_OK);
- CHECK(f3_eq_eps(pos, vertices + 3, 1.e-6f), 1);
+ CHK(polygon_vertex_get(NULL, UINT32_MAX, NULL) == RES_BAD_ARG);
+ CHK(polygon_vertex_get(poly, UINT32_MAX, NULL) == RES_BAD_ARG);
+ CHK(polygon_vertex_get(NULL, 0, NULL) == RES_BAD_ARG);
+ CHK(polygon_vertex_get(poly, 0, NULL) == RES_BAD_ARG);
+ CHK(polygon_vertex_get(NULL, UINT32_MAX, pos) == RES_BAD_ARG);
+ CHK(polygon_vertex_get(poly, UINT32_MAX, pos) == RES_BAD_ARG);
+ CHK(polygon_vertex_get(NULL, 0, pos) == RES_BAD_ARG);
+ CHK(polygon_vertex_get(poly, 0, pos) == RES_OK);
+ CHK(f3_eq_eps(pos, vertices + 3, 1.e-6f) == 1);
- CHECK(polygon_vertex_get(poly, 1, pos), RES_OK);
- CHECK(f3_eq_eps(pos, vertices + 15, 1.e-6f), 1);
+ CHK(polygon_vertex_get(poly, 1, pos) == RES_OK);
+ CHK(f3_eq_eps(pos, vertices + 15, 1.e-6f) == 1);
- CHECK(polygon_vertex_get(poly, 2, pos), RES_BAD_ARG);
+ CHK(polygon_vertex_get(poly, 2, pos) == RES_BAD_ARG);
- CHECK(polygon_clear(NULL), RES_BAD_ARG);
- CHECK(polygon_clear(poly), RES_OK);
+ CHK(polygon_clear(NULL) == RES_BAD_ARG);
+ CHK(polygon_clear(poly) == RES_OK);
- CHECK(polygon_vertices_count_get(poly, &nvertices), RES_OK);
- CHECK(nvertices, 0);
+ CHK(polygon_vertices_count_get(poly, &nvertices) == RES_OK);
+ CHK(nvertices == 0);
FOR_EACH(ivertex, 0, sizeof(vertices)/sizeof(float[3]))
- CHECK(polygon_vertex_add(poly, vertices + ivertex * 3), RES_OK);
+ CHK(polygon_vertex_add(poly, vertices + ivertex * 3) == RES_OK);
- CHECK(polygon_vertices_count_get(poly, &nvertices), RES_OK);
- CHECK(nvertices, sizeof(vertices)/sizeof(float[3]));
+ CHK(polygon_vertices_count_get(poly, &nvertices) == RES_OK);
+ CHK(nvertices == sizeof(vertices)/sizeof(float[3]));
FOR_EACH(ivertex, 0, sizeof(vertices)/sizeof(float[3])) {
- CHECK(polygon_vertex_get(poly, ivertex, pos), RES_OK);
- CHECK(f3_eq_eps(pos, vertices + ivertex*3, 1.e-6f), 1);
+ CHK(polygon_vertex_get(poly, ivertex, pos) == RES_OK);
+ CHK(f3_eq_eps(pos, vertices + ivertex*3, 1.e-6f) == 1);
}
- CHECK(polygon_triangulate(NULL, NULL, NULL), RES_BAD_ARG);
- CHECK(polygon_triangulate(poly, NULL, NULL), RES_BAD_ARG);
- CHECK(polygon_triangulate(NULL, &indices, NULL), RES_BAD_ARG);
- CHECK(polygon_triangulate(poly, &indices, NULL), RES_BAD_ARG);
- CHECK(polygon_triangulate(NULL, NULL, &nindices), RES_BAD_ARG);
- CHECK(polygon_triangulate(poly, NULL, &nindices), RES_BAD_ARG);
- CHECK(polygon_triangulate(NULL, &indices, &nindices), RES_BAD_ARG);
+ CHK(polygon_triangulate(NULL, NULL, NULL) == RES_BAD_ARG);
+ CHK(polygon_triangulate(poly, NULL, NULL) == RES_BAD_ARG);
+ CHK(polygon_triangulate(NULL, &indices, NULL) == RES_BAD_ARG);
+ CHK(polygon_triangulate(poly, &indices, NULL) == RES_BAD_ARG);
+ CHK(polygon_triangulate(NULL, NULL, &nindices) == RES_BAD_ARG);
+ CHK(polygon_triangulate(poly, NULL, &nindices) == RES_BAD_ARG);
+ CHK(polygon_triangulate(NULL, &indices, &nindices) == RES_BAD_ARG);
/* Check full triangulation */
- CHECK(polygon_triangulate(poly, &indices, &nindices), RES_OK);
- CHECK(nindices, 30);
- CHECK(eq_eps(check_triangulation
- (poly, indices, nindices, 12), 1.f, 1.e-6f), 1);
+ CHK(polygon_triangulate(poly, &indices, &nindices) == RES_OK);
+ CHK(nindices == 30);
+ CHK(eq_eps(check_triangulation(poly, indices, nindices, 12), 1.f, 1.e-6f));
/* After the triangulation the input polygon may be unchanged */
- CHECK(polygon_vertices_count_get(poly, &nvertices), RES_OK);
- CHECK(nvertices, sizeof(vertices)/sizeof(float[3]));
+ CHK(polygon_vertices_count_get(poly, &nvertices) == RES_OK);
+ CHK(nvertices == sizeof(vertices)/sizeof(float[3]));
FOR_EACH(ivertex, 0, sizeof(vertices)/sizeof(float[3])) {
- CHECK(polygon_vertex_get(poly, ivertex, pos), RES_OK);
- CHECK(f3_eq_eps(pos, vertices + ivertex*3, 1.e-6f), 1);
+ CHK(polygon_vertex_get(poly, ivertex, pos) == RES_OK);
+ CHK(f3_eq_eps(pos, vertices + ivertex*3, 1.e-6f) == 1);
}
/* Check that the input polygon can be retriangulated */
- CHECK(polygon_triangulate(poly, &indices, &nindices), RES_OK);
- CHECK(nindices, 30);
- CHECK(eq_eps(check_triangulation
- (poly, indices, nindices, 12), 1.f, 1.e-6f), 1);
+ CHK(polygon_triangulate(poly, &indices, &nindices) == RES_OK);
+ CHK(nindices == 30);
+ CHK(eq_eps(check_triangulation(poly, indices, nindices, 12), 1.f, 1.e-6f));
/* One can triangulate empty polygon */
- CHECK(polygon_clear(poly), RES_OK);
- CHECK(polygon_triangulate(poly, &indices, &nindices), RES_OK);
- CHECK(nindices, 0);
+ CHK(polygon_clear(poly) == RES_OK);
+ CHK(polygon_triangulate(poly, &indices, &nindices) == RES_OK);
+ CHK(nindices == 0);
/* Check the triangulation of an updated polygon */
- CHECK(polygon_vertex_add(poly, vertices + 0), RES_OK);
- CHECK(polygon_vertex_add(poly, vertices + 3), RES_OK);
- CHECK(polygon_triangulate(poly, &indices, &nindices), RES_OK);
- CHECK(nindices, 0);
- CHECK(polygon_vertex_add(poly, vertices + 6), RES_OK);
- CHECK(polygon_triangulate(poly, &indices, &nindices), RES_OK);
- CHECK(nindices, 3);
- CHECK(eq_eps(check_triangulation
- (poly, indices, nindices, 3), 0.5f, 1.e-6f), 1);
- CHECK(polygon_vertex_add(poly, vertices + 9), RES_OK);
- CHECK(polygon_vertex_add(poly, vertices + 12), RES_OK);
- CHECK(polygon_vertex_add(poly, vertices + 15), RES_OK);
- CHECK(polygon_vertex_add(poly, vertices + 18), RES_OK);
- CHECK(polygon_vertex_add(poly, vertices + 21), RES_OK);
- CHECK(polygon_vertex_add(poly, vertices + 21), RES_OK);
- CHECK(polygon_triangulate(poly, &indices, &nindices), RES_OK);
- CHECK(nindices, 18);
- CHECK(eq_eps(check_triangulation
- (poly, indices, nindices, 8), 1.375f, 1.e-6f), 1);
-
- CHECK(polygon_ref_put(poly), RES_OK);
+ CHK(polygon_vertex_add(poly, vertices + 0) == RES_OK);
+ CHK(polygon_vertex_add(poly, vertices + 3) == RES_OK);
+ CHK(polygon_triangulate(poly, &indices, &nindices) == RES_OK);
+ CHK(nindices == 0);
+ CHK(polygon_vertex_add(poly, vertices + 6) == RES_OK);
+ CHK(polygon_triangulate(poly, &indices, &nindices) == RES_OK);
+ CHK(nindices == 3);
+ CHK(eq_eps(check_triangulation(poly, indices, nindices, 3), 0.5f, 1.e-6f));
+ CHK(polygon_vertex_add(poly, vertices + 9) == RES_OK);
+ CHK(polygon_vertex_add(poly, vertices + 12) == RES_OK);
+ CHK(polygon_vertex_add(poly, vertices + 15) == RES_OK);
+ CHK(polygon_vertex_add(poly, vertices + 18) == RES_OK);
+ CHK(polygon_vertex_add(poly, vertices + 21) == RES_OK);
+ CHK(polygon_vertex_add(poly, vertices + 21) == RES_OK);
+ CHK(polygon_triangulate(poly, &indices, &nindices) == RES_OK);
+ CHK(nindices == 18);
+ CHK(eq_eps(check_triangulation(poly, indices, nindices, 8), 1.375f, 1.e-6f));
+
+ CHK(polygon_ref_put(poly) == RES_OK);
check_memory_allocator(&allocator_proxy);
mem_shutdown_proxy_allocator(&allocator_proxy);
- CHECK(mem_allocated_size(), 0);
+ CHK(mem_allocated_size() == 0);
return 0;
}
diff --git a/src/test_polygon1.c b/src/test_polygon1.c
@@ -28,32 +28,32 @@ main(int argc, char** argv)
uint32_t nids;
(void)argc, (void)argv;
- CHECK(mem_init_proxy_allocator(&allocator_proxy, &mem_default_allocator), RES_OK);
+ CHK(mem_init_proxy_allocator(&allocator_proxy, &mem_default_allocator) == RES_OK);
- CHECK(polygon_create(&allocator_proxy, &poly), RES_OK);
+ CHK(polygon_create(&allocator_proxy, &poly) == RES_OK);
pos[0] = (ucast.i = 0xbeb504f3, ucast.f);
pos[1] = (ucast.i = 0x3eb504f3, ucast.f);
- CHECK(polygon_vertex_add(poly, pos), RES_OK);
+ CHK(polygon_vertex_add(poly, pos) == RES_OK);
pos[0] = (ucast.i = 0xbe977d76, ucast.f);
pos[1] = (ucast.i = 0x3ec14031, ucast.f);
- CHECK(polygon_vertex_add(poly, pos), RES_OK);
+ CHK(polygon_vertex_add(poly, pos) == RES_OK);
pos[0] = (ucast.i = 0xbe5dab96, ucast.f);
pos[1] = (ucast.i = 0x3f05ca33, ucast.f);
- CHECK(polygon_vertex_add(poly, pos), RES_OK);
+ CHK(polygon_vertex_add(poly, pos) == RES_OK);
pos[0] = (ucast.i = 0xbecccbef, ucast.f);
pos[1] = (ucast.i = 0x3ecccbef, ucast.f);
- CHECK(polygon_vertex_add(poly, pos), RES_OK);
+ CHK(polygon_vertex_add(poly, pos) == RES_OK);
pos[0] = (ucast.i = 0xbeb504f3, ucast.f);
pos[1] = (ucast.i = 0x3eb504f3, ucast.f);
- CHECK(polygon_vertex_add(poly, pos), RES_OK);
+ CHK(polygon_vertex_add(poly, pos) == RES_OK);
- CHECK(polygon_triangulate(poly, &ids, &nids), RES_OK);
- CHECK(nids, 6);
- CHECK(polygon_ref_put(poly), RES_OK);
+ CHK(polygon_triangulate(poly, &ids, &nids) == RES_OK);
+ CHK(nids == 6);
+ CHK(polygon_ref_put(poly) == RES_OK);
check_memory_allocator(&allocator_proxy);
mem_shutdown_proxy_allocator(&allocator_proxy);
- CHECK(mem_allocated_size(), 0);
+ CHK(mem_allocated_size() == 0);
return 0;
}