goat3d

diff src/goat3d_writexml.cc @ 64:99715321ad6d

merged
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 17 Apr 2014 08:53:42 +0300
parents dad392c710df d317eb4f83da
children 70b7c41a4f17
line diff
     1.1 --- a/src/goat3d_writexml.cc	Thu Apr 17 08:50:36 2014 +0300
     1.2 +++ b/src/goat3d_writexml.cc	Thu Apr 17 08:53:42 2014 +0300
     1.3 @@ -44,7 +44,7 @@
     1.4  		write_material(this, io, materials[i], 1);
     1.5  	}
     1.6  	for(size_t i=0; i<meshes.size(); i++) {
     1.7 -		write_mesh(this, io, meshes[i], i, 1);
     1.8 +		write_mesh(this, io, meshes[i], (int)i, 1);
     1.9  	}
    1.10  	for(size_t i=0; i<lights.size(); i++) {
    1.11  		write_light(this, io, lights[i], 1);
    1.12 @@ -60,33 +60,19 @@
    1.13  	return true;
    1.14  }
    1.15  
    1.16 -static void collect_nodes(std::list<const XFormNode*> *res, const XFormNode *node)
    1.17 -{
    1.18 -	if(!node) return;
    1.19 -
    1.20 -	res->push_back(node);
    1.21 -
    1.22 -	for(int i=0; i<node->get_children_count(); i++) {
    1.23 -		collect_nodes(res, node->get_child(i));
    1.24 -	}
    1.25 -}
    1.26 -
    1.27 -bool Scene::save_anim_xml(const XFormNode *node, goat3d_io *io) const
    1.28 +bool Scene::save_anim_xml(goat3d_io *io) const
    1.29  {
    1.30  	xmlout(io, 0, "<anim>\n");
    1.31  
    1.32 -	const char *anim_name = node->get_animation_name();
    1.33 -	if(anim_name && *anim_name) {
    1.34 -		xmlout(io, 1, "<name string=\"%s\"/>\n", anim_name);
    1.35 +	if(!nodes.empty()) {
    1.36 +		const char *anim_name = nodes[0]->get_animation_name();
    1.37 +		if(anim_name && *anim_name) {
    1.38 +			xmlout(io, 1, "<name string=\"%s\"/>\n", anim_name);
    1.39 +		}
    1.40  	}
    1.41  
    1.42 -	std::list<const XFormNode*> allnodes;
    1.43 -	collect_nodes(&allnodes, node);
    1.44 -
    1.45 -	std::list<const XFormNode*>::const_iterator it = allnodes.begin();
    1.46 -	while(it != allnodes.end()) {
    1.47 -		const XFormNode *n = *it++;
    1.48 -		write_node_anim(io, n, 1);
    1.49 +	for(size_t i=0; i<nodes.size(); i++) {
    1.50 +		write_node_anim(io, nodes[i], 1);
    1.51  	}
    1.52  
    1.53  	xmlout(io, 0, "</anim>\n");