franMarz / TexTools-Blender

TexTools is a UV and Texture toolset created several years ago for Blender and Max by @renderhjs. In this open repository, originally created by @SavMartin, we develop the current version of this popular Blender add-on.
Other
2.02k stars 138 forks source link

UV Smoothing button just sets Auto Smooth to 180º #50

Closed PabloCaracena closed 3 years ago

PabloCaracena commented 3 years ago

Blender 2.90.1 Windows 10 Textools_2.9x, released Jul 24. (Latest release right now)

Expected behavior: Setting sharp the edges that are UV islands bounds.

The only thing I noticed it does is turning on Autosmooth and setting it to 180º. Tried it in different projects, so you can reproduce it in any model you want I guess.

Thanks for the addon!

franMarz commented 3 years ago

It was working on 2.82, broken since 2.83. The same version of TexTools. No documented API changes on 2.83 could have broken it, there may be an undocumented API change that is causing this, so this issue is not really straightforward to fix, the code have to be tested step by step. I suspect the issue should be in op_select_islands_outline.py

PabloCaracena commented 3 years ago

op_select_islands_outline.py does what is expected I think.

Executing this script in the UV editor does what you would expect from UV Smoothing:

import bpy

bpy.context.scene.tool_settings.use_uv_select_sync = True bpy.ops.uv.select_all(action='SELECT') bpy.ops.uv.textools_select_islands_outline() bpy.ops.mesh.mark_sharp()

PabloCaracena commented 3 years ago

Oh I find the solution.

I just added the functions: bpy.context.scene.tool_settings.use_uv_select_sync = True bpy.ops.mesh.select_all(action='SELECT') bpy.context.scene.tool_settings.use_uv_select_sync = False

In "op_smoothing_uv_islands.py" the "#Select edges" part looks like this working:

bpy.ops.mesh.select_all(action='DESELECT') bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE') bpy.context.scene.tool_settings.use_uv_select_sync = True bpy.ops.mesh.select_all(action='SELECT') bpy.ops.uv.textools_select_islands_outline() bpy.ops.mesh.mark_sharp() bpy.ops.mesh.select_all(action='DESELECT') bpy.context.scene.tool_settings.use_uv_select_sync = False

It was not selecting anything in first place, so I don't undestand how it worked in 2.83, but this works now.

franMarz commented 3 years ago

Yeah, this is the solution. I changed the op_select_islands_outline.py months ago to work without UV sync but UV sync is needed for UV Smoothing and has to be enabled before the call. Previously UV sync wasn't activated in Bounds Select so it should plain won't work, maybe I was testing it with UV sync enabled in 2.82. I'll make a push request.

franMarz commented 3 years ago

Fixed for 2.83. In 2.90/2.91 it doesn't work, because Select Bounds is failing, basically.