sibarrick Posted February 13, 2007 Share Posted February 13, 2007 Hi, any idea how to duplicate the vertexsplit sop functionality. Are there any quick functions to do it, or will i have to roll my own.... Quote Link to comment Share on other sites More sharing options...
edward Posted February 14, 2007 Share Posted February 14, 2007 Sorry, you'll have to roll your own. The VertexSplit SOP is not too complicated anyhow. It loops through each point, comparing the vertices around it (via GEO_PointRefArray), and then adds a new point for each vertex if needed. The tricky part is making sure the new point has all the same attributes using the right version of GEO_Detail::appendPoint(), destroying the old point references in your GEO_PointRefArray via GB_PointRefArray::destroyReference(), and then using GB_Vertex::setPt() to insert the new point into the adjacent primitives. Quote Link to comment Share on other sites More sharing options...
sibarrick Posted February 14, 2007 Author Share Posted February 14, 2007 Cheers Edward, i'll try that. Want to add vertex support to my UVuniform sop, and this seemed the easiest way..... Quote Link to comment Share on other sites More sharing options...
sibarrick Posted February 17, 2007 Author Share Posted February 17, 2007 Hi Edward, Having a small problem with this, I written this function to do the splitting, which seems to run and loop through all the points, but I'm obviously doing something rather wrong since it causes Houdini to crash when it exits. Any pointers? void SOP_UVuniform::splitVertexUVs(GEO_Detail *gdp,int uvoff) { GEO_Point *ppt; UT_Vector4 pos; GEO_PointRefArray pointRefArray(gdp); for(int i=0;i<pointRefArray.entries();i++) { GEO_Vertex *vtx,*nextvtx; vtx = (GEO_Vertex*)pointRefArray(i)->vtx; float *uvatt = (float*)vtx->getAttribData(uvoff); for(GB_PointRef *pointRef = pointRefArray(i)->next; pointRef; pointRef = pointRef->next) { nextvtx = (GEO_Vertex*)pointRef->vtx; float *nextuvatt = (float*)nextvtx->getAttribData(uvoff); if (abs(nextuvatt[0]-uvatt[0]) > 0.001 || abs(nextuvatt[1]-uvatt[1]) > 0.001 || abs(nextuvatt[2]-uvatt[2]) > 0.001) { //split point //append point into the gdp GB_AttributeData adata; pos = vtx->getPt()->getPos(); ppt = gdp->appendPoint(pos, adata, 1); //destroy old point ref pointRefArray.destroyReference(pointRef); //insert point into prim pointRef->vtx->setPt(ppt); } } } cout<<"end"<<endl; } Quote Link to comment Share on other sites More sharing options...
edward Posted February 17, 2007 Share Posted February 17, 2007 For appendPoint(), I think you need something more like this to make sure the attribute data is the same: ppt = gdp->appendPoint(pos, vtx->getPt()->getAttrib(), false /*steal*/); But I suspect the real problem is that you're trying to destroy the vertex references in the pointRefArray while you're still looping through the data structures inside it. So try making a UT_PtrArray<GEO_Vertex *> array which copies out all the GEO_Vertex pointers that you want to process out of pointRef first. Once you have this, then do the splitting by looping through this independent array instead. Quote Link to comment Share on other sites More sharing options...
sibarrick Posted February 18, 2007 Author Share Posted February 18, 2007 Cheers Edward! that did the trick. Many thanks once more. 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.