sergio Posted April 20, 2015 Share Posted April 20, 2015 Hello everyone, I am trying to do some calculation inside a sop solver and it has quite substeps (goes up to 1000s) but i need to know which substep i am at currently in a attribwrangle node. is there a way to get "substep" as an integer? like a foreach would give the each number. thanks in advance. Quote Link to comment Share on other sites More sharing options...
ciliath Posted April 20, 2015 Share Posted April 20, 2015 left click substeps --> copy parameter. in sop solver create attribute vop, in the vop create a parameter. now click back onto your attribute vop, left click the newly create parameter 'param' and "paste copied relative reference". How i would go about it with vops, dont know how to get a value from channel with wrangle nodes though :/ hope it helped~ Quote Link to comment Share on other sites More sharing options...
eetu Posted April 21, 2015 Share Posted April 21, 2015 Does that really work? Sounds like it would only give you the number of timesteps per frame, not the current timestep? You could try and deduce it from the fractional frame $FF, but it's in float so tread with caution. timestep = ($FF-$F)*timesteps or something like that. Quote Link to comment Share on other sites More sharing options...
Skybar Posted April 21, 2015 Share Posted April 21, 2015 In a wrangle (inside Solver SOP): i@substep_number += int(rint((X*Y)*@TimeInc)); Where X = FPS and Y = total number of substeps, so like: i@substep_number += int(rint((25*1000)*@TimeInc)); Quote Link to comment Share on other sites More sharing options...
sergio Posted April 21, 2015 Author Share Posted April 21, 2015 In a wrangle (inside Solver SOP): i@substep_number += int(rint((X*Y)*@TimeInc)); Where X = FPS and Y = total number of substeps, so like: i@substep_number += int(rint((25*1000)*@TimeInc)); Thank you David that works like a charm. Felix and eetu thank you too for answering Quote Link to comment Share on other sites More sharing options...
sergio Posted April 21, 2015 Author Share Posted April 21, 2015 (edited) BTW thanks to you guys i was able to complete my quicksort algorithm. Edited September 8, 2019 by sergio Quote Link to comment Share on other sites More sharing options...
eetu Posted April 21, 2015 Share Posted April 21, 2015 In a wrangle (inside Solver SOP): i@substep_number += int(rint((X*Y)*@TimeInc)); Where X = FPS and Y = total number of substeps, so like: i@substep_number += int(rint((25*1000)*@TimeInc)); Just wondering, isn't that right side always equal to 1? Or am I missing something? Quote Link to comment Share on other sites More sharing options...
sergio Posted April 21, 2015 Author Share Posted April 21, 2015 (edited) Just wondering, isn't that right side always equal to 1? Or am I missing something? On a second look yes. And it goes from 1 -> ( total substeps / 2 ) for first frame of simulation . But hey if it works and i don't know why, i'm not gonna question it Edited April 21, 2015 by sergio Quote Link to comment Share on other sites More sharing options...
pezetko Posted April 21, 2015 Share Posted April 21, 2015 (edited) This vex expression goes from 0 to 49 for each frame for chf("substep") = 50 (number of sub steps per frame): i@curr_substep = floor((f@Frame - floor(f@Frame))*chf("substep")); If you want to increment sub step from 0 to $RFEND*chf("substep") then use this one (chf("startframe") and chf("substep") are SOP Solver parameters): i@curr_substep = floor(f@Frame-chf("startframe"))*chf("substep")+floor((f@Frame - floor(f@Frame))*chf("substeps")); Edited April 21, 2015 by pezetko 3 Quote Link to comment Share on other sites More sharing options...
jkunz07 Posted April 21, 2015 Share Posted April 21, 2015 For completion you can use the expression: 1/stamp("..", "TIMESTEP", 1/$FPS)/$FPS in a parameter to get the number of subteps this would be an alternative to doing a channel reference to the substeps parameter on the dopnet. pezetko: what is the advantage to using chf() as opposed to ch()? Quote Link to comment Share on other sites More sharing options...
pbarua Posted April 22, 2015 Share Posted April 22, 2015 pezetko: what is the advantage to using chf() as opposed to ch()? It's just explicit cast. ch() will use implicit cast and give you little warning. Quote Link to comment Share on other sites More sharing options...
Skybar Posted April 22, 2015 Share Posted April 22, 2015 (edited) Just wondering, isn't that right side always equal to 1? Or am I missing something? Well yes, it does equal to 1. But since it evaluates at every substep we can simply += to add it to the previous step, so it will be incremented by 1 for each substep . There might be a better way though, it's just what I came up with. Edit: Ah I get what you mean. I just tried "i@substep_number += 1;", and it seems to work just as well haha.. Oh well. Edit2: Alright, so without adding to the previous step we could just find the current substep at once. So: i@substep_number = int(((@Frame * X) - X) + 1); Where X = total number of substeps. If you rather it starts at 0 at frame 1 you could just skip that last addition. If you want it to restart at 0 at every frame as well, you could throw in a modulus like: i@substep_number = int(((@Frame * X) - X) % X); Edited April 22, 2015 by Skybar 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.