OK, I've found some workaround...
It uses 3D MAX internal code instead of my own one but at least it works:
Let's assume I have a list or vector of edge structs:
struct Edge
{
int nEd0;
int nEd1;
};
And a function to check if an edge is in the list:
bool findHardEdge( int v1, int v2 );
Here is the code to compute Smoothing Groups from Hard Edges, using MNMesh class:
MNMesh mm = *pMesh; // pMesh contains vert/face data already and is copied to MNMesh
mm.FillInMesh(); // computes helper data in MNMesh
for( int i = 0; i < mm.nume; i++ ) // iterate over all edges
{
int v1 = mm.E(i)->v1;
int v2 = mm.E(i)->v2;
bool found = findHardEdge( v1, v2 ); // check if the edge is a 'hard' one
if( found )
mm.E(i)->SetFlag( 32 ); // mark an edge with some flag
}
mm.SmoothByCreases( 32 ); // this method does the job
mm.OutToTri( *pMesh ); // copy data back to the original mesh instance
I realize that this code is quite slow, especially for bigger meshes but it's also simplest thing I came up with. If you know any better way let me know :)