bool initialize(PointCloudMeshCollisionTraversalNodeRSS& node, BVHModel<RSS>& model1, const BVHModel<RSS>& model2, BVH_REAL collision_prob_threshold, int leaf_size_threshold, int num_max_contacts, bool exhaustive, bool enable_contact, BVH_REAL expand_r) { if(!(model1.getModelType() == BVH_MODEL_TRIANGLES || model1.getModelType() == BVH_MODEL_POINTCLOUD) || model2.getModelType() != BVH_MODEL_TRIANGLES) return false; node.model1 = &model1; node.model2 = &model2; node.vertices1 = model1.vertices; node.vertices2 = model2.vertices; node.tri_indices2 = model2.tri_indices; node.uc1.reset(new Uncertainty[model1.num_vertices]); estimateSamplingUncertainty(model1.vertices, model1.num_vertices, node.uc1.get()); BVHExpand(model1, node.uc1.get(), expand_r); node.num_max_contacts = num_max_contacts; node.exhaustive = exhaustive; node.enable_contact = enable_contact; node.collision_prob_threshold = collision_prob_threshold; node.leaf_size_threshold = leaf_size_threshold; relativeTransform(model1.getRotation(), model1.getTranslation(), model2.getRotation(), model2.getTranslation(), node.R, node.T); return true; }
bool initialize(MeshDistanceTraversalNodeRSS& node, const BVHModel<RSS>& model1, const BVHModel<RSS>& model2) { if(model1.getModelType() != BVH_MODEL_TRIANGLES || model2.getModelType() != BVH_MODEL_TRIANGLES) return false; node.model1 = &model1; node.model2 = &model2; node.vertices1 = model1.vertices; node.vertices2 = model2.vertices; node.tri_indices1 = model1.tri_indices; node.tri_indices2 = model2.tri_indices; relativeTransform(model1.getRotation(), model1.getTranslation(), model2.getRotation(), model2.getTranslation(), node.R, node.T); return true; }
bool initialize(MeshCollisionTraversalNodeRSS& node, const BVHModel<RSS>& model1, const BVHModel<RSS>& model2, int num_max_contacts, bool exhaustive, bool enable_contact) { if(model1.getModelType() != BVH_MODEL_TRIANGLES || model2.getModelType() != BVH_MODEL_TRIANGLES) return false; node.vertices1 = model1.vertices; node.vertices2 = model2.vertices; node.tri_indices1 = model1.tri_indices; node.tri_indices2 = model2.tri_indices; node.model1 = &model1; node.model2 = &model2; node.num_max_contacts = num_max_contacts; node.exhaustive = exhaustive; node.enable_contact = enable_contact; relativeTransform(model1.getRotation(), model1.getTranslation(), model2.getRotation(), model2.getTranslation(), node.R, node.T); return true; }
BVHModel<BV>::BVHModel(const BVHModel<BV>& other) : CollisionGeometry(other), boost::noncopyable(), num_tris(other.num_tris), num_vertices(other.num_vertices), build_state(other.build_state), bv_splitter(other.bv_splitter), bv_fitter(other.bv_fitter), num_tris_allocated(other.num_tris), num_vertices_allocated(other.num_vertices) { if(other.vertices) { vertices = new Vec3f[num_vertices]; memcpy(vertices, other.vertices, sizeof(Vec3f) * num_vertices); } else vertices = NULL; if(other.tri_indices) { tri_indices = new Triangle[num_tris]; memcpy(tri_indices, other.tri_indices, sizeof(Triangle) * num_tris); } else tri_indices = NULL; if(other.prev_vertices) { prev_vertices = new Vec3f[num_vertices]; memcpy(prev_vertices, other.prev_vertices, sizeof(Vec3f) * num_vertices); } else prev_vertices = NULL; if(other.primitive_indices) { int num_primitives = 0; switch(other.getModelType()) { case BVH_MODEL_TRIANGLES: num_primitives = num_tris; break; case BVH_MODEL_POINTCLOUD: num_primitives = num_vertices; break; default: ; } primitive_indices = new unsigned int[num_primitives]; memcpy(primitive_indices, other.primitive_indices, sizeof(unsigned int) * num_primitives); } else primitive_indices = NULL; num_bvs = num_bvs_allocated = other.num_bvs; if(other.bvs) { bvs = new BVNode<BV>[num_bvs]; memcpy(bvs, other.bvs, sizeof(BVNode<BV>) * num_bvs); } else bvs = NULL; }