Пример #1
0
void DumpVisitor::ApplyGroup(Group &g)
{
	for(int i=0; i<m_level; i++)
		std::cout << "  ";

	if (g.GetName().empty())
		std::cout << g.GetTypeName() << std::endl;
	else
		std::cout << g.GetTypeName() << " - " << g.GetName() << std::endl;

	m_level++;
	g.Traverse(*this);
	m_level--;
}
Пример #2
0
	virtual void ApplyGroup(Group &group) {
		Group *old = root;
		root = 0;

		// only play in the cache if the group is shared
		const bool doCache = group.GetRefCount() > 1;

		if (doCache) {
			std::map<Group*,Group*>::iterator i = cache.find(&group);
			if (i != cache.end())
				root = (*i).second;
		}

		if (!root) {
			// can't use the copy constructor or Clone
			// they will do too much work
			root = new Group(group.GetRenderer());
			root->SetName(group.GetName());
			root->SetNodeMask(group.GetNodeMask());

			if (doCache)
				cache.insert(std::make_pair(&group, root));
		}

		group.Traverse(*this);

		if (old) {
			old->AddChild(root);
			root = old;
		}
	}