   not recursing properly
  This function doens't perform it's recursion properly and I'm not really sure what it could be. The counter 'p', I'm not sure if I'm counting the function depth properly, but it gets to about 36k before stopping with no error message. But when I start the program by stepping through lines of code, then letting it continue, it comes up with a stack overflow error.Currently the 'drawBone' function only draws a 3d line.The joint object has a list of child joints, and the 'getNumChildren' function returns the size of the list, which has never been more than 3 with my test data.If the loop counter is out of bounds, 'getChildJoint' returns NULL, which should be okay because of the first if statement.void drawJointsAndBones(const scene::CJoint* joint, util::CVector3d trans) const{static int p = 0;util::CVector3d temp;if( !joint )// if the joint doens't existreturn;// nothing to draw// DEBUGutil::Message::print("Function depth: %d", p);p++;// down a level in function depth// DEBUGtemp = trans + joint->getRelativeTranslation();// Draw the bone between the previous joint absolute translation and this joint's absolute// translation.if( trans != temp )drawBone(trans, temp);// draw the jointm_sceneManager->getVideoDriver()->draw3dPoint( temp );// get a pointer to the bone and draw it, then pass joint on the other end of the bone// recursively to this function.for(int i=0; i < joint->getNumChildren(); i++)// draw next "subtree" of joints and bonesdrawJointsAndBones( joint->getChildJoint(i), temp );// DEBUGp--;// up a level in function depth// DEBUG}These are a small bunch of results from the functon depth counter.14/12/05 03:10:09  Function depth: 014/12/05 03:10:09  Function depth: 114/12/05 03:10:09  Function depth: 214/12/05 03:10:10  Function depth: 214/12/05 03:10:10  Function depth: 214/12/05 03:10:10  Function depth: 114/12/05 03:10:10  Function depth: 214/12/05 03:10:10  Function depth: 314/12/05 03:10:10  Function depth: 314/12/05 03:10:11  Function depth: 314/12/05 03:10:11  Function depth: 214/12/05 03:10:11  Function depth: 314/12/05 03:10:11  Function depth: 414/12/05 03:10:11  Function depth: 414/12/05 03:10:11  Function depth: 414/12/05 03:10:12  Function depth: 314/12/05 03:10:12  Function depth: 414/12/05 03:10:12  Function depth: 514/12/05 03:10:12  Function depth: 514/12/05 03:10:12  Function depth: 514/12/05 03:10:13  Function depth: 414/12/05 03:10:13  Function depth: 514/12/05 03:10:13  Function depth: 614/12/05 03:10:13  Function depth: 614/12/05 03:10:13  Function depth: 614/12/05 03:10:14  Function depth: 514/12/05 03:10:14  Function depth: 614/12/05 03:10:14  Function depth: 714/12/05 03:10:14  Function depth: 714/12/05 03:10:14  Function depth: 714/12/05 03:10:14  Function depth: 614/12/05 03:10:15  Function depth: 714/12/05 03:10:15  Function depth: 814/12/05 03:10:15  Function depth: 814/12/05 03:10:15  Function depth: 814/12/05 03:10:15  Function depth: 714/12/05 03:10:16  Function depth: 814/12/05 03:10:16  Function depth: 914/12/05 03:10:16  Function depth: 914/12/05 03:10:16  Function depth: 914/12/05 03:10:16  Function depth: 814/12/05 03:10:17  Function depth: 914/12/05 03:10:17  Function depth: 1014/12/05 03:10:17  Function depth: 1014/12/05 03:10:17  Function depth: 1014/12/05 03:10:17  Function depth: 914/12/05 03:10:17  Function depth: 1014/12/05 03:10:18  Function depth: 1114/12/05 03:10:18  Function depth: 1114/12/05 03:10:18  Function depth: 1114/12/05 03:10:18  Function depth: 1014/12/05 03:10:18  Function depth: 1114/12/05 03:10:18  Function depth: 1214/12/05 03:10:19  Function depth: 1214/12/05 03:10:19  Function depth: 1214/12/05 03:10:19  Function depth: 11So, what am I doing so wrong that this never returns all the way?   
  First, make sure your joints are being created properly.  It looks to me like you've got a bad tree.  Then, step through your draw routine and break just before you expect it to start unwinding but doesn't.  Keep tabs on all your variables, and see which one isn't behaving the way you expect.  This includes those joint pointers, some of which might start repeating themselves.CM   ;  A depth of 36k with at most three children per joint?  My TI-83+ overflows just trying to calculate the number of joints you'd need for that to be possible [smile]  It's safe to say you don't really have that many joints (approx. 2x1017000).There's probably something wrong with one of your functions that prevents the recursion from terminating, or at least makes it go on for a very long time.  getChildJoint may not be returning NULL when it should, or getNumChildren could be returning an extremely large value.  I'd step through the code diligently for at least a dozen or so recursions.   ;  AHA!!!Okay, here's what was happening: the way I distinguish a root joint from other joints, is that a root joint has the jointid and parentid as the same integer.Now, this was causing problems when I was creating the tree from file, as of course I didn't code it to ignore itself, so the root joint had 2 children. The joint that was supposed to be its child, and itself.All fixed. But, if anyone has a better idea of a joint structure for skeletal animation, I'm all ears. This is what I have:class CJoint{private:util::array<scene::CJoint*> m_childList;///< List of child joints for this joint.unsigned int m_parentID;///< Id of the parent for this joint.unsigned int m_jointID;///< The id of this joint.util::CVector3d m_relativeTranslation;///< The joint translation relative to its parent jointutil::CMatrix m_relativeTranslationMatrix;///< The joint translation relative to its parent joint///< in matrix formutil::CVector3d m_relativeRotation;///< The joint rotation relative to its parent jointutil::CMatrix m_relativeRotationMatrix;///< The joint rotation relative to its parent joint///< in matrix form};;  That appears to be the bare minimum for a joint structure.  Although maybe storing a pointer to the parent would be quicker than an ID.   ;  A pointer? Would I actually need to go back up to the parent once I've passed it recursively on the way down?   ;  Depends what you want to do with the joint structure.  For instance, several IK approach require you to move in a reverse direction from an end-effector to the root.  But it's up to you - an ID would be fine if you never really use the parent.   ;  Well, right now I'm only doing basics, so, might as well leave it. And anyway, putting in a pointer to the parent would be fairly easy, so, I'll do it later if I find I need it.   