For loops number of vertices not updating

   2673   7   0
User Avatar
Member
7 posts
Joined: 10月 2019
Offline
I had some issues when using an attribute wrangle and looking for number of vertices.
I noticed this does not always update, and messes up my whole loop, kind of annoying.

Basically, if you have an attribute wrangle, with a simple
i@nverts = @numvtx;
And you change the for loop input, reset the cache. It will keep the info from the previous input.
It will not change when the code is re-executed.
It will only update when the code is changed. For example
i@nverts = @numvtx+0;

This is frustrating, in the end I had to store the vertex count in a prim attribute, before entering the for loop.
Is there a way to fix this?
I tested this in: 18.5.462 and 18.5.351
Edited by LauraB - 2021年2月19日 05:13:28
User Avatar
Member
471 posts
Joined: 7月 2005
Offline
Hi,

it looks strange, but nvertices(input) works for me.
User Avatar
Member
7 posts
Joined: 10月 2019
Offline
Hey,

Thank you that works.

I did a few more testing with @numvtx, cause I'm too curious.
If I connect the attribute wrangle, from begin to end, it works fine, sometimes.
But if I disconnect it from the end, so it's only connected to input, it only works right when the attribute wrangle is not set to detail.
For Loop is set to input.
Attribute wrangle set on Primitives has:
i@vertnum = nvertices(0);
i@vertnum2 = @numvtx;
These work as intended.

But the attribute wrangle set to Detail:
i@vertnumdetail = @numvtx;
Does not update when the for loop input is changed.

Strange.. I wonder why
Edited by LauraB - 2021年2月21日 05:04:00
User Avatar
Member
471 posts
Joined: 7月 2005
Offline


There is also another aspect. nvertices(0) gives you the total vertex count (as @numvtx) in detail mode, but if you are in (point, vertex, prim) mode, @numvtx returns the vertex number of the local primitive (@primnum), which should be equivalent to the function primvertexcount(0, @primnum). @primnum is defined in (point, vertex and prim) mode, but there might be several different primitives for a point (@primnum seems to take the last element of the primitive list ~ pointprims(0, @ptnum)), where each vertex has only one primitive (like the primitives themselves of course).
Edited by Aizatulin - 2021年2月22日 12:48:52
User Avatar
Member
7 posts
Joined: 10月 2019
Offline
Thanks!
That was not what I meant tho.

https://ibb.co/gy5y4sT [ibb.co]
If you look at this image, when I switch the input of the for loop, I'm just wondering why
nvertices(0) //works
@numvtx //doesn't update
But it will update normally when the attribute wrangle is connect to the end of the for loop.
In my case, I don't want it connected to the end.

I think it's strange that it doesn't update, though
@numpt, @numprim
work fine in the same situation.
Only @numvtx messes up when the input is updated.
Even resetting the for loop doesn't work.
Re executing the code, doesn't work.
You need to update the code before @numvtx updates correctly.
Edited by LauraB - 2021年2月24日 05:19:19
User Avatar
Member
856 posts
Joined: 10月 2008
Offline
I get the same problem and it even doesn't react to upstream changes (just a box and using different axis divisions). I'd submit it as a bug.
--
Jobless
User Avatar
Member
471 posts
Joined: 7月 2005
Offline
Hi,

is it always updating, if you are using @numvtx in (point, vertex or prim) context?
For me this always works (18.5.408), but here @numvtx represents the local vertex count for each primitive.

In detail mode it is not working (as you described). In detail @numvtx is the global vertex count. It looks like a bug but on the other other side it is quite dangerous, to use the same variable name for different meanings. There should something like @totalnumvtx (just my opinion of course).
User Avatar
Member
7 posts
Joined: 10月 2019
Offline
It all works normally like yours, except detail.

That makes sense.
Welp, I guess I will just avoid using @numvtx in detail then, and just use nvertices().

Thanks!
  • Quick Links