commit 28b8fb3240e77f45ceaa9273523a113cea423b8f
parent c245dc6d19d6dcf3bfd032c9a8c48c9548b75add
Author: vaplv <vaplv@free.fr>
Date: Sun, 21 Sep 2014 18:55:07 +0200
Add accessors to the polygon vertices
Diffstat:
2 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/src/polygon.c b/src/polygon.c
@@ -294,6 +294,26 @@ error:
}
enum polygon_result
+polygon_vertices_count_get(const struct polygon* poly, uint32_t* nvertices)
+{
+ if(!poly || !nvertices) return POLYGON_BAD_ARGUMENT;
+ *nvertices = poly->nvertices;
+ return POLYGON_OK;
+}
+
+enum polygon_result
+polygon_vertex_get
+ (const struct polygon* poly, const uint32_t ivertex, float pos[3])
+{
+ const struct vertex_node* node;
+ if(!poly || !pos || ivertex >= poly->nvertices)
+ return POLYGON_BAD_ARGUMENT;
+ node = darray_vertex_node_cdata_get(&poly->pool) + ivertex;
+ f3_set(pos, node->pos);
+ return POLYGON_OK;
+}
+
+enum polygon_result
polygon_triangulate
(struct polygon* poly,
const uint32_t** indices,
diff --git a/src/polygon.h b/src/polygon.h
@@ -67,9 +67,21 @@ polygon_vertex_add
const float pos[3]);
POLYGON_API enum polygon_result
+polygon_vertices_count_get
+ (const struct polygon* polygon,
+ uint32_t* nvertices);
+
+POLYGON_API enum polygon_result
+polygon_vertex_get
+ (const struct polygon* polygon,
+ const uint32_t ivertex,
+ float position[3]);
+
+POLYGON_API enum polygon_result
polygon_triangulate
(struct polygon* polygon,
- const uint32_t** vertex_indices);
+ const uint32_t** indices,
+ uint32_t* indices_count);
END_DECLS