| 33 | using namespace spark_dsg; |
| 34 | |
| 35 | void mergeObjectAttributes(const KhronosObjectAttributes& from, |
| 36 | KhronosObjectAttributes& into) { |
| 37 | // Update the bounding box. Do this first as it is the reference for the mesh. |
| 38 | BoundingBox new_box = into.bounding_box; |
| 39 | new_box.merge(from.bounding_box); |
| 40 | |
| 41 | // Adjust the old vertex positions. |
| 42 | for (auto& vertex : into.mesh.points) { |
| 43 | vertex = new_box.pointToBoxFrame(into.bounding_box.pointToWorldFrame(vertex)); |
| 44 | } |
| 45 | |
| 46 | // Merge incoming vertices. |
| 47 | const size_t num_previous_vertices = into.mesh.numVertices(); |
| 48 | into.mesh.resizeVertices(num_previous_vertices + from.mesh.numVertices()); |
| 49 | for (size_t i = 0; i < from.mesh.numVertices(); ++i) { |
| 50 | into.mesh.setPos( |
| 51 | num_previous_vertices + i, |
| 52 | new_box.pointToBoxFrame(from.bounding_box.pointToWorldFrame(from.mesh.pos(i)))); |
| 53 | into.mesh.setColor(num_previous_vertices + i, from.mesh.color(i)); |
| 54 | } |
| 55 | |
| 56 | // Merges incoming faces. |
| 57 | const size_t idx_offset = into.mesh.numVertices(); |
| 58 | into.mesh.faces.reserve(from.mesh.faces.size() + into.mesh.faces.size()); |
| 59 | for (const auto& face : from.mesh.faces) { |
| 60 | spark_dsg::Mesh::Face new_face = face; |
| 61 | for (size_t i = 0; i < new_face.size(); ++i) { |
| 62 | new_face[i] += idx_offset; |
| 63 | } |
| 64 | into.mesh.faces.emplace_back(new_face); |
| 65 | } |
| 66 | |
| 67 | into.bounding_box = new_box; |
| 68 | } |
| 69 | |
| 70 | bool isNodeActive(const SceneGraphNode& node, |
| 71 | const std::map<NodeId, size_t>& node_to_component, |
no test coverage detected