tony Posted July 19, 2013 Share Posted July 19, 2013 Hi, I've got the following code which mimicks a trail sop: SOP_TrailIfExists::cookMySop(OP_Context &context){fpreal t = context.getTime();fpreal f = context.getFloatFrame();fpreal new_t;const GU_Detail *current_frame_gdp;const GU_Detail *trail_frame_gdp;GU_Detail blank_gdp;GU_Detail trail_gdp;OP_Context trail_context = context;//get trail length and increment amount from UIfpreal len = LEN(t);fpreal inc = INC(t);// Lock the input contextif (lockInput(0, context) >= UT_ERROR_ABORT)return error();//get the geometrycurrent_frame_gdp=inputGeo(0, context);//start copyinggdp->copy(blank_gdp, GEO_COPY_START);//copy current framegdp->copy(*current_frame_gdp, GEO_COPY_ADD);//unlock the contextunlockInput(0);//do the trailfor(int i = 1;i<len;i++){// This is the frame number we want to evaluatenew_t = f-(i*inc);// The context takes seconds, not frame, so we convert.new_t = OPgetDirector()->getChannelManager()->getTime(new_t);// Adjust our cooking context to reflect thistrail_context.setTime(new_t);// Lock the input contextif (lockInput(0, trail_context) >= UT_ERROR_ABORT)return error();//get the geometrytrail_frame_gdp=inputGeo(0, trail_context);// copy the geometrygdp->copy(*trail_frame_gdp, GEO_COPY_ADD);}//end copying geometrygdp->copy(blank_gdp, GEO_COPY_END);//unlock the inputunlockInput(0);return error();}[/CODE]I'd like to be able to make it run on multiple threads, but I'm a bit unsure about how to go about it. I've had a look at:http://www.sidefx.co...ingChildThreadswhich seems to suggest I need to wrap it all up into a class and use the UT_ThreadedAlgorithm THREADED_METHOD options. But then I looked at the slides in: $HFS/toolkit/slides/HDK12_Intro.pdfand they mention the UTparallelFor option. My main questions are:1. Which one should I go for?2. Will I need to wrap all of my code into a class or can I just put the for loop into a seperate function and thread that function?Cheers,Tony Quote Link to comment Share on other sites More sharing options...
Guest mantragora Posted July 19, 2013 Share Posted July 19, 2013 (edited) If I remember correctly PDF mentioned both methods. It wasn't specified why one is better over other so I suppose both are equally good. PS. I have somewhere example of threaded code, not made by me, but I can't find it now. Edited July 19, 2013 by mantragora Quote Link to comment Share on other sites More sharing options...
graham Posted July 20, 2013 Share Posted July 20, 2013 I'm skeptical that this could actually be multithreaded. Houdini doesn't really support threaded network cooking which is essentially what this could would be doing. I suppose it's worth a shot, but I wouldn't expect any gains and there might even be some crashing. 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.