test_sanim_utils.h (3412B)
1 /* Copyright (C) 2018-2026 |Méso|Star> (contact@meso-star.com) 2 * Copyright (C) 2016-2018 CNRS 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 17 #ifndef TEST_SANIM_UTILS_H 18 #define TEST_SANIM_UTILS_H 19 20 #include "sanim.h" 21 22 #include <rsys/rsys.h> 23 #include <rsys/ref_count.h> 24 25 struct mem_allocator; 26 27 /******************************************************************************* 28 * Define a custom type of node based on sanim_node 29 ******************************************************************************/ 30 struct my_type { 31 struct sanim_node node; 32 double my_data; 33 struct mem_allocator *allocator; 34 ref_T ref; 35 }; 36 37 res_T 38 my_type_create(struct mem_allocator *allocator, struct my_type** t); 39 40 res_T 41 my_type_pivot_create 42 (struct mem_allocator *allocator, 43 const struct sanim_pivot* pivot, 44 const struct sanim_tracking* tracking, 45 struct my_type** t); 46 47 /* create a new node and copy content of src into it 48 * non-recursive copy (father/child links are not set) 49 * copy my_data, rotations, translation and possible pivot information */ 50 res_T 51 my_type_copy_create 52 (const struct my_type* src, 53 struct my_type** dst); 54 55 res_T 56 my_type_ref_get(struct my_type* t); 57 58 res_T 59 my_type_ref_put(struct my_type* t); 60 61 res_T 62 my_type_add_child(struct my_type* t, struct my_type* child); 63 64 res_T 65 my_type_set_translation(struct my_type* t, const double translation[3]); 66 67 res_T 68 my_type_get_translation(const struct my_type* t, double translation[3]); 69 70 res_T 71 my_type_set_rotations(struct my_type* t, const double rotations[3]); 72 73 res_T 74 my_type_get_rotations(const struct my_type* t, double rotations[3]); 75 76 res_T 77 my_type_get_transform(struct my_type* t, double transform[12]); 78 79 res_T 80 my_type_solve_pivot(struct my_type* t, const double in_dir[3]); 81 82 res_T 83 my_type_is_pivot(struct my_type* t, int* pivot); 84 85 res_T 86 my_type_track_me(const struct my_type* t, struct sanim_tracking* tracking); 87 88 res_T 89 my_type_get_father 90 (const struct my_type* t, 91 struct my_type** father); 92 93 res_T 94 my_type_get_children_count(const struct my_type* t, size_t* count); 95 96 res_T 97 my_type_get_child 98 (const struct my_type* t, 99 const size_t idx, 100 struct my_type** child); 101 102 res_T 103 my_type_recursive_copy 104 (struct mem_allocator *allocator, 105 const struct my_type* src, 106 struct my_type** dst); 107 108 /******************************************************************************* 109 * Utilities 110 ******************************************************************************/ 111 char 112 d3_is_zero_eps(const double v[3], const double eps); 113 114 char 115 d3_is_zero(const double v[3]); 116 117 char 118 d33_is_identity_eps(const double v[9], const double eps); 119 120 char 121 d34_eq_eps(const double a[12], const double b[12], const double eps); 122 123 void 124 log_stream(const char* msg, void* ctx); 125 126 void 127 check_memory_allocator(struct mem_allocator* allocator); 128 129 #endif /* TEST_SANIM_UTILS_H */ 130