sweenal / opencollada

Automatically exported from code.google.com/p/opencollada
0 stars 0 forks source link

COLLADAFWKinematicsController copy constructor doesn't copy AxisInfos and KinematicsModelUniqueIds #165

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
- Load a kinematics model with the tag <articulated_system>, could use the one 
I attached below.

- Try to execute following code:

bool writeKinematicsScene( const COLLADAFW::KinematicsScene* kinematicsScene )
{
  COLLADAFW::KinematicsControllerArray controllers = kinematicsScene->getKinematicsControllers();
  COLLADAFW::AxisInfoArray& axisInfos = controllerPtr->getAxisInfos();
  cout << "found " << axisInfos.getCount() << " axis_info tags" << endl;
}

- The output will be 0.

- If you use a reference instead of the copying object:
{
  const COLLADAFW::KinematicsControllerArray& controllers =   kinematicsScene->getKinematicsControllers();
  COLLADAFW::AxisInfoArray& axisInfos = controllerPtr->getAxisInfos();
  cout << "found " << axisInfos.getCount() << " axis_info tags" << endl;
}

You get the correct number of axisInfo tags, which 8 for this example.

This happens because in KinematicsController copy constructor fields mAxisInfos
and mKinematicsModelUniqueIds are initialized with default values, instead of
the values from the original KinematicsController instance (pre).

Here is this copy constructor:

KinematicsController::KinematicsController( const KinematicsController& pre )
        : ObjectTemplate<COLLADA_TYPE::KINEMATICS_CONTROLLER>(pre)
        , mKinematicsModelUniqueIds(UniqueIdArray::OWNER)
        , mAxisInfos(AxisInfoArray::OWNER)
        , mLinearMotionProfile(pre.mLinearMotionProfile)
        , mAngularMotionProfile(pre.mAngularMotionProfile)
    {

    }

solution I guess is easy, just add following lines in the copy constructor:

pre.mKinematicsModelUniqueIds.cloneArray(mKinematicsModelUniqueIds);
pre.mAxisInfos.cloneArray(mAxisInfos);

as it is done in KinematicsController::operator=( const KinematicsController& 
pre ) method.

best regards,
Alexey

Original issue reported on code.google.com by Alexey.Z...@gmail.com on 24 Jun 2011 at 1:51

Attachments: