Commit ac884a22 authored by Matthias Möller's avatar Matthias Möller
Browse files

- added: function "insertJoint". This function will insert a joint between the...

- added: function "insertJoint". This function will insert a joint between the given joint and his parent

git-svn-id: 383ad7c9-94d9-4d36-a494-682f7c89f535
parent dd100cce
......@@ -51,6 +51,7 @@
//== INCLUDES =================================================================
#include <iostream>
#include <algorithm>
#include "SkeletonT.hh"
......@@ -1007,3 +1008,44 @@ void SkeletonT<PointT>::updateFromGlobal(unsigned int _idJoint)
* @brief insert a Joint given its future child joint
* @param _pChild existing joint, will be the child
* @param _pInsert joint, which will be inserted. _pChild will be his child and the parent of _pChild will be his parent.
template<typename PointT>
void SkeletonT<PointT>::insertJoint(typename SkeletonT<PointT>::Joint *_pChild, typename SkeletonT<PointT>::Joint *_pInsert)
std::size_t i = 0;
if (!_pChild || !_pChild->parent() || !_pInsert)
Joint* parent = _pChild->parent();
//update IDs of our joints
unsigned int childID = _pChild->id();
for(typename std::vector<Joint*>::iterator it = joints_.begin() + childID; it != joints_.end(); ++it)
(*it)->setId((*it)->id() + 1);
//insert our new joint into this skeleton
joints_.insert(joints_.begin() + childID, _pInsert);
//update the parents
//note: pChild will be automatically erased in parent->children_
_pInsert->setParent(parent, *this);
_pChild->setParent(_pInsert, *this);
for(typename vector<Animation*>::iterator it = animations_.begin(); it != animations_.end(); ++it)
if (*it)
referencePose_.updateFromGlobal(0, true);
......@@ -145,6 +145,7 @@ public:
void addJoint(typename SkeletonT<PointT>::Joint *_pParent, typename SkeletonT<PointT>::Joint *_pJoint);
void insertJoint(typename SkeletonT<PointT>::Joint *_pChild, typename SkeletonT<PointT>::Joint *_pInsert);
void removeJoint(typename SkeletonT<PointT>::Joint *_pJoint);
inline void clear();
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment