vex can't update detail attribute when referencing itself.

   2384   4   0
User Avatar
Member
143 posts
Joined: March 2014
Offline
Why doesn't this vex code work? I'm simply trying to increment a detail float value by 1 for every frame irrespective of what frame it's on. "currZrot" should always only increment when the frame is incremented (not decremented)

attribute wrangle set to run over "Detail".
"currZrot" is a detail attribute.

float curvalue = detail(0,"currZrot",0);
setdetailattrib(0,"currZrot",curvalue+1, "set");

Attachments:
Capture.PNG (28.2 KB)

User Avatar
Member
8506 posts
Joined: July 2007
Online
- It seems to work fine, assuming you are running it inside of the Solver SOP since you are expecting that geometry is fed back each frame to increment previous value

- also since you are running it as in Detail mode and also creating detail attrib you can just do
f@curvalue += 1;
for the same effect
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
143 posts
Joined: March 2014
Offline
this does work inside of the solver sop, but when attempting to change the condition while running, it doesn't seem to work. I need to conditionally update this attribute depending on another attribute:

if(detail(0,"spin",0)==1)
{
    f@currZrot += 1;
}

if I stop and reset the simulation, it works, but not while running if I change the "spin" attribute to "0"
Edited by caesar - March 6, 2022 13:02:31

Attachments:
Capture.PNG (63.9 KB)

User Avatar
Member
8506 posts
Joined: July 2007
Online
You are taking the spin attribute value from the first input which is geo from the previous frame in your case so that will always have spin value from the start frame unless changed within the solver

You can either sample the first input geo of the solver itself for the spin value

Or instead of operating directly in previous frame geo just copy attribs you want to preserve from previous frame geo onto live input geo yo further modify them
This will leave all other attributes live and updating from input
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
143 posts
Joined: March 2014
Offline
Awesome - thank you
  • Quick Links