I did the most simple code I could. you need to select 2 verts in edit mode on the default cube. which has already UVs. So my question is how to update UVs to the new geometry?
import bpy,bmesh
me = bpy.context.object.data
bm = bmesh.from_edit_mesh(me)
bm.verts.ensure_lookup_table()
hist = bm.select_history
v1=hist[0]
v2=hist[1]
v1.co = v1.co.lerp(v2.co,1)
bmesh.ops.remove_doubles(bm, verts=list(hist), dist=0.0001)
#there? if I want to update UVs
uv_layer = bm.loops.layers.uv.active
for face in bm.faces:
for loop in face.loops:
loop[uv_layer].uv = ?
bm.normal_update()
bmesh.update_edit_mesh(me)
I thought it was possible to do same operation on UV that on vertices like a merge but apparently like several loops are linked to the two vertices this is a messā¦
right- thatās kinda what i was talking about, UVs are stored per LOOP, not per vert. there is no such thing as āmerging uvsā. If two uvs share an edge and are cospatial then they are āmergedā.
and itās not really a mess, thatās just how UVs work. In other tech (unity and UE4 for example) uvs are stored per triangle, and itās the same thing- there is no āmergingā of uvs.
I just remembered a lengthy post I made a year or so ago over on devtalk that goes into much greater detail about all of this in case youāre interested in learning more about it:
I understood what you explained and I saw it before but I really donāt see how to transform my code to have the wanted result. before I was using the remove double operator, it has an option correct UVs. so if you are merging several vertices on 2 edges you get a hole in UVs without correct UVs (the missing face). but now Iām using a lerp fonction to reduce distance between vertices and at value=1 itās merging (bmesh remove double which has not uv option). what is happening at line 147 in the script https://github.com/1C0D/Remove_doubles_plus/blob/master/remove_doubles_plus%20v1_6_1.py