@paqwak i wish houdini had a built in nearest point on single prim function… you can make one yourself by manually computing the barycentric coords…
the local solve from the paper i linked above seems to work pretty well. the idea is to generate prim normals using a normal sop, and then use the following vex in a for loop: @paqwak “`c //run over points int nbs[] = pointprims(0, @ptnum); matrix3 nTn = 0; vector dTn = 0; foreach(int prim; nbs){ vector n = prim(0, “N”, prim); vector p = prim(0, “P”, prim); nTn += outerproduct(n, n); dTn += n * dot(p, n); }
3@A = nTn; v@b = dTn; v@P = invert(3@A) * v@b; //solve Ax=b “`
if you use enough iterations on the above idea, you’ll end up at a point where your for loop with the fuse and stuff no longer really affects the mesh. the only problem with this method is that it requires the geometry to be like manifold and not poopy
the paper wrote the algorithm in matrix form, which does also work (though the normal building step that uses eigenvalues/vecs is really annoying so we skip that and just use a normal sop)
and since we can use a normal sop, really only the bottom half of the algorithm is what we need, and i’ve translated it to the vex above
I also omitted the `mu` stuff since that’s just like a lerp from non-planar to planar… which is a parameter we don’t really need
the above method can be problematic if the matrix A has a really stupid inverse… since i’m solving by inversion, it will cause like crazy results
Attachments in this post:
http://fx-td.com/houdiniandchill/wp-content/uploads/discord/20232608/15/23/FlattenPrims5_jr_v0002.hiplc
http://fx-td.com/houdiniandchill/wp-content/uploads/discord/20232608/15/23/image.png