Jump to content

Hash?


Macha

Recommended Posts

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

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

Link to comment
Share on other sites

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

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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

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...