Page MenuHome

Geometry Nodes: Add a minimum distance attribute to the Attribute Proximity Node
AbandonedPublic

Authored by ogierm on Jun 9 2021, 2:43 AM.

Details

Summary

Geometry Nodes: Add a minimum distance attribute to the Attribute Proximity Node

Currently, the Attribute Proximity node finds the closest point in the target geometry. This patch adds an attribute input (or a slider) for a minimum distance, so for example instead of the closest point, the closest point that is at least 5 meters away could be found.

To do this, a member min_dist_sq has been added to the BVHTreeNearest struct. The function BLI_bvhtree_find_nearest_ex has been amended to make use of this. For simplicity, this behavior has only been added to dfs_find_nearest and not to heap_find_nearest, because the latter is only being used in certain situations by the shrinkwrap modifier. To clarify this, the flag parameter has been amended into an enum with either the option BVH_NEAREST_OPTIMAL_ORDER and the new option BVH_USE_MIN_DISTANCE.

Most of the implementation of the attribute / float input part on the Attribute Proximity node itself, including the required RNA and DNA has been adapted from the math node.

Here are some examples:


This could for example be used in mograph scenarios:

In this example, without the minimum distance, the closest attachment point each cable finds, is the attachment point from which it itself started (so the distance is 0m). With the minimum distance, we can force each cable to pick a target that is not on the same pole!

Caveats: Currently, the minimum distance works by repeatedly discarding the nearest point that the depth first search on the BVH tree found, until the point is outside (or on >=) the minimum distance. This means that the higher the minimum distance is (the closer points are being skipped), the more calculations are being made.
For a minimum distance of 0 (i.e. how it was before) or every distance that leads to no skipping of points the performance penalty by this patch should be rather small and is constant time.

In the future the search could be optimized by utilizing the BVH, but as of right now I don't understand the kDOPs not enough to pull that off.

Diff Detail

Event Timeline

ogierm requested review of this revision.Jun 9 2021, 2:43 AM
ogierm created this revision.
ogierm updated this revision to Diff 38086.Jun 9 2021, 6:51 PM
ogierm updated this revision to Diff 38088.Jun 9 2021, 7:04 PM
ogierm updated this revision to Diff 38089.Jun 9 2021, 7:09 PM
ogierm updated this revision to Diff 38134.Jun 10 2021, 1:06 PM
ogierm updated this revision to Diff 38420.Jun 16 2021, 9:50 PM

Use PROP_DISTANCE

ogierm updated this revision to Diff 38432.Jun 17 2021, 12:01 AM
Hans Goudey (HooglyBoogly) requested changes to this revision.Aug 11 2021, 10:08 PM

I don't have a strong opinion about this, but I think it would be quite important that other users of the BVH code pay no price for this feature, and this node pay no price for the feature when it is turned off. Since it's quite niche compared to other uses of the BVH.

My guess is that there are other ways to accomplish many of these use cases, except for the second video maybe.

Since I'm also quite uncertain about the BVH tree code I'm not sure I'm able to offer much guidance here.

I'm requesting changes here because that should be verified, and if it isn't true some refactoring would be necessary.

This revision now requires changes to proceed.Aug 11 2021, 10:08 PM

Closing this patch, just because it's been a while. Please feel free to reopen this.