2 #include "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, DepthSearchNodeType (*get_type)(v3s32 pos), 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);
26 node->type = get_type(pos);
28 if ((*(node->success = success) = (node->type == DEPTH_SEARCH_TARGET)))
31 if (node->type == DEPTH_SEARCH_PATH)
32 for (int i = 0; i < 6; i++)
33 if (voxel_depth_search(v3s32_add(pos, dirs[i]), get_type, success, visit))