Hello
I have a DG node that has just two attributes: 'inGeo' and 'outGeo'.
The attributes are of generic type, accepting both MFnData::kNurbsSurface and MFnData::kMesh.
The nodes operation is very simple (for presentation purpose): take input points and move them +Y by 1.0
The first step in compute function is to copy input geometry to output plug, and then operate directly on output.
This method is taken from devkit example, and works for polymesh, bo not for NURBS surfaces.
The problem looks like some kind of loop - every time compute() is executed, the +Y offset is applied to already offseted points, so each compute() accumulates over previous ! This happens only on nurbs, not meshes.
Here are compute() and initialize() functions()
Initialize()
{
MFnGenericAttribute gAttr ;
inGeo = gAttr.create( "inGeo", "inGeo" );
gAttr.addAccept(MFnData::kNurbsSurface); // Accept nurbs
gAttr.addAccept(MFnData::kMesh); // Accepts Mesh
gAttr.setStorable(false);
addAttribute(inGeo);
outGeo = gAttr.create( "outGeo", "outGeo" );
gAttr.addAccept(MFnData::kNurbsSurface); // Accept nurbs
gAttr.addAccept(MFnData::kMesh); // Accepts Mesh
gAttr.setStorable(false);
gAttr.setWritable(false);
addAttribute(outGeo);
...
}
compute()
{
if( plug == outGeo ) {
MDataHandle inputData = block.inputValue( inGeo );
MDataHandle outputData = block.outputValue( outGeo );
// NURBS
MFnNurbsSurface geometryFn;
outputData.set( inputData.asNurbsSurface() );
geometryFn.setObject(outputData.asNurbsSurface());
// MESH
//MFnMesh geometryFn;
//outputData.set( inputData.asMesh() );
//geometryFn.setObject(outputData.asMesh());
MPointArray points;
geometryFn.getCVs( points ); // NURBS
//geometryFn.getPoints(points); // MESH
for(int j=0; j<points.length(); ++j)
points[j].y += 1;
geometryFn.setCVs( points ); // NURBS
//geometryFn.setPoints( points ); // MESH
outputData.setClean();
return MS::kSuccess;
}
}
The MESH parts are commented out - they work as expected.
NURBS code results in +Y accumulation on each compute() call.
Any hints appreciated
-Michal