1
$\begingroup$

EDIT: This apparently is a bug (https://developer.blender.org/T52723)

However, I'm still creating bmeshes in the draw method of my panels which is bad practice, but not the cause of this problem.


I've been developing an add-on for Re-Volt file types for a while.

I'm not sure if I discovered a bug or if I'm doing something wrong: As soon as I call bm.faces.layers.int.new("LayerName"), the UV Unwrap Reset operator starts behaving weirdly.

Usually, when you reset the UV on a cube, you get the faces mapped as squares. After creating a new int layer on the bmesh, it starts mapping faces to lines or other weird shapes that sometimes go beyond the UV bounds.

example uv image

I create those int layers to store flags for each face. The layers are created upon import and in Edit mode. I made a tool panel for setting those flags. It all works fine, it just breaks the bpy.ops.uv.reset() operator.

Launching Blender with --debug-all also didn't reveal any interesting details. Everything in the logs looks like it's supposed to.

I also tried opening the Blender files with that problem in older and newer versions than 2.78 and the problem persists there, it seems to be in the mesh.

Here's a .blend with the problem: http://pasteall.org/blend/index.php?id=47471

Here's the wider context of creating a new int layer (panel in the 3D view):

class RevoltFacePropertiesPanel(bpy.types.Panel):
    bl_label = "Face Properties"
    bl_space_type = "VIEW_3D"
    bl_region_type = "TOOLS"
    bl_context = "mesh_edit"
    bl_category = "Re-Volt"

    selection = None
    selected_face_count = None

    @classmethod
    def poll(self, context):
        return (context.object is not None)

    def draw(self, context):
        pass
        obj = context.object
        mesh = obj.data
        bm = bmesh.from_edit_mesh(mesh)
        flags = bm.faces.layers.int.get("RVFlags") or bm.faces.layers.int.new("RVFlags")
        texture = bm.faces.layers.int.get("RVTexture") or bm.faces.layers.int.new("RVTexture")

Here's the section on GitHub if that helps: https://github.com/Dummiesman/HabitatB/blob/dev/io_scene_habitatb/panels.py#L104

Please tell me if I could provide more information. I'd be really thankful if someone has an idea.

$\endgroup$
  • 1
    $\begingroup$ Changing ID data in a panel's draw method is a NO NO. (will throw an error for obj.location = (0, 0, 0) for example). The draw method runs many times (esp if mouse is over), put in a print statement to check. You will be making multiple instances of bmesh.from_edit_mesh() Have a look at on how to make a global dic and use one edit mode bmesh for the panel. $\endgroup$ – batFINGER Aug 15 '17 at 12:24
0
$\begingroup$

This is a Blender bug. It has been fixed: developer.blender.org

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.