vesaw55345 Posted February 14, 2022 Share Posted February 14, 2022 I'm having troubles with connecting close points, but only if they are not on the same y coordinate. int pts[] = nearpoints(0, @P, chf("maxDist")); printf("POINT " + itoa(@ptnum) + "\n"); foreach (int pt; pts) { float coord[] = point(0, "P", pt); printf(" " + itoa(@ptnum) + " NEARPOINT " + itoa(pt) + "\n"); // don't connect horizontally if(abs(coord[1] - @P.y) < 0.001) { return; } int prim = addprim(geoself(), "polyline", @ptnum, pt); } Also I think I might not really understand the order in which things are executed. If I run the above code over points I expect a nested debug output like POINT 1 1 NEARPOINT 1 1 NEARPOINT 2 POINT 2 2 NEARPOINT 1 2 NEARPOINT 2 etc... Instead I get the output of line 3 for every point first. How come? (Pretty new to Houdini.) filter.hipnc Quote Link to comment Share on other sites More sharing options...
flcc Posted February 15, 2022 Share Posted February 15, 2022 (edited) It's a bit confusing but nearpoint also returns the source point, i.e. it finds itself. So you have to exclude this entry. It' probably why you get three lines when you excpect two. This is a try for what you try to do. It run in detail mode. For this kind of stuff, It's more easy to debug IMO. filter F.hipnc Edited February 15, 2022 by flcc Quote Link to comment Share on other sites More sharing options...
vesaw55345 Posted February 15, 2022 Author Share Posted February 15, 2022 @flcc : Thanks! (1) May I ask why you run it in detail mode and then manually iterate through the points? Wouldn't running it over the Points do that for you? (2) The part about nearpoint returning the source: I was aware of that and initially tried something like this (in my code above): foreach (int pt; pts) { if(pt == @ptnum) { return; } I thought it would skip the loop for those cases where the nearpoint is the current point. But somehow this condition was always true and the the code always returned. That's quite confusing to me. Quote Link to comment Share on other sites More sharing options...
flcc Posted February 15, 2022 Share Posted February 15, 2022 When creating geometry I prefer run in detail Mode if possible. Can sometime be tricky in point mode. But you can easily convert it in point mode after if needed. If primitive number is the same, It's that there is no problem. Probably more experimented guys don't do that Quote Link to comment Share on other sites More sharing options...
animatrix Posted February 15, 2022 Share Posted February 15, 2022 Hi, You are doing it correctly but instead of return you have to use "continue": int pts[] = nearpoints(0, @P, chf("maxDist")); removevalue ( pts, @ptnum ); foreach (int pt; pts) { vector coord = point(0, "P", pt); if(abs(coord.y - @P.y) < 0.001) continue; if ( @ptnum < pt ) int prim = addprim(geoself(), "polyline", @ptnum, pt); } I would also recommend removing the point itself from the array. The point itself is generally the first element but it's not guaranteed if you have overlapping points. Also you can avoid duplicate polygons by comparing point numbers. As for the print messages, it's related to how Houdini executes the given VEX code. 1 Quote Link to comment Share on other sites More sharing options...
vesaw55345 Posted February 16, 2022 Author Share Posted February 16, 2022 @animatrix thanks a lot! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.