commit 2683eeecee3f6d394f00f109ba0415c7c1b3bf37
parent 6c80a19de3a7e0b5659cd723e098c759d4b99440
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Wed, 4 May 2022 12:04:15 +0200
Handle the line mesh at the leaf level
Diffstat:
2 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/src/sln_tree_build.c b/src/sln_tree_build.c
@@ -33,6 +33,34 @@ ui64_to_ui32(const uint64_t ui64)
return (uint32_t)ui64;
}
+static INLINE res_T
+setup_leaf
+ (struct sln_tree* tree,
+ const struct sln_tree_create_args* args,
+ struct sln_node* leaf)
+{
+ res_T res = RES_OK;
+ (void)args; /* It should define the number of vertices */
+
+ /* Currently assume that we have only one line per leaf */
+ ASSERT(leaf->range[0] == leaf->range[1]);
+
+ leaf->offset = 0;
+
+ leaf->ivertices = darray_vertex_size_get(&tree->vertices);
+
+ res = line_mesh(tree, leaf->range[0], 64/*TODO it must be an argument*/);
+ if(res != RES_OK) goto error;
+
+ leaf->nvertices = ui64_to_ui32
+ (darray_vertex_size_get(&tree->vertices) - leaf->ivertices);
+
+exit:
+ return res;
+error:
+ goto exit;
+}
+
/*******************************************************************************
* Local functions
******************************************************************************/
@@ -69,7 +97,9 @@ tree_build
/* Make a leaf */
if(nlines <= args->max_nlines_per_leaf) {
- NODE(inode)->offset = 0;
+ res = setup_leaf(tree, args, NODE(inode));
+ if(res != RES_OK) goto error;
+
inode = istack ? stack[--istack] : SIZE_MAX; /* Pop the next node */
/* Split the node */
diff --git a/src/test_sln_tree.c b/src/test_sln_tree.c
@@ -407,7 +407,7 @@ test_tree
tree_args.max_nlines_per_leaf = 0;
CHK(sln_tree_create(sln, &tree_args, &tree) == RES_BAD_ARG);
- tree_args.max_nlines_per_leaf = 16;
+ tree_args.max_nlines_per_leaf = 1;
CHK(sln_tree_create(sln, &tree_args, &tree) == RES_OK);
CHK(sln_tree_ref_put(tree) == RES_OK);