I'm trying to send a pointer to my function but having trouble.  Shouldn't this work?

MStatus myFunction(MVector *vec)
{

    vec->x = 3.145;
    vec->y = 3.145;
    vec->z = 3.145;

    return MStatus::kSuccess;
}

MVector coolVector(0.0, 0.0, 0.0);

stat = myFunction(&coolVector);

print(coolVector)

//[0.0, 0.0, 0.0]

How do I pass an existing MVector into my function and place a value in it?

  • created

    Jan '12
  • last reply

    Jan '12
  • 1

    reply

  • 1.6k

    views

  • 1

    user

never mind - got it to work just fine using only references.

MStatus myFunction(MVector &vec)
{

    vec.x = 3.145;
    vec.y = 3.145;
    vec.z = 3.145;

    return MStatus::kSuccess;
}

MVector coolVector(0.0, 0.0, 0.0);

stat = myFunction(coolVector);

print(coolVector)

//[3.145, 3.145, 3.145]