Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Relax mesh" node #3807

Merged
merged 5 commits into from
Jan 4, 2021
Merged

"Relax mesh" node #3807

merged 5 commits into from
Jan 4, 2021

Conversation

portnov
Copy link
Collaborator

@portnov portnov commented Jan 4, 2021

This node moves vertices of the input mesh, in order to make it more "relaxed",
i.e. for mesh elements to have more even distribution in some sense. There are
several algorithms supported, each of which has different definition of what "relaxed" is:

  • Lloyd-based algorithm. This is created after well-known Lloyd algorithm. For
    each vertex, find centers of all incident faces, and then find the average of
    those points; this will be the new location of the vertex. Effectively, this
    algorithm tries to make each face as close to circle as possible. This
    algorithm shows it's best for meshes that consist of Tris.
  • Edge lengths. Scale each edge up or down, trying to make all edges of the
    same length. Target edge length can be minimum, maximum or average of all
    lengths of edges of the source mesh.
  • Face areas. Scale each face up or down, trying to make all faces of the same
    area. Target face area can be minimum, maximum or average of all areas of
    faces of the source mes.

These algorithms can change the overall shape of the mesh a lot. In order to
try to preserve original shape of the mesh at least partially, the following
methods are supported:

  • "Linear" method is supported for Lloyd algorithm only. When the algorithm has
    found the new location of the vertex, put it at the same distance from the
    plane where centers of incident faces lie, as the original vertex was. This
    method can be slow for large meshes.
  • "Tangent": move vertices along tangent planes of original vertexes only (i.e.
    perpendicular to vertex normal).
  • "BVH": use BVH tree to find the nearest point to the newly calculated vertex
    on the original mesh.

Screenshot_20210104_140240

Preflight checklist

Put an x letter in each brackets when you're done this item:

  • Code changes complete.
  • Code documentation complete.
  • Documentation for users complete (or not required, if user never sees these changes).
  • Manual testing done.
  • Unit-tests implemented.
  • Ready for merge.

@portnov portnov merged commit 0ed3cc3 into master Jan 4, 2021
@@ -125,6 +126,8 @@ def process(self):
new_face_data = []
bm.free()

new_faces = get_unique_faces(new_faces)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@portnov why did you add this line?, it slows a lot the node

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember exactly, there was some node which created meshes with duplicate faces, which broke the node...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you want me to leave it as an option or just delete it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably the correct option would be to remove it from here, and to create a separate node for "fixing any mesh"...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably the correct option would be to remove it from here, and to create a separate node for "fixing any mesh"...

Yes, there is even request for such node. #3989

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think such node might want to also output the indices from the original face list, which it has discarded

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it should remove only repeated faces and edges. Bmesh module should be able to handle repeated vertices (with the same coordinates). Such vertices can be removed by 'Merge by distance' if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants