| 25 | } |
| 26 | |
| 27 | void CollisionMeshDesc::InsertTriangle(const Vector3& vertex0, const Vector3& vertex1, const Vector3& vertex2) |
| 28 | { |
| 29 | auto getVertexId = [&](const Vector3& vertex) |
| 30 | { |
| 31 | // Get existing vertex ID. |
| 32 | auto it = _vertexMap.find(vertex); |
| 33 | if (it != _vertexMap.end()) |
| 34 | { |
| 35 | const auto& [vertex, vertexId] = *it; |
| 36 | return vertexId; |
| 37 | } |
| 38 | |
| 39 | // Add and cache new vertex. |
| 40 | int vertexId = (int)_vertices.size(); |
| 41 | _vertices.push_back(vertex); |
| 42 | _vertexMap[vertex] = vertexId; |
| 43 | |
| 44 | // Get new vertex ID. |
| 45 | return vertexId; |
| 46 | }; |
| 47 | |
| 48 | // Allocate vertices. |
| 49 | int vertexId0 = getVertexId(vertex0); |
| 50 | int vertexId1 = getVertexId(vertex1); |
| 51 | int vertexId2 = getVertexId(vertex2); |
| 52 | |
| 53 | // Add vertex IDs. |
| 54 | _vertexIds.push_back(vertexId0); |
| 55 | _vertexIds.push_back(vertexId1); |
| 56 | _vertexIds.push_back(vertexId2); |
| 57 | } |
| 58 | |
| 59 | void CollisionMeshDesc::Optimize() |
| 60 | { |
no test coverage detected