On 07/03/2014 at 04:59, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 15
Platform: Mac OSX ;
Language(s) : C++ ;
---------
I'm creating some helper methods for the C4DAtom::GetParameter method, since using it as is, is a bit verbose. Here's a example of my helper for a Float.
Bool GetParameter(GeListNode* node, const Int32 id, Float& value) {
GeData d;
if(node->GetParameter(id, d, DESCFLAGS_GET_0)) {
value = d.GetFloat();
return true;
}
return false;
}
//Usage:
Float offset;
if(!GetParameter(op, TEST_EFFECTOR_OFFSET, offset)) return;
This works and sets the offset correctly as a Float set by the user in the GUI.
But when I try to do the same thing to a custom data type, in this case SplineData, the data disappears when out of the helper function's scope. Here's the code:
Bool GetParameter(GeListNode* node, const Int32 id, SplineData *&splineData) {
GeData d(CUSTOMDATATYPE_SPLINE, DEFAULTVALUE);
if(node->GetParameter(id, d, DESCFLAGS_GET_0)) {
splineData = (SplineData* )d.GetCustomDataType(CUSTOMDATATYPE_SPLINE);
cout << splineData->GetKnotCount() << endl; **// outputs 4, correct**
return true;
}
return false;
}
//Usage:
SplineData* splineData;
if(!GetParameter(op, TEST_EFFECTOR_SPLINE, splineData)) return;
if(splineData) cout << splineData->GetKnotCount() << endl; **// outputs 0, incorrect**
I can't figure out how to get the correct SplineData out of the helper function. Any help on this would be great as I'm relatively new to c++.