////////////////////////////////////////////////////////////// // find the edge with the highest weight in the path between // u and v ////////////////////////////////////////////////////////////// bin_data pathQuery(node* v, node* u) { cluster *clv,*clvp;//cluster for v, and parent cluster for v cluster *clu,*clup;//cluster for u, and parent cluster for u result rU(&emptyDat); result rV(&emptyDat); clv = v->data; clu = u->data; clvp = clv->parent; clup = clu->parent; while(clup != clvp) { // Base case. deprintf("."); deprintf("clvp = %d\n", clvp->id); deprintf("clup = %d\n", clup->id); // "Recursive" (loopersive) case if(clvp->height <= clup->height) { processCluster(clvp,clv,&rV); clv = clvp; clvp = clvp->parent; if(!clvp) return emptyDat; } else { processCluster(clup,clu,&rU); clu = clup; clup = clup->parent; if(!clup) return emptyDat; } }//while int van = clu -> getVanishing(); return *(compare (rU.find (van), rV.find (van))); }
boost::shared_ptr<btCompoundShape> ConvexDecomp::run(std::vector<boost::shared_ptr<btCollisionShape> > &shapeStorage) { HACD::HACD hacd; hacd.SetPoints(&points[0]); hacd.SetNPoints(points.size()); hacd.SetTriangles(&triangles[0]); hacd.SetNTriangles(triangles.size()); hacd.SetCompacityWeight(0.1); hacd.SetVolumeWeight(0.0); // HACD parameters // Recommended parameters: 2 100 0 0 0 0 //size_t nClusters = 2; size_t nClusters = 1; double concavity = 100; bool invert = false; bool addExtraDistPoints = false; bool addNeighboursDistPoints = false; bool addFacesPoints = false; hacd.SetNClusters(nClusters); // minimum number of clusters hacd.SetNVerticesPerCH(100); // max of 100 vertices per convex-hull hacd.SetConcavity(concavity); // maximum concavity hacd.SetAddExtraDistPoints(addExtraDistPoints); hacd.SetAddNeighboursDistPoints(addNeighboursDistPoints); hacd.SetAddFacesPoints(addFacesPoints); hacd.Compute(); nClusters = hacd.GetNClusters(); boost::shared_ptr<btCompoundShape> compound(new btCompoundShape()); for (int c = 0; c < nClusters; ++c) { btVector3 centroid; boost::shared_ptr<btConvexHullShape> shape(processCluster(hacd, c, centroid)); shapeStorage.push_back(shape); compound->addChildShape(btTransform(btQuaternion(0, 0, 0, 1), centroid), shape.get()); } return compound; }