Jump to content

Slow geometry creation


Recommended Posts

Hi,

I want to export my particles from maya to houdini to use it in mantra. Now I wrote an exporter which will export a simple particle file format. Then I start a houdini standalone which reads this file and crates a .geo file. At the moment it works fine, but it is really extremly slow. I have about 145000 particles. These are written from maya in less than a second and the creation of a houdini .geo file taks more than 5 minutes! This leads me to the conclusion that there must be something wrong with my code. I do the following:

 GU_Detail	gdp;
 GU_PrimParticle *particle;

 int defaultId = -1;
 GB_AttributeRef idAttr = gdp.addPointAttrib("id", sizeof(int), GB_ATTRIB_INT, &defaultId);

 UT_Vector3 vel(1,2,3);
 GB_AttributeRef velAttr = gdp.addPointAttrib("v", sizeof(UT_Vector3), GB_ATTRIB_VECTOR, &vel);

 float pscale = 1.234;
 GB_AttributeRef scaleAttr = gdp.addPointAttrib("pscale", sizeof(float), GB_ATTRIB_FLOAT, &pscale);

 particle = (GU_PrimParticle *)GU_PrimParticle::build(&gdp, numParticles);


 int sizeId = 0;
 for( uint i = 0; i < numParticles; i++)
 {
	uint index = i * 3;
	particle->getVertex(i).getPt()->setPos(posList[index], posList[index+1], posList[index+2]);
	particle->getVertex(i).getPt()->setValue<UT_Vector3>(velAttr, UT_Vector3(velList[index],velList[index+2],velList[index+2]));
	particle->getVertex(i).getPt()->setValue<float>(scaleAttr, sizeList[sizeId++]);
 }

First I create an GU_Detail with the necessary points and attributes. The data is read from the file in posList, velList and sizeList. And the loop takes a long time. It would be great if there would be a faster way to assign the values to the points. Without the attributes it takes about 40sec with both attributes, more than 5 minutes.

Thanks for any tips.

haggi

Link to comment
Share on other sites

Guest xionmark

 GU_Detail	gdp;
 GU_PrimParticle *particle;

 int defaultId = -1;
 GB_AttributeRef idAttr = gdp.addPointAttrib("id", sizeof(int), GB_ATTRIB_INT, &defaultId);

 UT_Vector3 vel(1,2,3);
 GB_AttributeRef velAttr = gdp.addPointAttrib("v", sizeof(UT_Vector3), GB_ATTRIB_VECTOR, &vel);

 float pscale = 1.234;
 GB_AttributeRef scaleAttr = gdp.addPointAttrib("pscale", sizeof(float), GB_ATTRIB_FLOAT, &pscale);

 particle = (GU_PrimParticle *)GU_PrimParticle::build(&gdp, numParticles);


 int sizeId = 0;
 for( uint i = 0; i < numParticles; i++)
 {
	uint index = i * 3;
	particle->getVertex(i).getPt()->setPos(posList[index], posList[index+1], posList[index+2]);
	particle->getVertex(i).getPt()->setValue<UT_Vector3>(velAttr, UT_Vector3(velList[index],velList[index+2],velList[index+2]));
	particle->getVertex(i).getPt()->setValue<float>(scaleAttr, sizeList[sizeId++]);
 }

Hi Haggi,

It doesn't make sense for the position and attribute assignments to take that long, there must be something else wrong. A couple of questions.

1) Are you sure the delay is happening in this loop? Have you added print statements to verify that the delay is in this loop and the values you are assigning are correct? Are you sure the delay is not related to your import code?

2) If you want to merely read Maya particles to be rendered in mantra, you don't have to create a particle system, merely create points and then assign position and attributes, that's all mantra needs. You can assign shading as with any point set, or surface it, volumize it, etc. Points are just points.

--Mark

Link to comment
Share on other sites

Thanks Mark,

thats a good idea, points are points. This could be much more efficient.

I remembered that I read somewhere that particles are created as a linked list and that access of particles in such a loop is expensive ( what I prooved this way). Then I tried another approach where I simply create a GEO_Point first and do a particle->appendParticle(). This now works fine, the longest time at the moment is the saving as .geo file, I think it will be still faster as soon as I write .bgeo files.

Link to comment
Share on other sites

  • 3 weeks later...

Now I have an exporter from maya to geo/bgeo files based on a standalone converter.

It seems that a Houdini Standalone only works with exactly the same Houdini version that was used to compile the tool. e.g. I compiled it with 11.0.477 and it crashed with 11.0.422.

Is this possible? This would mean that I have to recomplie my standalone for every small update.

In maya only the major releases need a recompilation. So I suppose the problem lies in some compilation setings.

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