Jump to content

Get the substep number inside SOP Solver


sergio

Recommended Posts

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.  

Link to comment
Share on other sites

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~

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

 

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 

Link to comment
Share on other sites

 

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? :)

Link to comment
Share on other sites

 

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 by sergio
Link to comment
Share on other sites

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 by pezetko
  • Like 3
Link to comment
Share on other sites

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()?

Link to comment
Share on other sites

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 by Skybar
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...