You might wanna populate a mathutils.kdtree.KDTree with face centers, balance it once, then query as often as needed for closest coord (as long as the mesh doesn’t change). It should be very efficient.
I am currently in the process of re-factoring the code. Though not in that screenshot, “generative” also has a random color function, and a simplified “highlight vector.” The expression tool can do random colors as well. Highlight facing will also get a distance falloff option.
All tools have a channel option to isolate the operation to a specific channel if need be.
Started with the basics on the vertex paint tools little more than a year ago, and I add tools as I need them.
Cool, so you are vertex coloring based on proximity to another mesh and/or the face direction?
q. Have you seen the proximity vertex group modifier? That my take care of your vertex weights without having to script the kd tree. However the scripting is much more flexible. I’ve always wanted a way to transform the weights from the proximity modifier to a color map in vertex paint. Because switching to weight paint mode to visualize the proximity modifier results is a pain. It looks like you have achieved one of my “back of my mind” projects.
Yes proximity vertex group modifier is not what I want. My need was facing/not facing and not distance. But I’ll combine it with distance just to make it that much more useful. My tool accepts all object types. The surface facing counts only for meshable objects (mesh, curve, surface, meta, text), using a sun lamp uses the sun vector, and for other object types the object origin is default. I can modify it for other object type specifics as I see the need. Right now this is a vertex color tool, but I just transfer the vertex colors to a weight layer when I am done.
All my vcol tools default to selected vertices (all loops of the vertex) unless face masking is enabled in which all tools use the selected face loops (except “set vertex colors soft” which would defeat its purpose).
I did this because I find it absolutely absurd to the highest degree that weight paint has vertex selection masking ( ), but vertex paint does not.
Sounds super useful for several applications that I use. Both the coloring via a color map based on some parameter (proximity, face direction etc) and changing vertex weights. I don’t know if you would be willing to share, but I would love to take a peak. If this is a private/proprietary tool, no worries.
I’ll eventually release the w0rkfl0w tools on here, I am right in the middle of other projects and in the middle of the code re-factor for it. Over time it grew into a huge multi-thousand line pile of redundant, disorganized code as a result of copy and paste any time I added another tool.