pixwerx/src/scene/tests/pwscene_test_traverser.cpp

65 lines
1.3 KiB
C++
Raw Normal View History

2018-12-27 23:45:16 +01:00
#include <pw/core/vector.hpp>
#include <pw/core/serialize.hpp>
#include <pw/scene/node.hpp>
#include <pw/scene/transform.hpp>
#include <pw/scene/traverser.hpp>
2018-12-27 23:45:16 +01:00
#include <iostream>
//struct test_visitor : pw::node::visitor {
// virtual void enter(pw::node *n) override;
// virtual void leave(pw::node *n) override;
//};
2018-12-27 23:45:16 +01:00
//void test_visitor::enter(pw::node *n)
//{
// std::cout << n->name() << " " << n->is_leaf() << std::endl;
//}
2018-12-27 23:45:16 +01:00
//void test_visitor::leave(pw::node *n)
//{
//}
2018-12-27 23:45:16 +01:00
#include <iostream>
2019-01-01 21:47:35 +01:00
void print_node_path(pw::node::ref node) {
auto parents = node->path();
std::cout << node->name() << " - ";
for (auto p : node->path()) {
std::cout << " p:'" << p->name() << "'";
}
std::cout << std::endl;
}
2018-12-27 23:45:16 +01:00
int main(int argc,char **argv) {
using namespace pw;
node::ref root(std::make_shared<node>());
root->set_name("root");
root->add_child()->set_name("sub-1");
2018-12-27 23:45:16 +01:00
// node::ref sub_2_1 = std::make_shared<node>("sub-2-1");
2018-12-27 23:45:16 +01:00
// root->add_child(std::make_shared<node>("sub-3"))->add_child(sub_2_1);
// root->add_child(std::make_shared<node>("sub-2"))->add_child(std::make_shared<node>("sub-2-2"));
2019-01-01 21:47:35 +01:00
// std::cout << "sub-2-1 parent count: " << sub_2_1->parents().size() << std::endl;
2018-12-27 23:45:16 +01:00
2019-01-01 21:47:35 +01:00
// traverser tv;
// tv.bfs(root);
2018-12-27 23:45:16 +01:00
2019-01-01 21:47:35 +01:00
// print_node_path(sub_2_1);
// print_node_path(root->children()[2]->children().front());
2018-12-27 23:45:16 +01:00
return 0;
}