View Full Version : passing parameters to methods in maya api

02 February 2006, 01:11 AM
I am having an attack of anal rententiveness. The swirlDeformer2 from Dave Gould's 1st book Maya Programming uses two different parameter names in it's deform method syntax. I am being neurotic about the MMatrix ref parameter name. Is it named mat or is it localToWorld? And then the DataHandle uses the mat name again! Plus it is a virtual method so it really only exists in the derived class. UGH! IT is the only thing I don't get in the example! It compiles and operates fine and drives me mad!

//prototype in header file
virtual MStatus deform( MDataBlock &block,
MItGeometry &iter,
const MMatrix &mat,
unsigned int multiIndex );

// actual defination
MStatus SwirlDeformer::deform( MDataBlock& block, MItGeometry &iter,
const MMatrix &localToWorld,
unsigned int geomIndex )
MDataHandle matData = block.inputValue( deformSpace );
MMatrix mat = matData.asMatrix();
MMatrix invMat = mat.inverse();

02 February 2006, 07:50 AM
hehe, hold on ...

In C/C++ the variable names in class function declaration or regular function declarations doesnt have to be the same like it is in their definitions, but you're right, its not such a good thing to have different names that will most likely confuse other programmers, you could even remove the varaiable names and just keep the datatypes in the declarations ...

The MMatrix datatype in the definition is the matrix representation of the deformSpace attribute on your MPxDeform node ....


02 February 2006, 10:02 AM
Technically speaking you don't need variable names in the declaration at all, you only need to tell the compile the types you are passing to the function. Variable names in the declaration are only there to give you (and other people reading your code) a hint as to what you should be passing.

So yes, putting different (or undescriptive) names in the declaration is very evil.

02 February 2006, 04:59 PM
edit nevermind,
I understood what ur saying, yea i agree it is confusing

02 February 2006, 05:44 PM
I think it is mainly confusing to beginners like me. We get obsessed with that small wrinkle and then miss that the dataHandle is being explictely set and that is going to govern what is happening with the data.

CGTalk Moderation
02 February 2006, 05:44 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.