star-2d

Contour structuring for efficient 2D geometric queries
git clone git://git.meso-star.fr/star-2d.git
Log | Files | Refs | README | LICENSE

commit 17f2ac4e9322ab6b88ab7ea33524c1938436ffc8
parent 2e74745c9d1e0c558f0d138d61c7e6fae2a58eb5
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Mon, 20 Jun 2016 09:37:28 +0200

Implement the line_segments_copy_indexed_vertices back-end function

Diffstat:
Msrc/s2d_line_segments.c | 59+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 59 insertions(+), 0 deletions(-)

diff --git a/src/s2d_line_segments.c b/src/s2d_line_segments.c @@ -503,3 +503,62 @@ line_segments_compute_aabb } } +void +line_segments_copy_indexed_vertices + (const struct line_segments* src, + struct line_segments* dst) +{ + size_t nsegments_src; + size_t nsegments_dst; + size_t nverts_src; + size_t nverts_dst; + int i; + ASSERT(src && dst); + + nsegments_src = line_segments_get_nsegments(src); + nsegments_dst = line_segments_get_nsegments(dst); + nverts_src = line_segments_get_nsegments(src); + nverts_dst = line_segments_get_nsegments(dst); + + /* Setup indexe buffer masks */ + if(nsegments_src == nsegments_dst) { + dst->update_mask = (INDEX_BUFFER & !dst->resize_mask); + } else { + dst->resize_mask |= INDEX_BUFFER; + dst->update_mask &= !INDEX_BUFFER; + } + + /* Release the previous index buffer of dst */ + if(dst->indices) { + index_buffer_ref_put(dst->indices); + dst->indices = NULL; + } + /* Get a reference onto the index buffer of src */ + if(src->indices) { + index_buffer_ref_get(src->indices); + dst->indices = src->indices; + } + + /* Setup the vertex buffer masks */ + if(nverts_src == nverts_dst) { + dst->update_mask = (VERTEX_BUFFER & ~dst->resize_mask); + } else { + dst->resize_mask |= VERTEX_BUFFER; + dst->update_mask &= !VERTEX_BUFFER; + } + + FOR_EACH(i, 0, S2D_ATTRIBS_COUNT__) { + /* Release the previous vertex buffers of dst */ + if(dst->attribs[i]) { + vertex_buffer_ref_put(dst->attribs[i]); + dst->attribs[i] = NULL; + } + /* Get a reference onto the vertex buffers of src */ + if(src->attribs[i]) { + vertex_buffer_ref_get(src->attribs[i]); + dst->attribs[i] = src->attribs[i]; + dst->attribs_type[i] = src->attribs_type[i]; + } + } +} +