Infernalspawn Posted August 3, 2010 Share Posted August 3, 2010 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! 1 Quote Link to comment Share on other sites More sharing options...
Ratman Posted August 3, 2010 Share Posted August 3, 2010 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! Quote Link to comment Share on other sites More sharing options...
goldleaf Posted August 3, 2010 Share Posted August 3, 2010 Awesome! I was trying to do something like this myself using python a few weeks ago. Thanks a ton! Quote Link to comment Share on other sites More sharing options...
Netvudu Posted August 3, 2010 Share Posted August 3, 2010 this is very useful...will it become and .otl for those of us who are subpar coders? Quote Link to comment Share on other sites More sharing options...
Ratman Posted August 3, 2010 Share Posted August 3, 2010 You can't OTL this, it's an actual plugin library, has to be compiled. Quote Link to comment Share on other sites More sharing options...
Matt_K Posted August 4, 2010 Share Posted August 4, 2010 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. Quote Link to comment Share on other sites More sharing options...
ilay Posted August 4, 2010 Share Posted August 4, 2010 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. Quote Link to comment Share on other sites More sharing options...
Infernalspawn Posted August 4, 2010 Author Share Posted August 4, 2010 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 Quote Link to comment Share on other sites More sharing options...
ilay Posted August 4, 2010 Share Posted August 4, 2010 (edited) ah sorry, i tried recalculate center of mass for new fracture pieces(v11) and shape too. Thanks for sample. 12 sec for building Edited August 4, 2010 by ilay Quote Link to comment Share on other sites More sharing options...
Netvudu Posted August 4, 2010 Share Posted August 4, 2010 (edited) 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? Edited August 4, 2010 by Netvudu Quote Link to comment Share on other sites More sharing options...
Ratman Posted August 4, 2010 Share Posted August 4, 2010 I see. So...is anybody going to compile this for Win64? What build? Quote Link to comment Share on other sites More sharing options...
Ratman Posted August 4, 2010 Share Posted August 4, 2010 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. Quote Link to comment Share on other sites More sharing options...
Ratman Posted August 4, 2010 Share Posted August 4, 2010 Dahr, forgot to press attach SOP_Centroid.rar Quote Link to comment Share on other sites More sharing options...
pclaes Posted August 5, 2010 Share Posted August 5, 2010 Nice work, and a nice example to learn how to use multithreading. Thanks a lot for sharing! Quote Link to comment Share on other sites More sharing options...
helium Posted August 5, 2010 Share Posted August 5, 2010 that's great! Just compiled and it works very well:) Quote Link to comment Share on other sites More sharing options...
graham Posted August 5, 2010 Share Posted August 5, 2010 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. Quote Link to comment Share on other sites More sharing options...
pagefan Posted August 5, 2010 Share Posted August 5, 2010 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 Quote Link to comment Share on other sites More sharing options...
Infernalspawn Posted August 5, 2010 Author Share Posted August 5, 2010 (edited) @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 August 5, 2010 by Infernalspawn Quote Link to comment Share on other sites More sharing options...
graham Posted August 5, 2010 Share Posted August 5, 2010 (edited) 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 August 5, 2010 by graham Quote Link to comment Share on other sites More sharing options...
graham Posted August 5, 2010 Share Posted August 5, 2010 (edited) 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 August 5, 2010 by graham 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.