'Join' does not preserve face orientation for negative scales #74237

Closed
opened 2020-02-26 16:38:33 +01:00 by Nicolas Lelong · 18 comments

System Information
Operating system: Windows-10-10.0.18362 64 Bits
Graphics card: Quadro RTX 3000/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 441.22

Blender Version
Broken: version: 2.81 (sub 16), branch: master, commit date: 2019-12-04 11:32, hash: f1aa4d18d4

Short description of errorjoin_face_orientation_problem.blend
When joining multiple meshes, if some of them have a negative scale (mirror), the joined mesh has flipped faces, while the original display in viewport was good (with backface culling enabled)

Note that the faces may be flipped on mesh parts that had no negative scale, it seems to depend on the active object.

May be similar to #57612

Exact steps for others to reproduce the error

  • Open the attached blend file
  • Press Ctrl-J to join the two preselected cubes
  • As the viewport Backface culling is enabled, see that one of the cubes now has flipped faces.
**System Information** Operating system: Windows-10-10.0.18362 64 Bits Graphics card: Quadro RTX 3000/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 441.22 **Blender Version** Broken: version: 2.81 (sub 16), branch: master, commit date: 2019-12-04 11:32, hash: `f1aa4d18d4` **Short description of error**[join_face_orientation_problem.blend](https://archive.blender.org/developer/F8373214/join_face_orientation_problem.blend) When joining multiple meshes, if some of them have a negative scale (mirror), the joined mesh has flipped faces, while the original display in viewport was good (with backface culling enabled) Note that the faces may be flipped on mesh parts that had no negative scale, it seems to depend on the active object. May be similar to #57612 **Exact steps for others to reproduce the error** * Open the attached blend file * Press `Ctrl-J` to join the two preselected cubes * As the viewport *Backface culling* is enabled, see that one of the cubes now has flipped faces.
Author

Added subscriber: @rotoglup

Added subscriber: @rotoglup

#88164 was marked as duplicate of this issue

#88164 was marked as duplicate of this issue

#78508 was marked as duplicate of this issue

#78508 was marked as duplicate of this issue
Author

FWIW I'm able to workaround this using some scripting :

import bpy
import bmesh
import mathutils

for obj in bpy.context.selected_objects:
    
    if obj.type != 'MESH':
        continue

    if 0 > mathutils.Matrix.determinant(obj.matrix_world):    
        
        # create a single user mesh
        new_mesh = bpy.data.meshes.new_from_object(obj, preserve_all_data_layers=True)
        obj.data = new_mesh
        
        # reverse faces
        bm = bmesh.new()
        bm.from_mesh(obj.data)
        bmesh.ops.reverse_faces(bm, faces=bm.faces[:], flip_multires=True)
        bm.to_mesh(obj.data)
        bm.free()
    
bpy.ops.object.join()
FWIW I'm able to workaround this using some scripting : ``` import bpy import bmesh import mathutils for obj in bpy.context.selected_objects: if obj.type != 'MESH': continue if 0 > mathutils.Matrix.determinant(obj.matrix_world): # create a single user mesh new_mesh = bpy.data.meshes.new_from_object(obj, preserve_all_data_layers=True) obj.data = new_mesh # reverse faces bm = bmesh.new() bm.from_mesh(obj.data) bmesh.ops.reverse_faces(bm, faces=bm.faces[:], flip_multires=True) bm.to_mesh(obj.data) bm.free() bpy.ops.object.join() ```

Added subscriber: @mano-wii

Added subscriber: @mano-wii

Changed status from 'Needs Triage' to: 'Needs User Info'

Changed status from 'Needs Triage' to: 'Needs User Info'

Join is a simple operator. And it doesn't check, nor flip the faces when the matrix is negative.
I don't see this as a bug, the faces are flipped, but the renderers make up for it by checking the matrix.

What if an external renderer does not make this adjustment?
What if a modifier is counting on the current face orientation in a file?

If this change was in favor of a python script, I think this adjustment should be done in the script.

Join is a simple operator. And it doesn't check, nor flip the faces when the matrix is negative. I don't see this as a bug, the faces are flipped, but the renderers make up for it by checking the matrix. What if an external renderer does not make this adjustment? What if a modifier is counting on the current face orientation in a file? If this change was in favor of a python script, I think this adjustment should be done in the script.
Author

Hi, I see you changed the status to 'Needs Information from User', I'd be happy to, but I'm not sure what more information I could provide ?

I see the current behaviour of join as problematic because I can't detect or prevent face flips before joining, without coding a script :

For a negative-scaled object :

  • the 'solid' viewport shows no flipped face, even if backface culling is enabled
  • same if 'backface culling' is enabled in material Settings in Eevee
  • the 'face orientation' overlay does not show any flip either in this case (appears blue, not red)

As there is no warning either, the join operation may provoke had-to-detect (and hard-to-recover later) flips.

What if an external renderer does not make this adjustment?
What if a modifier is counting on the current face orientation in a file?

Being new to Blender, I can't really answer those questions.
As a developper, I'm not aware of a sensible use case where flips are not 'compensated' after negative scales, which happen a lot after mirrors & co.

Hi, I see you changed the status to *'Needs Information from User'*, I'd be happy to, but I'm not sure what more information I could provide ? I see the current behaviour of `join` as problematic because I can't detect or prevent face flips before joining, without coding a script : For a negative-scaled object : * the 'solid' viewport shows no flipped face, even if backface culling is enabled * same if 'backface culling' is enabled in material Settings in Eevee * the 'face orientation' overlay does not show any flip either in this case (appears blue, not red) As there is no warning either, the `join` operation may provoke had-to-detect (and hard-to-recover later) flips. > What if an external renderer does not make this adjustment? > What if a modifier is counting on the current face orientation in a file? Being new to Blender, I can't really answer those questions. As a developper, I'm not aware of a sensible use case where flips are not 'compensated' after negative scales, which happen a lot after mirrors & co.

Changed status from 'Needs User Info' to: 'Confirmed'

Changed status from 'Needs User Info' to: 'Confirmed'

Ok, marking it as know issue, since the priority is low and there are no plans to fix it soon.

Ok, marking it as know issue, since the priority is low and there are no plans to fix it soon.

Added subscriber: @ideasman42

Added subscriber: @ideasman42

Changed status from 'Confirmed' to: 'Archived'

Changed status from 'Confirmed' to: 'Archived'
Campbell Barton self-assigned this 2020-02-27 22:33:32 +01:00

Closing, since this is working as expected.

Flipping faces on join could be an option, though.

Closing, since this is working as expected. Flipping faces on join could be an option, though.

Added subscribers: @bblanimation, @iss

Added subscribers: @bblanimation, @iss

I don’t understand the latest comment from @ideasman42; how is it the expected behavior that a face normal would flip when joined with another object? It's a very unintuitive behavior that seems problematic to me from a usability standpoint.

I don’t understand the latest comment from @ideasman42; how is it the expected behavior that a face normal would flip when joined with another object? It's a very unintuitive behavior that seems problematic to me from a usability standpoint.

Added subscribers: @ZachHixson, @kioku, @filedescriptor

Added subscribers: @ZachHixson, @kioku, @filedescriptor

@bblanimation logically - an odd number of negative scale causes the face direction to flip.

Blender detects this and corrects for it when drawing.

When joining though, there is no logic in Blender to correct for this per-face, so the faces show as flipped.

Reversing the direction of a face can be done but it's a destructive modification to the mesh, while it's probably fine in most cases, features that depend on vertex order in the face would behave differently. Instancing geometry on faces for example.

We could accept this behavior (or have an option) I'm just noting that this is currently working as intended, and there are potential down-sides to flipping faces for the user.

@bblanimation logically - an odd number of negative scale causes the face direction to flip. Blender detects this and corrects for it when drawing. When joining though, there is no logic in Blender to correct for this per-face, so the faces show as flipped. Reversing the direction of a face can be done but it's a destructive modification to the mesh, while it's probably fine in most cases, features that depend on vertex order in the face would behave differently. Instancing geometry on faces for example. We could accept this behavior (or have an option) I'm just noting that this is currently working as intended, and there are potential down-sides to flipping faces for the user.

I submitted the duplicate of this a few days ago, having failed to find this. I thought it strange no one else had encountered it.

But how is this not a bug?

Someone says "Blender detects this and corrects for it when drawing" but that is just hiding the problem. The reversed faces are still there, and if you try to 3d print the model, it will have holes in it. I know, because I did that. The fact that Blender hides that is, frankly, worse than if it did not.

I submitted the duplicate of this a few days ago, having failed to find this. I thought it strange no one else had encountered it. But how is this not a bug? Someone says "Blender detects this and corrects for it when drawing" but that is just hiding the problem. The reversed faces are still there, and if you try to 3d print the model, it will have holes in it. I know, because I did that. The fact that Blender hides that is, frankly, worse than if it did not.
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
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
6 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#74237
No description provided.