HDK question XOR/main compute function

   1531   1   0
User Avatar
Member
14 posts
Joined: Oct. 2017
Offline
Hello!

I'm starting to learn hdk Houdini and look at the examples in toolkit folder. So I have two question, I found two examples files: 1. OBJ_WorldAlign.C, 2. OBJ_Shake.C… So, OBJ_WorldAlign file has function cookMyObj, but OBJ_Shake does't have, why? and what is main compute function in Houdini rules?

And second question.. in file “OBJ_Shake.C” I found bit operation XOR “seed ^= 0xdeadbeef;”

seed = (int)OPgetDirector()->getChannelManager()->getSample(t);
jx *= 2*SYSfastRandom(seed) - 1.0;

seed ^= 0xdeadbeef;
jy *= 2*SYSfastRandom(seed) - 1.0;

seed ^= 0xfadedcab;
jz *= 2*SYSfastRandom(seed) - 1.0;

what for this operation? could you explain to me, please! If I do it without this operation, what's happen?
Thanks!

https://www.sidefx.com/docs/hdk/_o_b_j___world_align_8_c_source.html [www.sidefx.com]

https://www.sidefx.com/docs/hdk/_o_b_j___shake_8_c_source.html [www.sidefx.com]
Edited by rash - Feb. 20, 2018 08:40:58
User Avatar
Member
7737 posts
Joined: Sept. 2011
Offline
The xor with the bitmask ‘deadbeef’ or ‘fadedcab’ is a bit of programmer humor, but it's purpose is to change the seed without losing entropy.

If the xor part was skipped, then the seed would be the same for all three axes, and result in a shaking that is along an xyz diagonal line, instead of the noisy space intended.
  • Quick Links