commit 24182df9eea1945a0ccb8a2412a36d1d86e858ab
parent 902b01679fcdf20b90452ab7321af8e3b197c80f
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Mon, 7 Nov 2016 13:55:19 +0100
Add is_pivot API call and test code.
Diffstat:
5 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/src/sanim.h b/src/sanim.h
@@ -183,6 +183,11 @@ sanim_node_get_child
const size_t idx,
const struct sanim_node** child);
+SANIM_API res_T
+sanim_node_is_pivot
+ (const struct sanim_node* node,
+ int* pivot);
+
END_DECLS
#endif /* SANIM_H */
diff --git a/src/sanim_node.c b/src/sanim_node.c
@@ -728,7 +728,9 @@ sanim_node_add_child
{
res_T res = RES_OK;
- if (!father || !child) return RES_BAD_ARG;
+ if (!father || !child
+ || !father->data || !child->data
+ ) return RES_BAD_ARG;
if (child->data->father) return RES_BAD_ARG;
if (is_ancestor(father, child)) return RES_BAD_ARG;
if (child->data->pivot_data && is_after_pivot(father)) return RES_BAD_ARG;
@@ -946,3 +948,13 @@ sanim_node_get_child
*child = children[idx];
return RES_OK;
}
+
+res_T
+sanim_node_is_pivot
+ (const struct sanim_node* node,
+ int* pivot)
+{
+ if (!node || !pivot) return RES_BAD_ARG;
+ *pivot = (node->data && node->data->pivot_data);
+ return RES_OK;
+}
+\ No newline at end of file
diff --git a/src/test_sanim_node.c b/src/test_sanim_node.c
@@ -26,6 +26,7 @@ main(int argc, char** argv)
struct sanim_pivot pivot;
struct sanim_tracking tracking;
size_t count;
+ int p;
double transform1[12], transform2[12];
double transl[3], rot[3];
(void) argc, (void) argv;
@@ -51,9 +52,19 @@ main(int argc, char** argv)
CHECK(my_type_pivot_create(&allocator, &pivot, NULL, &t1), RES_BAD_ARG);
CHECK(my_type_pivot_create(&allocator, &pivot, &tracking, NULL), RES_BAD_ARG);
CHECK(my_type_pivot_create(&allocator, &pivot, &tracking, &t1), RES_OK);
+
+ CHECK(my_type_is_pivot(NULL, &p), RES_BAD_ARG);
+ CHECK(my_type_is_pivot(t1, NULL), RES_BAD_ARG);
+ CHECK(my_type_is_pivot(t1, &p), RES_OK);
+ CHECK(p, 1);
+
CHECK(my_type_ref_put(t1), RES_OK);
CHECK(my_type_create(&allocator, &t1), RES_OK);
+
+ CHECK(my_type_is_pivot(t1, &p), RES_OK);
+ CHECK(p, 0);
+
CHECK(my_type_add_child(NULL, t1), RES_BAD_ARG);
CHECK(my_type_add_child(t1, NULL), RES_BAD_ARG);
CHECK(my_type_add_child(t1, t1), RES_BAD_ARG);
diff --git a/src/test_sanim_utils.c b/src/test_sanim_utils.c
@@ -297,6 +297,11 @@ my_type_solve_pivot(struct my_type* t, const double in_dir[3]) {
return sanim_node_solve_pivot(&t->node, in_dir);
}
+res_T
+my_type_is_pivot(struct my_type* t, int* pivot) {
+ return sanim_node_is_pivot(&t->node, pivot);
+}
+
char
d3_is_zero_eps(const double v[3], const double eps) {
int x;
diff --git a/src/test_sanim_utils.h b/src/test_sanim_utils.h
@@ -73,6 +73,9 @@ res_T
my_type_solve_pivot(struct my_type* t, const double in_dir[3]);
res_T
+my_type_is_pivot(struct my_type* t, int* pivot);
+
+res_T
my_type_get_father
(const struct my_type* t,
const struct my_type** father);