Solver SOP - Simple movement

   4659   18   0
User Avatar
Member
55 posts
Joined: March 2015
Offline

So im trying to develop somekind of “growing based of time” stuff, and I saw that for this kind of stuff you need to use a solver sop(seems obvious).

So to get used to the Solver SOP i tried something simple: I created 2 points in space, one is and the other is , then I created a sphere in , wired those 3 into a Solver Sop and inside of that I attached a wrangle wich looks for the position of the sphere, and if its not equal to the P of the second point, it increases it by 0.1 units in every axes (this way it will get closer to the 2nd point).

When the P of the sphere and the P of the second point will be equal, the sphere should turn green (initially it was red) and never move again.

The problem here is that even if the sphere reaches the position (on the 10th frame), it doesn't turn green, and keeps moving in the next frames…

I attached the scene so you can have a look at it.

Thanks
Edited by SteN - Sept. 3, 2016 17:48:51

Attachments:
Solver_try.hipnc (84.5 KB)

https://vimeo.com/user43100796 [vimeo.com]
User Avatar
Member
280 posts
Joined:
Offline

I wont use :
if( @P != _pB)
{
..
..

instead i replace it with:
float tolerance=.001;
if(length(_pB-@P)>tolerance
{
..
..


and now it works as it should…


best regards
Patar

Attachments:
Solver_tryMod.hipnc (77.7 KB)

User Avatar
Member
280 posts
Joined:
Offline
typo sorry

float tolerance=.001;
if(length(_pB-@P)>tolerance)
{
User Avatar
Member
55 posts
Joined: March 2015
Offline
Thank you so much.

This isnt the first time I have problems when comparing values in houdini, not gonna try again
So basically to get that to work you dont check if the two values are equal, but if the two values are more or less close?

Thanks again for your time.
Edited by SteN - Sept. 4, 2016 17:24:09
https://vimeo.com/user43100796 [vimeo.com]
User Avatar
Member
280 posts
Joined:
Offline
yes it has to do with precision …
User Avatar
Member
55 posts
Joined: March 2015
Offline
Ok perfect
https://vimeo.com/user43100796 [vimeo.com]
User Avatar
Member
4508 posts
Joined: Feb. 2012
Offline
And if you want to squeeze some performance use:

if(distance2(_pB, @P) > tolerance*tolerance)
...
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
User Avatar
Member
280 posts
Joined:
Offline
nice tips….
User Avatar
Member
55 posts
Joined: March 2015
Offline
pusat
And if you want to squeeze some performance use:

if(distance2(_pB, @P) > tolerance*tolerance)
...


Why should this give better performance?
Edited by SteN - Sept. 5, 2016 11:46:37
https://vimeo.com/user43100796 [vimeo.com]
User Avatar
Member
280 posts
Joined:
Offline
in programming world some operation is faster than the other its due to how to computer does calculation…like in assembly shl and shr is alot faster than multiplication..
u can use performance monitor if you r curious about the speed of nodes in your scene which slowing your computation which can be optimize…

besides length(_pB-@P) is 2 operation distance2(_pB, @P) is one…

im not realy up to optimizing my code unless its reaaaaally slow…
i often ended up creating my own stuffs from scratch if thats the case… stuffs like flip volume source…
i like to create my own since i will only use stuffs that i really need…
User Avatar
Member
4508 posts
Joined: Feb. 2012
Offline
SteN
pusat
And if you want to squeeze some performance use:

if(distance2(_pB, @P) > tolerance*tolerance)
...


Why should this give better performance?

Because sqrt is slow. Avoid it if you can.
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
User Avatar
Member
55 posts
Joined: March 2015
Offline
Yes ok, I got it.

After implementing this I came up with a new issue, wich is not realated to this last change.

So if you take a look into the code you will see what Im trying to do:

-On frame 1 I record the position of the target, wich is the blue point you can see in the 2nd screenshot, and I also calculate what I have called _moveStep, wich basically given an amount of frames, this should be the amount wich the sphere has to move on each frame, to reach the target in that amount of frames.

-Then for every next frame (if @Frame > 1) I do the check and then move along the Dir Vector (vector pointing to the target), wich you can see in the 2nd screenshot too (the red one).

The problem here is that _moveSteps changes in future frames even if I calculate it only on Frame 1.

In the 3rd frame you can see the result of all the printf I wrote to check where the varaible was being modified, and again, for some reason it changes even if I calculate it only on Frame 1.



Edited by SteN - Sept. 6, 2016 06:04:26

Attachments:
Code.jpg (209.2 KB)
Screenshot_1.jpg (178.7 KB)
outputs.jpg (65.2 KB)
Solver_try_error.hipnc (87.3 KB)

https://vimeo.com/user43100796 [vimeo.com]
User Avatar
Member
55 posts
Joined: March 2015
Offline
Bump please.
https://vimeo.com/user43100796 [vimeo.com]
User Avatar
Member
280 posts
Joined:
Offline
The way you set it up
_moveStep will never get a value after frame 1
coz that variable is only exist on that particular point wrangle
thats why if you look at your snapshot once it get to frame 2 the value no longer 1/48 ( which is 0.0208333)
instead it get whats in the memory at that pointer variable which some random number

as usual here i attached the fix…

sorry about the delay i was quite bussy…
got the time when my pc is simulating heheh got nothing better to do than… this stuffs..

best regards
Patar

Attachments:
Solver_try_errorFix.hipnc (85.6 KB)

User Avatar
Member
55 posts
Joined: March 2015
Offline
Thank you so much Patar

So the timeshift nodes are used to make the wrangle cook only on the first frame?
https://vimeo.com/user43100796 [vimeo.com]
User Avatar
Member
280 posts
Joined:
Offline
timeshift to always get the object state at frame 1..
User Avatar
Member
55 posts
Joined: March 2015
Offline
Yes ok, thank you

After that I added stuff to make the sphere follow the target even if its position is modified, even interactively.

Btw I did this thing because Im trying to develop another thing, and this should be the “foundamental” part of it…hope I can get it to work entirely

I post the file for reference.


Thanks again!

EDIT:
If I try to make a line between the two points this is what I get http://prntscr.com/chlhva [prntscr.com]
To solve this I used an object merge and get the points to another GEO node and then create the line, and that fixed it…I guess that “glitch” is because by the timeshift nodes…?
Edited by SteN - Sept. 13, 2016 13:37:57

Attachments:
Follow_target.hipnc (95.9 KB)

https://vimeo.com/user43100796 [vimeo.com]
User Avatar
Member
280 posts
Joined:
Offline
nope its because its somehow creating a nurbs curve… im also dont get that behavior but if u add a third point then it'll create a curved line…maybe its a bug
User Avatar
Member
280 posts
Joined:
Offline
after a little more digging its because:
geo1 > render tab > display as>subdivision surface / curves

it will get normal if its set to: display as> full geometry

see the attached file..

Attachments:
Follow_targetMod.hipnc (97.0 KB)

  • Quick Links