| 54 | } |
| 55 | |
| 56 | void SPH::TriangleMesh::updateNormals() |
| 57 | { |
| 58 | m_normals.resize(numFaces()); |
| 59 | |
| 60 | #pragma omp parallel default(shared) |
| 61 | { |
| 62 | #pragma omp for schedule(static) |
| 63 | for (int i = 0; i < (int)numFaces(); i++) |
| 64 | { |
| 65 | // Get first three points of face |
| 66 | const Vector3r &a = m_x[m_indices[3 * i]]; |
| 67 | const Vector3r &b = m_x[m_indices[3 * i + 1]]; |
| 68 | const Vector3r &c = m_x[m_indices[3 * i + 2]]; |
| 69 | |
| 70 | // Create normal |
| 71 | Vector3r v1 = b - a; |
| 72 | Vector3r v2 = c - a; |
| 73 | |
| 74 | m_normals[i] = v1.cross(v2); |
| 75 | m_normals[i].normalize(); |
| 76 | } |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | void SPH::TriangleMesh::updateVertexNormals() |
| 81 | { |
no test coverage detected