5#include "testing/testing.h"
19static void rng_v3_round(
float *coords,
int coords_len,
RNG *rng,
int round,
float scale)
21 for (
int i = 0; i < coords_len; i++) {
23 coords[i] = (
float(
int(f * round)) /
float(round)) * scale;
61 EXPECT_EQ_ARRAY(co, points[index], 3);
63 nearest->index = index;
72 int points_len,
float scale,
int round,
int random_seed,
bool optimal =
false)
77 void *mem =
MEM_mallocN(
sizeof(
float[3]) * points_len, __func__);
80 for (
int i = 0; i < points_len; i++) {
90 for (
int i = 0; i < points_len; i++) {
94 const float dist =
len_v3v3(points[i], points[j]);
95 if (dist > (1.0f /
float(round))) {
96 printf(
"%.15f (%d %d)\n", dist, i, j);
103 EXPECT_LT(j, points_len);
104 EXPECT_EQ_ARRAY(points[i], points[j], 3);
125TEST(kdopbvh, OptimalFindNearest_1)
129TEST(kdopbvh, OptimalFindNearest_2)
133TEST(kdopbvh, OptimalFindNearest_500)
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
BVHTree * BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis)
@ BVH_NEAREST_OPTIMAL_ORDER
void BLI_bvhtree_balance(BVHTree *tree)
void BLI_bvhtree_free(BVHTree *tree)
void BLI_bvhtree_insert(BVHTree *tree, int index, const float co[3], int numpoints)
int BLI_bvhtree_get_len(const BVHTree *tree)
void(* BVHTree_NearestPointCallback)(void *userdata, int index, const float co[3], BVHTreeNearest *nearest)
int BLI_bvhtree_find_nearest_ex(const BVHTree *tree, const float co[3], BVHTreeNearest *nearest, BVHTree_NearestPointCallback callback, void *userdata, int flag)
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, 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
struct RNG * BLI_rng_new(unsigned int seed)
void BLI_rng_free(struct RNG *rng) ATTR_NONNULL(1)
float BLI_rng_get_float(struct RNG *rng) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Read Guarded memory(de)allocation.
DEGForeachIDComponentCallback callback
draw_view in_light_buf[] float
void *(* MEM_mallocN)(size_t len, const char *str)
void MEM_freeN(void *vmemh)