ForEach Sop Applied to Points

   7004   8   0
User Avatar
Member
3 posts
Joined: 1月 2011
Offline
Hi guys,

When I check “apply to points” parm on in the ForEach Sop with “Each Attribute Value” chosen, I see some points swap their point numbers to each other.
Of course this doesn't happen if I write point attribute value as “$PT” in the AttributeCreate Sop. But even when I change the attribute value to “rand($PT*324)”, the order of point numbers don't seem to follow the attribute values. Just wonder why the swapping occurs when I use the “apply to points” parameter.

Thanks in advance, hope see some threads

Sewang

Attachments:
sepic3.jpg (35.5 KB)
sepic2.jpg (36.7 KB)
sepic1.jpg (36.3 KB)

User Avatar
Member
390 posts
Joined: 1月 2012
Offline
in trying to find out what was going on, i found some more weird behavior. i set up mostly the same network, but in my file, toggling apply to points also changes the attributes that were being fed into the for each sop. this makes no sense to me, but before i shout bug.. maybe someone with more knowledge could take a look?

toggling apply to points, while looking at the details view sorted by attribute1, the attributes go from 2, 2, 4, 5, 5, 6, 7.. to 2, 2, 4, 5, 6, 7, 9… how can this be? the attribute is created before the foreach sop.. why would the foreach sop ever change attributes?

Attachments:
strange.hipnc (70.4 KB)

.
User Avatar
Member
390 posts
Joined: 1月 2012
Offline
also in that file, leaving apply to points checked and changing the tolerance from < 1 to 1 (attribute1 are ints) yields the same result.
.
User Avatar
Member
8795 posts
Joined: 7月 2007
Offline
the way how For Each Sop works for Attribute values is a little tricky

it will loop through all points/primitives in order and for each attribute value it will gather all primitives/points with the same value within tolerance and process them in the same iteration
then it will merge results from all iterations as a separate geometries into one so this will change primitive/point order for all cases (except for case when you loop over individual primitives/points in original order)

it is not changing the value of the attribute though, it may seem so since it gets reordered

so what you can do is create integer attribute holding original primitive/point numbers with $PR or $PT prior to for loop and then after the loop, sort it back according to that attribute using Sort SOP
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
390 posts
Joined: 1月 2012
Offline
cool, but my point is that the foreach is changing the attribute values. theyre not just reordered. if you open the details view, sorted by attribute1 in my file, not by point number, the values are 2, 2, 4, 5, 5…. uncheck apply to points, and yes the order of the points change, but resort by attribute1 in the details view and you get 2, 2, 4, 5, 6. the foreach is indeed changing the values of point attributes.
.
User Avatar
Member
3 posts
Joined: 1月 2011
Offline
Thanks guys,

Inside the Voronoi Fracture Sop, there are a bunch of ForEach Sop Nodes, actually one of which is being used in the way that you've just mentioned(using Sort Sop). And yeah, when I set the tolerance parm to 0, it rarely seems to have the swapping anymore. Still I see the swapping occurring sometimes.

Zack, I don't think they're changing. For example, if you keep track of the attribute value of point 5, you'll see the same value for point 5 even after ForEach sop (applied to points) applied; swapping occurred.
User Avatar
Member
390 posts
Joined: 1月 2012
Offline
i dont understand this. irregardless of point numbers, one case has 2 points with the value of 5 while the other case has 1 point with the value of 5.
.
User Avatar
Member
390 posts
Joined: 1月 2012
Offline
keep in mind you have to change the tolerance to 1 to see this result.
.
User Avatar
Member
1 posts
Joined: 12月 2010
Offline
Yes, when the tolerance change to 1 in the file, the the number of points with the value of 5 for attribute1 changes from 1 to 2.
  • Quick Links