copy_from_face_interp needs tuple input, loses reference, returns nothing #120861

Open
opened 2024-04-20 20:10:46 +02:00 by Dmitry C. · 0 comments

System: Windows 10
Broken: Blender 2.79 - 4.1.1
Worked: never?

Short description of error
The operation projects data from source face onto target element. Calling it requires wrapping the source face into a tuple, which is unintuitive, likely unintentional and not reflected in the docs.

When projecting face data onto another face, the reference to the target face gets lost (marked dead), and the operation does not return a new reference. This makes the usage impractical. If possible, the face should stay in place, but if not, the op should at least return the new one.

Test code for different element types is below. Depending on the type, the behavior is different.
Faces throw both errors.
Loops don't lose references, but still require tuples.
Verts don't suffer from either of the issues.

  1. BMFace.copy_from_face_interp():
import bmesh; bm = bmesh.new(); bm.loops.layers.uv.verify()
bmesh.ops.create_icosphere(bm, radius=8, calc_uvs=True)
bm.faces.ensure_lookup_table()

src_face, tgt_face = bm.faces[:2]
print(tgt_face.tag)
# False
print(tgt_face.copy_from_face_interp(src_face))
# SystemError: new style getargs format but argument is not a tuple
print(tgt_face.copy_from_face_interp((src_face,)))
# None
print(tgt_face.tag)
# ReferenceError: BMesh data of type BMFace has been removed
  1. BMLoop.copy_from_face_interp():
import bmesh; bm = bmesh.new(); bm.loops.layers.uv.verify()
bmesh.ops.create_icosphere(bm, radius=8, calc_uvs=True)
bm.faces.ensure_lookup_table()

src_face, tgt_loop = bm.faces[0], bm.faces[-1].loops[0]
print(tgt_loop.tag)
# False
print(tgt_loop.copy_from_face_interp(src_face))
# SystemError: new style getargs format but argument is not a tuple
print(tgt_loop.copy_from_face_interp((src_face,)))
# None
print(tgt_loop.tag)
# False
  1. BMVert.copy_from_face_interp():
import bmesh; bm = bmesh.new(); bm.loops.layers.uv.verify()
bmesh.ops.create_icosphere(bm, radius=8, calc_uvs=True)
bm.faces.ensure_lookup_table()

src_face, tgt_vert = bm.faces[0], bm.faces[-1].vert[0]
print(tgt_vert.tag)
# False
print(tgt_vert.copy_from_face_interp(src_face))
# None
print(tgt_vert.tag)
# False
  1. BMVert.copy_from_vert_interp():
import bmesh; bm = bmesh.new(); bm.loops.layers.uv.verify()
bmesh.ops.create_icosphere(bm, radius=8, calc_uvs=True)
bm.verts.ensure_lookup_table()

src_vert1, src_vert2, tgt_vert = bm.verts[0], bm.verts[1], bm.verts[-1]
print(tgt_vert.tag)
# False
print(tgt_vert.copy_from_vert_interp((src_vert1, src_vert2), 0.5))
# None
print(tgt_vert.tag)
# False

Edit: changed test code to be (more) valid. Now the mesh isn't degenerate, has valid UVs, and there's no risk of projecting onto a perpendicular face. Everything still applies though, it's not mesh-specific.

System: Windows 10 Broken: Blender 2.79 - 4.1.1 Worked: never? **Short description of error** The operation projects data from source face onto target element. Calling it requires wrapping the source face into a tuple, which is unintuitive, likely unintentional and not reflected in the docs. When projecting face data onto another face, the reference to the target face gets lost (marked dead), and the operation does not return a new reference. This makes the usage impractical. If possible, the face should stay in place, but if not, the op should at least return the new one. Test code for different element types is below. Depending on the type, the behavior is different. Faces throw both errors. Loops don't lose references, but still require tuples. Verts don't suffer from either of the issues. 1. `BMFace.copy_from_face_interp()`: ```Py import bmesh; bm = bmesh.new(); bm.loops.layers.uv.verify() bmesh.ops.create_icosphere(bm, radius=8, calc_uvs=True) bm.faces.ensure_lookup_table() src_face, tgt_face = bm.faces[:2] print(tgt_face.tag) # False print(tgt_face.copy_from_face_interp(src_face)) # SystemError: new style getargs format but argument is not a tuple print(tgt_face.copy_from_face_interp((src_face,))) # None print(tgt_face.tag) # ReferenceError: BMesh data of type BMFace has been removed ``` 2. `BMLoop.copy_from_face_interp()`: ```Py import bmesh; bm = bmesh.new(); bm.loops.layers.uv.verify() bmesh.ops.create_icosphere(bm, radius=8, calc_uvs=True) bm.faces.ensure_lookup_table() src_face, tgt_loop = bm.faces[0], bm.faces[-1].loops[0] print(tgt_loop.tag) # False print(tgt_loop.copy_from_face_interp(src_face)) # SystemError: new style getargs format but argument is not a tuple print(tgt_loop.copy_from_face_interp((src_face,))) # None print(tgt_loop.tag) # False ``` 3. `BMVert.copy_from_face_interp()`: ```Py import bmesh; bm = bmesh.new(); bm.loops.layers.uv.verify() bmesh.ops.create_icosphere(bm, radius=8, calc_uvs=True) bm.faces.ensure_lookup_table() src_face, tgt_vert = bm.faces[0], bm.faces[-1].vert[0] print(tgt_vert.tag) # False print(tgt_vert.copy_from_face_interp(src_face)) # None print(tgt_vert.tag) # False ``` 4. `BMVert.copy_from_vert_interp()`: ```Py import bmesh; bm = bmesh.new(); bm.loops.layers.uv.verify() bmesh.ops.create_icosphere(bm, radius=8, calc_uvs=True) bm.verts.ensure_lookup_table() src_vert1, src_vert2, tgt_vert = bm.verts[0], bm.verts[1], bm.verts[-1] print(tgt_vert.tag) # False print(tgt_vert.copy_from_vert_interp((src_vert1, src_vert2), 0.5)) # None print(tgt_vert.tag) # False ``` Edit: changed test code to be (more) valid. Now the mesh isn't degenerate, has valid UVs, and there's no risk of projecting onto a perpendicular face. Everything still applies though, it's not mesh-specific.
Dmitry C. added the
Type
Report
Priority
Normal
Status
Needs Triage
labels 2024-04-20 20:10:47 +02:00
Iliya Katushenock added the
Interest
Modeling
Interest
Python API
labels 2024-04-20 20:16:54 +02:00
Dmitry C. changed title from copy_from_face_interp needs tuple input, loses reference, returns nothing to `copy_from_face_interp` needs tuple input, loses reference, returns nothing 2024-04-26 14:41:05 +02:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#120861
No description provided.