Advertisement
expired6978

Smooth

Dec 6th, 2014
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. void CDXSmoothStroke::Update(CDXStroke::Info * info, CDXMeshVert* pVertices, CDXMeshIndex* pIndices)
  2. {
  3.     CDXVec3 newPos = CDXVec3(0, 0, 0);
  4.  
  5.     UInt32 totalCount = 0;
  6.     m_mesh->VisitAdjacencies(info->index, [&](CDXMeshFace & face)
  7.     {
  8.         CDXMeshIndex m1 = face.v1;
  9.         if (m1 >= m_mesh->GetVertexCount())
  10.             return false;
  11.  
  12.         CDXMeshIndex m2 = face.v2;
  13.         if (m2 >= m_mesh->GetVertexCount())
  14.             return false;
  15.        
  16.         CDXMeshIndex m3 = face.v3;
  17.         if (m3 >= m_mesh->GetVertexCount())
  18.             return false;
  19.        
  20.         CDXVec3 sum = pVertices[m1].Position + pVertices[m2].Position + pVertices[m3].Position;
  21.         newPos += sum / 3;
  22.         totalCount++;
  23.         return false;
  24.     });
  25.  
  26.     newPos /= totalCount;
  27.  
  28.     CDXVec3 difference = newPos - pVertices[info->index].Position;
  29.    
  30.     m_current.insert(CDXVectorPair(info->index, CDXVec3(0,0,0)));
  31.     m_current[info->index] += difference;
  32.     pVertices[info->index].Position += difference;
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement