Jump to content

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

Share this post


Link to post
Share on other sites

Nice one Infernalspawn, we ran into this same problem on a previous show and we ended up having to make a very similar setup.

Definitely gonna have to check out the code!

Thanks!

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

ah sorry, i tried recalculate center of mass for new fracture pieces(v11) and shape too.

Thanks for sample. 12 sec for building ;)

post-5887-128092443767_thumb.png

Edited by ilay

Share this post


Link to post
Share on other sites

You can't OTL this, it's an actual plugin library, has to be compiled.

I see. So...is anybody going to compile this for Win64? :P

Edited by Netvudu

Share this post


Link to post
Share on other sites

Here's a version I built last night for someone.

Built for Houdini 11.0.460, Win64.

Can build one for Linux gcc4.1 on Redhat.

Share this post


Link to post
Share on other sites

Nice work, and a nice example to learn how to use multithreading. Thanks a lot for sharing!

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×