Jump to content

Intersect All VEX only works sometimes?


Behrendt

Recommended Posts

Hi everyone,

I posted some progress in another thread (Sidewalks - PathDeform? - Modeling - od|forum (odforce.net)). 

My VEX code for detecting intersecting geometry only seems to work on some parts of the model, whereas on others it does not seem to work at all.

My idea for the code was to iterate over all points and fire a ray each up and down, to see if there is more than one intersection (it seems it generates always 1 intersection, for the self intersection), and if the point intersects with the geo, its added to a point group, so it can be fused at a later point. 

What could be the reason, that it only works on some parts of the model?

vector RayDDown = {0,-100,0};
vector RayDUp= {0,100,0};
vector hitPos[];
int hitPrims[];
vector hitUVW[];
float tol = 0.00001;
float ttol = 0.00001;
int expand = 0;
int stepping = 2;
expand = expand * stepping;

    i@IntersectDown = intersect_all(0,@P, RayDDown, hitPos, hitPrims, hitUVW, tol, ttol);
    if (@IntersectDown > 1)
    {    
        setpointgroup(0,"Intersecting", @ptnum-expand, 1, "set");
        setpointgroup(0,"Intersecting", @ptnum, 1, "set");
        setpointgroup(0,"Intersecting", @ptnum+expand, 1, "set");
    }
    i@IntersectUp = intersect_all(0,@P, RayDUp, hitPos, hitPrims, hitUVW, tol, ttol);
    if (@IntersectUp >1)
    {
        setpointgroup(0,"Intersecting", @ptnum-expand, 1, "set");
        setpointgroup(0,"Intersecting", @ptnum, 1, "set");
        setpointgroup(0,"Intersecting", @ptnum+expand, 1, "set");
    }

I also included a screenshot illustrating the problem.

Thanks in advance!

2021-02-25_162839.jpg

Link to comment
Share on other sites

Hi,

not sure what you are trying to achieve, but if you want to detect the points with intersection rays, which are in the overlapping area, you can duplicate the geometry, add an offset to y and move each points slightly based on their point number in y-direction. Now you should be able to send a ray from the original point to y-direction with little offset from the starting point.

 

here is a file

intersect_all_overlap.hipnc

Edited by Aizatulin
  • Thanks 1
Link to comment
Share on other sites

Hi @Aizatulin,

thanks for helping again - yes, my original idea was trying to use intersection rays to detect overlapping surfaces. As you can see it also worked fine one most meshes - on others it just wouldn't at all.

I now found out about PolyDoctor (a lot of nodes to learn for a newcomer :) ) - which worked fine for detecting the overlaps. 

Still I'm interested to find out why my code only worked some of the time. As you proposed I also tried a Y-Offset to fix the problem, which didn't work out. Only thing that seemed to work was setting ttol to "-1" to get any interesections at all, otherwise the intersect didn't seem to hit anything. I guess it's a bias thingy and offsetting the points a little in X/Z would probably help, so the ray isn't hitting a point perfectly. Because when using ttol -1, the number of intersections per point grew, according to how many primitives it was connected to (which makes sense, but was unusable for my purposes).

Maybe I will test further in a few days, but for now PolyDoctor worked fine.

Thanks again :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...