2 #include "server/voxel_depth_search.h"
5 {+0, -1, +0}, // this is commonly used to find ground, search downwards first
13 static int cmp_depth_search_node(const DepthSearchNode *node, const v3s32 *pos)
15 return v3s32_cmp(&node->pos, pos);
18 bool voxel_depth_search(v3s32 pos, void (*callback)(DepthSearchNode *node, void *arg), void *arg, bool *success, Tree *visit)
20 TreeNode **tree_node = tree_nfd(visit, &pos, &cmp_depth_search_node);
22 return *success = *((DepthSearchNode *) (*tree_node)->dat)->success;
24 DepthSearchNode *node = malloc(sizeof *node);
25 tree_nmk(visit, tree_node, node);
29 if ((*(node->success = success) = (node->type == DEPTH_SEARCH_TARGET)))
32 if (node->type == DEPTH_SEARCH_PATH)
33 for (int i = 0; i < 6; i++)
34 if (voxel_depth_search(v3s32_add(pos, dirs[i]), callback, arg, success, visit))