Macha Posted January 5, 2011 Share Posted January 5, 2011 (edited) Does anybody know of a way to get/implement a fast hash function for points? I have various streams of pops merging and want the particles to have unique id. $PT doesn't work because the particles are born and die away irregularly and I want the ids to be persistent. I could randomize some values and hope for the best I suppose but I wonder if there is a proper way to do this. Edited January 5, 2011 by Macha Quote Link to comment Share on other sites More sharing options...
anim Posted January 5, 2011 Share Posted January 5, 2011 i suppose you are doing this after simulation with cached particles in SOPs each particle sim has detail attribute "nextid" which contain "id" which will be used on next born particle so if you are merging multiple sims together, just add sum of "nextid" attributes from all already merged sims to "id" of all particles in current sim and that way offseting those ids to unique values or you can add nextid-1 to be more exact, but it doesn't really matter Quote Link to comment Share on other sites More sharing options...
Macha Posted January 6, 2011 Author Share Posted January 6, 2011 (edited) Thanks for the reply but I miss something there. I still get multiple identical ids. The particles may also die away over the course of the animation so I am not sure how it would ensure uniqueness. The $NEXTID also changes from frame to frame, so how can we use it in an expression and retain a unique, persistant id? (by the way, having a hash function would be useful in other scenarios as well (changing $NPT and chops!)) id.hip Edited January 6, 2011 by Macha Quote Link to comment Share on other sites More sharing options...
anim Posted January 6, 2011 Share Posted January 6, 2011 as i said, i assume that all sequences are cached, so you can take nextid from the last frame otherwise it would be difficult and you need to add nextid before merge so for first stream nothing for 2nd stream id+nextid1(from last frame) for 3rd stream id+nextid1+nextid2 . . . or you can add high mumber to second stream ids, 2x high number to third and so on that number should be higher than potential particle count of each stream or maybe easier and doesn't need caching convert ID to float then add 0.1 for second stream, 0.2 for third, ..., 0.9 for 10th or if you need more use lower steps then merge all together your ids will be unique you can multiply them by 10 now and convert back to integer or never convert to float, but then the math would be *10 for first stream *10+1 for second . . . *10+9 for 10th Quote Link to comment Share on other sites More sharing options...
anim Posted January 6, 2011 Share Posted January 6, 2011 oh and the example file ids_fix.hip Quote Link to comment Share on other sites More sharing options...
Macha Posted January 6, 2011 Author Share Posted January 6, 2011 Thanks Thomas. I tried the "add a high number" before but I have huge amounts of particles and they often overlap and I need to go hunting pointcounts, and I need to create extra attributes and update them throughout my network. It works but it's all messy after a while. I'll keep thinking about your nextid idea. Obviously you have thought about it before and know more about it than me! Quote Link to comment Share on other sites More sharing options...
anim Posted January 6, 2011 Share Posted January 6, 2011 I have never needed that before, it's just a few ideas I am starting to like the approach I posted in the example, because it doesn't require caching and even after merging you can tell which particle is from which stream and they have unique ids but it depends on what you need it for Quote Link to comment Share on other sites More sharing options...
Macha Posted January 6, 2011 Author Share Posted January 6, 2011 What I done before, if you are interested, is to sum the id and a number unique to the popnet, and then generate a random number out of that, multiply it by something large and create an integer attribute out of it. It kind of works but with huge pointcounts you get a few id overlaps. Quote Link to comment Share on other sites More sharing options...
anim Posted January 6, 2011 Share Posted January 6, 2011 yes but with method in that file you should get completely unique ids for each particle and you don't need to add huge numbers unless i didn't really get what you are trying to do 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.