Notifications
Clear all

[Closed] Fastest way to "getDiagonal" in Editable Poly?

Hello,
I’ve noticed that there is a “polyop.setDiagonal” to set the invisible triangulation in a face.
However, there doesn’t seem to be a “getDiagonal” that would retrieve those invisible edges.

Currently, the way I’m working around it is to store the number of edges in a variable, I create a copy of the mesh, I connect the verts of the specified face and then I count the edge number again. I get the extra added edges count (since there might be more than one) and I get those edge verts. I then delete the copy of the mesh once I’m done looping through all the polygons.

I was wondering if there was a faster way of doing this? Did I miss something?

Thanks!

EDIT: The slow part seems to be the “.ConnectVertices” is there any alternative?

8 Replies

the key is to find all mesh tries those make a specified poly.

So that would require to figure out how to loop through the polygons in editable mesh.
I thought about it, but I didn’t figure out how to. I’ll think about it some more… If I can’t find the solution I’ll ask for more hints

the easiest way is to select a poly of an editable_poly and check selected faces of the editable_poly mesh. the selected faces correspond to the selected poly.

it’s the easiest way, but not the fastest.

1 Reply
(@norman3d)
Joined: 10 months ago

Posts: 0

Right, because for every time you use “.mesh” you are internally converting to editable mesh and this would take time.
The key is to convert to editable mesh once and do everything that is needed there, right? I’ll keep thinking.

you are right about accessing mesh… yes. every time it make a mesh copy. so if you need to find diagonals of only one poly you need only one mesh copy. and using selection method would be the fastest.

but if you need to get diagonals of many or all polys you have to find a way that uses a mesh copy only once.

So I managed to do it with “meshop.getPolysUsingFace”. I collect every polygon in an array. Then I loop through the faces of each polygon, and I loop through every edge to find which ones are invisible or not.
This worked! It was faster than the “connectVerts” method, however it was still somewhat slow.

I realized that “meshop.getPolysUsingFace” was the culprit. It’s very slow!
In my specific case I only have to deal with quads and triangles. There will never be ngons with higher vert count than 4. So I figured I don’t have to use “meshop.getPolysUsingFace” at all. Instead I’m looping through the faces and collecting the invisible edges. Once I find an invisible edge I put the next face in an array so that it is skipped in the next loop. The next face we know is the other part of the quad, and so the invisible edge will be the same. It works perfectly.

Thanks for the tips Denis! I’m curious though, is “meshop.getPolysUsingFace” supposed to be slow. Or did I mess something up on my end?

Denis version is like a third faster than mine! I’m going to study this for sure!

EDIT: It’s actually even faster if you don’t use “node.selectedfaces” and instead use every edge.