3 #include "testing/testing.h"
17 static void rng_v3_round(
float *coords,
int coords_len,
struct RNG *rng,
int round,
float scale)
19 for (
int i = 0; i < coords_len; i++) {
21 coords[i] = ((
float)((
int)(f * round)) / (
float)round) * scale;
59 EXPECT_EQ_ARRAY(co, points[index], 3);
61 nearest->
index = index;
70 int points_len,
float scale,
int round,
int random_seed,
bool optimal =
false)
75 void *mem =
MEM_mallocN(
sizeof(
float[3]) * points_len, __func__);
78 for (
int i = 0; i < points_len; i++) {
88 for (
int i = 0; i < points_len; i++) {
92 const float dist =
len_v3v3(points[i], points[j]);
93 if (dist > (1.0f / (
float)round)) {
94 printf(
"%.15f (%d %d)\n", dist, i, j);
101 EXPECT_LT(j, points_len);
102 EXPECT_EQ_ARRAY(points[i], points[j], 3);
123 TEST(kdopbvh, OptimalFindNearest_1)
127 TEST(kdopbvh, OptimalFindNearest_2)
131 TEST(kdopbvh, OptimalFindNearest_500)
typedef float(TangentPoint)[2]
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
int BLI_bvhtree_find_nearest_ex(BVHTree *tree, const float co[3], BVHTreeNearest *nearest, BVHTree_NearestPointCallback callback, void *userdata, int flag)
void BLI_bvhtree_balance(BVHTree *tree)
BVHTree * BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis)
void BLI_bvhtree_free(BVHTree *tree)
void BLI_bvhtree_insert(BVHTree *tree, int index, const float co[3], int numpoints)
@ BVH_NEAREST_OPTIMAL_ORDER
int BLI_bvhtree_get_len(const BVHTree *tree)
void(* BVHTree_NearestPointCallback)(void *userdata, int index, const float co[3], BVHTreeNearest *nearest)
static void optimal_check_callback(void *userdata, int index, const float co[3], BVHTreeNearest *nearest)
static void rng_v3_round(float *coords, int coords_len, struct RNG *rng, int round, float scale)
static void find_nearest_points_test(int points_len, float scale, int round, int random_seed, bool optimal=false)
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE float len_squared_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
void BLI_rng_free(struct RNG *rng) ATTR_NONNULL(1)
struct RNG * BLI_rng_new(unsigned int seed)
float BLI_rng_get_float(struct RNG *rng) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Read Guarded memory(de)allocation.
DEGForeachIDComponentCallback callback
void(* MEM_freeN)(void *vmemh)
void *(* MEM_mallocN)(size_t len, const char *str)
blender::RandomNumberGenerator rng