| 1632 | } |
| 1633 | |
| 1634 | static void updateQuadrics(const unsigned int* collapse_remap, size_t vertex_count, Quadric* vertex_quadrics, QuadricGrad* volume_gradients, Quadric* attribute_quadrics, QuadricGrad* attribute_gradients, size_t attribute_count, const Vector3* vertex_positions, const unsigned int* remap, float& vertex_error) |
| 1635 | { |
| 1636 | for (size_t i = 0; i < vertex_count; ++i) |
| 1637 | { |
| 1638 | if (collapse_remap[i] == i) |
| 1639 | continue; |
| 1640 | |
| 1641 | unsigned int i0 = unsigned(i); |
| 1642 | unsigned int i1 = collapse_remap[i]; |
| 1643 | |
| 1644 | unsigned int r0 = remap[i0]; |
| 1645 | unsigned int r1 = remap[i1]; |
| 1646 | |
| 1647 | // ensure we only update vertex_quadrics once: primary vertex must be moved if any wedge is moved |
| 1648 | if (i0 == r0) |
| 1649 | { |
| 1650 | quadricAdd(vertex_quadrics[r1], vertex_quadrics[r0]); |
| 1651 | |
| 1652 | if (volume_gradients) |
| 1653 | quadricAdd(volume_gradients[r1], volume_gradients[r0]); |
| 1654 | } |
| 1655 | |
| 1656 | if (attribute_count) |
| 1657 | { |
| 1658 | quadricAdd(attribute_quadrics[i1], attribute_quadrics[i0]); |
| 1659 | quadricAdd(&attribute_gradients[i1 * attribute_count], &attribute_gradients[i0 * attribute_count], attribute_count); |
| 1660 | |
| 1661 | if (i0 == r0) |
| 1662 | { |
| 1663 | // when attributes are used, distance error needs to be recomputed as collapses don't track it; it is safe to do this after the quadric adjustment |
| 1664 | float derr = quadricError(vertex_quadrics[r0], vertex_positions[r1]); |
| 1665 | vertex_error = vertex_error < derr ? derr : vertex_error; |
| 1666 | } |
| 1667 | } |
| 1668 | } |
| 1669 | } |
| 1670 | |
| 1671 | static void solvePositions(Vector3* vertex_positions, size_t vertex_count, const Quadric* vertex_quadrics, const QuadricGrad* volume_gradients, const Quadric* attribute_quadrics, const QuadricGrad* attribute_gradients, size_t attribute_count, const unsigned int* remap, const unsigned int* wedge, const EdgeAdjacency& adjacency, const unsigned char* vertex_kind, const unsigned char* vertex_update) |
| 1672 | { |
no test coverage detected