bool check_polyhedron_collision_with_dag(SceneNode *node, const pp::Matrix& modelMatrix, const pp::Matrix& invModelMatrix, const ppogl::Polyhedron& ph) { PP_CHECK_POINTER( node ); bool hit = false; pp::Matrix newModelMatrix=modelMatrix*node->trans; pp::Matrix newInvModelMatrix=node->invtrans*invModelMatrix; if(node->isSphere == true){ ppogl::Polyhedron newph(ph); trans_polyhedron( newInvModelMatrix, newph ); hit = intersect_polyhedron( newph ); } if (hit == true) return hit; SceneNode* child = node->child; while (child != NULL) { hit = check_polyhedron_collision_with_dag( child, newModelMatrix, newInvModelMatrix, ph ); if ( hit == true ) { return hit; } child = child->next; } return false; }
bool_t check_polyhedron_collision_with_dag( scene_node_t *node, matrixgl_t modelMatrix, matrixgl_t invModelMatrix, polyhedron_t ph) { matrixgl_t newModelMatrix, newInvModelMatrix; scene_node_t *child; polyhedron_t newph; bool_t hit = False; check_assertion( node != NULL, "node is NULL" ); multiply_matrices( newModelMatrix, modelMatrix, node->trans ); multiply_matrices( newInvModelMatrix, node->invtrans, invModelMatrix ); if ( node->geom == Sphere ) { newph = copy_polyhedron( ph ); trans_polyhedron( newInvModelMatrix, newph ); hit = intersect_polyhedron( newph ); free_polyhedron( newph ); } if (hit == True) return hit; child = node->child; while (child != NULL) { hit = check_polyhedron_collision_with_dag( child, newModelMatrix, newInvModelMatrix, ph ); if ( hit == True ) { return hit; } child = child->next; } return False; }