The Face I get from casting the leaf->data pointer doesn't seem right. for one thing, it's m_leaf which I would assume should point back to the leaf is NULL.
Each one of the three Node pointers in m_n array always point to unaddressable memory.
This is simply code I stuck into the SoftBody demo to dump out the Bunny's Tree.
Bullet 2.77 on Ubuntu 10.10 x86_64
Code: Select all
void traverse_softbody_tree(btSoftBody* psb)
{
traverse_softbody_tree_rec(psb->m_ndbvt.m_root);
}
static int node_num = 0;
void traverse_softbody_tree_rec(const btDbvtNode *n)
{
std::cout << "\nIn node : " << node_num++ << std::endl;
std::cout << n->volume.Mins().getX() << " : ";
std::cout << n->volume.Mins().getY() << " : ";
std::cout << n->volume.Mins().getZ() << std::endl;
std::cout << n->volume.Maxs().getX() << " : ";
std::cout << n->volume.Maxs().getY() << " : ";
std::cout << n->volume.Maxs().getZ() << std::endl;
if (n->isleaf()) {
std::cout << "In Leaf: data is " << (n->dataAsInt) << std::endl;
std::cout << "In Leaf: data is " << (n->data) << std::endl;
btSoftBody::Face& f = *(btSoftBody::Face*) n->data;
for (int i = 0; i < 3; ++i) {
btVector3 & m = f.m_n[i]->m_x; //This is always a nonsense address :(
for (int j = 0; j < 3; ++j) {
std::cout << m.m_floats[j] << " : ";
}
std::cout << std::endl;
}
std::cout << std::endl;
return;
}
assert(n->isinternal());
traverse_softbody_tree_rec(n->childs[0]);
traverse_softbody_tree_rec(n->childs[1]);
}