/** * Adds current path to WorldObjectManager's list. Note how we copy all the local * to a new instance of a path world object. */ bool PathTool::addCurrent() //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ { bool returnValue = true; //only add path if it has more than 1 point if (mCurrentNumberOfPoints > 1) { WorldObject* worldObject = new WorldObject(); worldObject->setName(mName); worldObject->setColor(mColor); worldObject->setGroup(WorldObject::PATH); //instantiate path renderer and associate it with world object PathRenderer* pathRenderer = new PathRenderer(); for (int i = 0; i < mCurrentNumberOfPoints; i++) { pathRenderer->addPoint(mPoints[i]); } worldObject->setMeshRenderer(pathRenderer); //if object already exists (cannot add) perform cleanup if (!WorldObjectManager::getInstance()->addWorldObject(worldObject)) { //note: the path renderer that we associated with this world //object will get deleted on the world object's destructor delete worldObject; returnValue = false; } } return returnValue; }