Essentially I am trying to sort the points in the polygon line in a stable way. Sorting by vertex does not always work in my test-cases. (That might be worth a bug report, but I'm not sure…). Anyways, there is some strangeness going on with the setpointattrib() updates, I guess. If you examine the console printout, it seems that the newID attribute on point 0 does not get set during the execution of the code, or does not get set in time for the last if to catch it.
Maybe I miss a fundamental concept, or something like that.
I'm on 16.0.661.
Maybe somebody can kindly point out to me, what I'm doing wrong.
Vex point attribute issue.
2737 3 0- DASD
- Member
- 453 posts
- Joined: Feb. 2013
- Offline
- jlait
- Staff
- 6219 posts
- Joined: July 2005
- Offline
- DASD
- Member
- 453 posts
- Joined: Feb. 2013
- Offline
Thank you for the help!
Now I only have more questions, though:
Are there ways to force predictable execution order for this?
Where can I find the documentation for the technicalities of this behavior?
Is this also true for Python in Houdini?
Any ideas on how to work around this issue for this particular problem?
(I can think of using a foreach loop, but that seems expensive and I can think of using a direction-vector approach, but that seems like it could fail in edge-cases.)
Now I only have more questions, though:
Are there ways to force predictable execution order for this?
Where can I find the documentation for the technicalities of this behavior?
Is this also true for Python in Houdini?
Any ideas on how to work around this issue for this particular problem?
(I can think of using a foreach loop, but that seems expensive and I can think of using a direction-vector approach, but that seems like it could fail in edge-cases.)
Edited by DASD - July 20, 2017 11:19:22
- jlait
- Staff
- 6219 posts
- Joined: July 2005
- Offline
I should clarify there is a fully predictable execution order. If you overwrite the same point with multiple setattrib() calls, they will overwrite in a predictable & consistent manner. (Specifically, later writes in the same elements kernel will overwrite earlier writes; and later elements will overwrite earlier elements)
This, however, is explicitly hidden during execution. point(0,) refers to the input, and there is no way to get the partially updated geometry.
Python does not have this issue as you have a handle to the actual live geometry in a python sop.
One approach I've seen done to do this in VEX is to build an array of all the newId for all the points so you can read & write to them in the array. Then when your algorithm is complete, write out the array to the points.
But ideally if you can write this as a ForAllPoints rather than a For Detail you can get more speed. Especially if your full use case is a forest of hairs rather than a single line - a single line will need O(npoints) passes so be pretty slow as a for-all-points or as a detail loop.
This, however, is explicitly hidden during execution. point(0,) refers to the input, and there is no way to get the partially updated geometry.
Python does not have this issue as you have a handle to the actual live geometry in a python sop.
One approach I've seen done to do this in VEX is to build an array of all the newId for all the points so you can read & write to them in the array. Then when your algorithm is complete, write out the array to the points.
But ideally if you can write this as a ForAllPoints rather than a For Detail you can get more speed. Especially if your full use case is a forest of hairs rather than a single line - a single line will need O(npoints) passes so be pretty slow as a for-all-points or as a detail loop.
-
- Quick Links