goat3dgfx

diff src/xform_node.cc @ 22:92bfb0206969

- made all XFormNode functions virtual - added XFormNode::get_parent()
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 28 Dec 2013 06:48:23 +0200
parents 7c593721547f
children
line diff
     1.1 --- a/src/xform_node.cc	Fri Dec 27 11:59:32 2013 +0200
     1.2 +++ b/src/xform_node.cc	Sat Dec 28 06:48:23 2013 +0200
     1.3 @@ -13,6 +13,11 @@
     1.4  {
     1.5  	anm = new anm_node;
     1.6  	anm_init_node(anm);
     1.7 +	parent = 0;
     1.8 +
     1.9 +	// TODO read them from anm to get the correct initial values
    1.10 +	interp = INTERP_LINEAR;
    1.11 +	extrap = EXTRAP_EXTEND;
    1.12  }
    1.13  
    1.14  XFormNode::~XFormNode()
    1.15 @@ -53,10 +58,21 @@
    1.16  	return extrap;
    1.17  }
    1.18  
    1.19 +XFormNode *XFormNode::get_parent()
    1.20 +{
    1.21 +	return parent;
    1.22 +}
    1.23 +
    1.24 +const XFormNode *XFormNode::get_parent() const
    1.25 +{
    1.26 +	return parent;
    1.27 +}
    1.28 +
    1.29  void XFormNode::add_child(XFormNode *child)
    1.30  {
    1.31  	children.push_back(child);
    1.32  	anm_link_node(anm, child->anm);
    1.33 +	child->parent = this;
    1.34  }
    1.35  
    1.36  void XFormNode::remove_child(XFormNode *child)
    1.37 @@ -66,6 +82,10 @@
    1.38  	if(it != children.end()) {
    1.39  		children.erase(it);
    1.40  		anm_unlink_node(anm, child->anm);
    1.41 +
    1.42 +		if(child->parent == this) {
    1.43 +			child->parent = 0;
    1.44 +		}
    1.45  	}
    1.46  }
    1.47