Jump to content
Sign in to follow this  
Behrendt

Intersect All VEX only works sometimes?

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

Share this post


Link to post
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

Share this post


Link to post
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 :)

Share this post


Link to post
Share on other sites
Posted (edited)

I think you just need to change the following :) :

float tol = -1;
float ttol = -1;

then it should find all intersections, even the triangles are at exactly the same height

Edited by acey195

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×