32 uiItemR(layout,
ptr,
"target_element", 0,
"", ICON_NONE);
39 node->storage = node_storage;
62 if (bvh_data.
tree ==
nullptr) {
67 BVHTreeNearest nearest;
68 copy_v3_fl(nearest.co, FLT_MAX);
72 const int index = mask[i];
74 nearest.dist_sq = math::distance_squared(float3(nearest.co), positions[index]);
76 BLI_bvhtree_find_nearest(
77 bvh_data.tree, positions[index], &nearest, bvh_data.nearest_callback, &bvh_data);
79 if (nearest.dist_sq < r_distances[index]) {
80 r_distances[index] = nearest.dist_sq;
81 if (!r_locations.is_empty()) {
82 r_locations[index] = nearest.co;
100 if (bvh_data.
tree ==
nullptr) {
105 BVHTreeNearest nearest;
106 copy_v3_fl(nearest.co, FLT_MAX);
109 for (int i : range) {
110 const int index = mask[i];
114 nearest.dist_sq = r_distances[index];
116 BLI_bvhtree_find_nearest(
117 bvh_data.tree, positions[index], &nearest, bvh_data.nearest_callback, &bvh_data);
119 if (nearest.dist_sq < r_distances[index]) {
120 r_distances[index] = nearest.dist_sq;
121 if (!r_locations.is_empty()) {
122 r_locations[index] = nearest.co;
139 : target_(
std::move(target)), type_(
type)
142 this->set_signature(&signature);
149 signature.single_output<
float3>(
"Position");
150 signature.single_output<
float>(
"Distance");
151 return signature.build();
166 distances.fill_indices(
mask, FLT_MAX);
168 bool success =
false;
183 if (!distances.is_empty()) {
184 distances.fill_indices(
mask, 0.0f);
189 if (
params.single_output_is_required(2,
"Distance")) {
191 for (const int i : range) {
192 const int j = mask[i];
193 distances[j] = std::sqrt(distances[j]);
206 params.set_default_remaining_outputs();
213 auto proximity_fn = std::make_unique<ProximityFunction>(
214 std::move(geometry_set_target),
216 auto proximity_op = std::make_shared<FieldOperation>(
217 FieldOperation(std::move(proximity_fn), {std::move(position_field)}));
BVHTree * BKE_bvhtree_from_pointcloud_get(struct BVHTreeFromPointCloud *data, const struct PointCloud *pointcloud, int tree_type)
void free_bvhtree_from_mesh(struct BVHTreeFromMesh *data)
void free_bvhtree_from_pointcloud(struct BVHTreeFromPointCloud *data)
BVHTree * BKE_bvhtree_from_mesh_get(struct BVHTreeFromMesh *data, const struct Mesh *mesh, BVHCacheType bvh_cache_type, int tree_type)
@ GEO_COMPONENT_TYPE_MESH
@ GEO_COMPONENT_TYPE_POINT_CLOUD
#define NODE_STORAGE_FUNCS(StorageT)
void node_type_init(struct bNodeType *ntype, void(*initfunc)(struct bNodeTree *ntree, struct bNode *node))
#define GEO_NODE_PROXIMITY
#define NODE_CLASS_GEOMETRY
void node_type_storage(struct bNodeType *ntype, const char *storagename, void(*freefunc)(struct bNode *node), void(*copyfunc)(struct bNodeTree *dest_ntree, struct bNode *dest_node, const struct bNode *src_node))
void nodeRegisterType(struct bNodeType *ntype)
GeometryNodeProximityTargetType
@ GEO_NODE_PROX_TARGET_EDGES
@ GEO_NODE_PROX_TARGET_POINTS
@ GEO_NODE_PROX_TARGET_FACES
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon)
void single_input(const char *name)
ProximityFunction(GeometrySet target, GeometryNodeProximityTargetType type)
static fn::MFSignature create_signature()
void call(IndexMask mask, fn::MFParams params, fn::MFContext UNUSED(context)) const override
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
static bool calculate_mesh_proximity(const VArray< float3 > &positions, const IndexMask mask, const Mesh &mesh, const GeometryNodeProximityTargetType type, const MutableSpan< float > r_distances, const MutableSpan< float3 > r_locations)
static void node_geo_exec(GeoNodeExecParams params)
static void node_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
static void node_declare(NodeDeclarationBuilder &b)
static void geo_proximity_init(bNodeTree *UNUSED(ntree), bNode *node)
static bool calculate_pointcloud_proximity(const VArray< float3 > &positions, const IndexMask mask, const PointCloud &pointcloud, MutableSpan< float > r_distances, MutableSpan< float3 > r_locations)
void parallel_for(IndexRange range, int64_t grain_size, const Function &function)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
MutableSpan< float3 > positions
void register_node_type_geo_proximity()
void geo_node_type_base(bNodeType *ntype, int type, const char *name, short nclass)
void node_copy_standard_storage(bNodeTree *UNUSED(dest_ntree), bNode *dest_node, const bNode *src_node)
void node_free_standard_storage(bNode *node)
const PointCloud * get_pointcloud_for_read() const
void ensure_owns_direct_data()
const Mesh * get_mesh_for_read() const
bool has_pointcloud() const
NodeGeometryExecFunction geometry_node_execute
void(* draw_buttons)(struct uiLayout *, struct bContext *C, struct PointerRNA *ptr)
NodeDeclareFunction declare