Jump to content

Centroid - SOP


Recommended Posts

over the time a came across an issue a couple of times: generating centroids for primitives, prim- and point-groups.

doing that with the for-each-sop may take ages so I set myself a little project, writing a sop that does that for me .

This is the result, a Centroid-SOP, it supports generation of centroids from primitives, prim-groups and point-groups.

it uses multithreading and is, compared to an for-each sop solution, quite fast ;)

On a

- Linux Fedora

- Houdini 10.0.707

- 100x100 cubes

- 8 x 2.83GHz (Xeon) 8GB RAM

| Just Prims | Prim Groups | Point Groups

| 60k Prims | 10k Groups | 10k Groups

-------------------------------------------------------------

For-Each | > 9.00 min ©| > 7.00 min ©| > 69 min (canceled)

Centroid-SOP | 128.12 ms | 25.05 s | 33.60 s

Centroid-SOP (MT) | 106.75 ms | 9.62 s | 12.87 s

I thought I share the result, you can get the code from gitorious

http://gitorious.org/centroid-sop

some things are left todo:

- some windows testing is required,so far i've tested it on mac & linux

- H11 tests, so far i've only tested it propperly on H10

- maybe some primitive-attribute transfer-stuff to the generated centroids, i'm not sure yet what might be usefull ;)

please leave suggestions & comments!

Infernal!

post-1388-128087392583_thumb.png

  • Like 1
Link to comment
Share on other sites

Hey guys, (Hiya Rick!)

Thanks Infernal - a very useful tool indeed.

As Rick mentioned above, we've had a similar tool made which has become indispensable - I find I'm using it a lot these days!

Perhaps for a future update, you might think of extracting orientations too?

Matt.

Link to comment
Share on other sites

Hi

Infernalspawn, thanks a'lot!

At windows xp sp3 win32(compiled), i tried to calculate for Bullet solver...in attachment

Also can you post sample of this node's work or similar with examples centroid expression(Hhelp)?

Sorry for that, i still learn houdini workflow and newbie too. :)

post-5887-128091684515_thumb.png

Link to comment
Share on other sites

Hi Ilay,

from your attached image i dont understand what you want to do ;), ... can you explain a bit more, or attach a file ?

What this tool does is: generating a single point for either each primitive, point- or prim-group.

thats it ;)

i've attached the file that i used for the performance test, if you enable point display you could see the generated points.

Infernal

performanceTest.hip

Link to comment
Share on other sites

I compiled it yesterday however changing the technique parameter doesn't seem to work for me. No matter what it always uses the Bounding Box method. Haven't had a change to look at the code though and see what's up.

Link to comment
Share on other sites

Hi Infernal,

very nice and useful SOP! Compiled almost like a charm on linux (except for having to make the sop/node/help directory in houdini10.0)It does compile against houdini 11, though with some warnings:

/opt/hfs11.0.462/toolkit/include/VM/VM_SSEFunc.h: In function ‘__vector(2) long long int vm_splats(uint32, uint32, uint32, uint32)’:

/opt/hfs11.0.462/toolkit/include/VM/VM_SSEFunc.h:238:12: warning: dereferencing type-punned pointer will break strict-aliasing rules

Since it is some sse warning it might be my old hardware (only sse and sse2 instructions in the cpu here)

One question: when I have a planer primitive shouldn't the centroid be on the surface of that primitive? See attached hip-file.

Cheers,

Hans

centroid.hip

Link to comment
Share on other sites

@pagefan: your problem is the same that graham mentioned, no matter what technique (barycenter/bbox/points) you choose it always uses the bbox. ... weird

i'll see that i fix that!

Infernal

[edit] ... found the error, ... something that got lost when doing the cleanup ;), ... i'll do some last tests and put it on gitorious tonight

Edited by Infernalspawn
Link to comment
Share on other sites

After looking at the code it looks like you aren't actually ever checking the method against what's is chosen in the UI. You set the method member variable to 0 in the constructor, but never again modify it or call getMethod(). Adding method = getMethod(time); near the top of cookMySOP() makes it work correctly. Barycenter works good for me but Points is all over the place when not using groups, so I'll have to take a look at that as well.

Edited by graham
Link to comment
Share on other sites

After looking at it the points technique code it seems the problem is that what you are creating the UT_Vector3 center; in many methods it is not being properly initialized. This is fine for the bbox and barycenter methods because you are assigning another UT_Vector3 to that variable, however when doing the points method you just start adding vectors to that and when it isn't initialized the initial values are unpredictable so the result is incorrect. Properly initializing it to 0,0,0 fixes the problems with that.

Edited by graham
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...