UE5 Modeling-Mode: Welding vertices/edges?

Hi there!

How would I go about to weld/collapse/merge the two selected edges in the screenshot?

New to Unreal, trying out the Modeling Mode. Let’s say I like to build some simple 45°-edge-style geometry. Seems like a good use-case where rolling out Blender (etc.) would be overkill. However, I like the resulting geometry to be clean, so no degenerated zero-size triangles, etc.

I tried PolyEdEdge EditsWeld as well as Mesh OpsWeld, which seem the obvious candidates. However, neither tools seem to have any effect at all. The latter doesn’t even merge anything with absurd tolerances like “100”. I pretty sure I’m doing some odd noob mistake :smiley: Any ideas? Or does “Beta” mean this is really Beta and not yet usable?

1 Like

So I found the function that does the welding in the code. It’s quite a bit to look through, and I don’t have the source version of UE-5 to breakpoint it so I might do that later. It does seem to work as a vertex merger though, so I think your intuition is correct.

2 Likes

This certainly is the most outstanding comment though

//
// construct edge equivalence sets. First we find all other edges with same
// midpoint, and then we form equivalence set for edge from subset that also
// has same endpoints
//

Try using TriEdits instead, there seems to be a collapse function for edge. I think weld is the combine edges with identical duplicate vertices into one.

1 Like

Thanks. That does something. I managed to get what I wanted by some trial and error. Then reverted to try again, but then couldn’t repeat what I did :smiley: I seems I don’t understand what I need to select to collapse the way I want. Apparently one needs to select multiple edges, not just those you want to collapse the vertices of. Possibly a chain of edges somehow?

(For anyone looking for the code section the comment was quoted from, that would be FMergeCoincidentMeshEdges::Apply() )

1 Like

Thanks for linking the function.

There was a lot of work done in 5 surround FDynamicMesh3 (Now has a wrapper class UDynamicMesh*) since 4. I think most of the intent was to standardize the mesh descriptions and editing workflow and less on the tools in the kit, so it may be that Epic just hasn’t gotten to this specific feature yet, although we would need them to weigh in.

It would be a bit of work but there is a way to register your own tool with the modeling editor dynamically. All of the tools now register themselves dynamically now it seems via
UWeldMeshEdgesOperatorFactory::MakeNewOperator()

Hm, there is a CollapseEdge method on FDynamicMesh3, which seems supposed to do what I would expect when “collapsing an edge”. Will have a look tomorrow whether I can figure out how to call that.

	/**
	 * Collapse the edge between the two vertices, if topologically possible.
	 * @param KeepVertID index of the vertex that should be kept
	 * @param RemoveVertID index of the vertex that should be removed
	 * @param EdgeParameterT vKeep is moved to Lerp(KeepPos, RemovePos, collapse_t)
	 * @param CollapseInfo returned information about new and modified mesh elements
	 * @return Ok on success, or enum value indicates why operation cannot be applied. Mesh remains unmodified on error.
	 */
	virtual EMeshResult CollapseEdge(int KeepVertID, int RemoveVertID, double EdgeParameterT,
	                                 FEdgeCollapseInfo& CollapseInfo);
	virtual EMeshResult CollapseEdge(int KeepVertID, int RemoveVertID, FEdgeCollapseInfo& CollapseInfo)
	{
		return CollapseEdge(KeepVertID, RemoveVertID, 0, CollapseInfo);
	}
1 Like

Good find!

1 Like

I found a number of code leads, in case anyone would like to follow up on this. However, there seems no obvious easy way to add your own mesh ops, without modifying the engine itself. Certainly not something I should try in my first week of Unreal :roll_eyes:

  • UEditMeshPolygonsTool::ApplyWeldEdges()
    This is called on PolyEdEdge EditsWeld

  • UEditMeshPolygonsTool::ApplyCollapseEdge()
    Some dead code where somebody tried to implement collapsing of edges, with an interesting comment of “AAAHHH cannot do because of overlays” :rofl:
    This was probably supposed to call the above mentioned FDynamicMesh3::CollapseEdge.

  • UEditMeshPolygonsToolEdgeActions
    The different tools when editing edges in PolyEd.

  • FModelingToolActionCommands
    Registering of tools happens here.

  • FModelingToolsEditorModeModule::OnPostEngineInit()
    Which again is tied to this module.

1 Like

Another find, trying the TriEd mode. The collapse code in UEditMeshPolygonsTool::ApplyCollapseSingleEdge() there looks right when glancing at it, but it appears it somehow actually collapses a different edge than the one you selected. Maybe its a “random” neighbor vertex/edge ID that sometimes just doesn’t exist, which could explain why it sometimes does something and sometimes nothing at all.

Collapsing the selected edge in the screenshot actually collapses the one marked in purple:

=> I will consider Modeling Mode not ready for productive use for now and stick to Blender :wink:

1 Like

I had the same problem with the Tri-Edit collapse also

1 Like

This is a great question, thanks. One of the things to keep is that the current weld function only works on open boundaries. Other packages will collapse unneeded faces, which is a great option we will look into.

In this case if you removed the triangles that won’t be needed first with triEdit.

then while still in triEdit use the edge weld option.(the first selected edge is the edge that will shift)

You should get the shape you were looking for.

-Russell

3 Likes

@endofthehall Thanks for the reply!

In the case of just one quad is it possible to weld? This is not possible.
(This is just a bevel on the top face)
image

But this will be possible. Hard to see, but I’ve only remove a triangle on each side adjacent to the quad in the first image.

Ah, thx! That indeed does work in both PolyEd and TriEd. However, of course its a bit cumbersome having to delete the faces first. In TriEd mode you are likely having to flip at least one edge on the left or right side. In PolyEd you even have to insert edges on both sides to be able to delete the faces. In Unity ProBuilder as well as Blender this kind of thing happens automatically as it is clear which triangles need to be deleted during the weld.

You would still need to remove one triangle on either side, so that you are not collapsing one of the bevel triangles.

@Coolcat , agreed this type of workflow should be more efficient and is something we will be chatting about. Thanks again for the feedback!

-R

3 Likes

@endofthehall Thanks for the clarification. Really happy to see the evolution around FDynamicMesh3, keep fighting the good fight.

1 Like