33 auto preCollapse = [&] (
EdgeId edgeToCollapse,
const Vector3f& newEdgeOrgPos )
35 const auto org = mesh.topology.org( edgeToCollapse );
36 const auto dest = mesh.topology.dest( edgeToCollapse );
37 const auto orgPos = mesh.orgPnt( edgeToCollapse );
38 const auto destPos = mesh.destPnt( edgeToCollapse );
40 const auto ab = destPos - orgPos;
41 const auto dt = dot( newEdgeOrgPos - orgPos, ab );
42 const auto abLengthSq = ab.lengthSq();
48 if ( dt >= abLengthSq )
50 data[org] = data[dest];
54 const auto ratio = dt / abLengthSq;
55 data[org] = ( 1 - ratio ) * data[org] + ratio * data[dest];
#define MRMESH_API
Definition MRMeshFwd.h:80
Definition MRMeshAttributesToUpdate.h:10
Definition MRMesh/MRMesh.h:23
std::vector<T>-like container that requires specific indexing type,
Definition MRVector.h:19
Definition MRCameraOrientationPlugin.h:8
MRMESH_API PreCollapseCallback meshPreCollapseVertAttribute(const Mesh &mesh, const MeshAttributesToUpdate ¶ms)
auto preCollapseVertAttribute(const Mesh &mesh, Vector< T, VertId > &data)
Definition MRMeshDecimateCallbacks.h:31