Fix #103562: preserve custom normals in BM_mesh_triangulate #121871

Merged
Philipp Oeser merged 4 commits from lichtwerk/blender:103562 into main 2024-05-23 17:33:54 +02:00
Member

BM_mesh_triangulate is used in exporters (when the "Triangulate"
option is ON), the Triangulate modifier and currently also in the
Triangulate geometry node (even though there are plans to change this,
see !112264)

So in practice, exporters (Alembic/FBX/OBJ/Collada) were breaking
custom normals for game pipelines (unless everything was triangulated
beforehand).

This change builds upon 93c8955a72 (uses the use
BM_custom_loop_normals_to_vector_layer /
BM_custom_loop_normals_from_vector_layer pair of calls).

In the case of the Triangulate modifier, this had its own try at
preserving custom normals in 7d0fcaa69a -- doing very similar
things but as an option -- this is now removed (so it is always done,
which fits into "interpolate custom data if it's there" design that we have
nowadays).

NOTE: the "Triangulate Faces" operator already did the same

`BM_mesh_triangulate` is used in exporters (when the "Triangulate" option is ON), the `Triangulate` modifier and currently also in the `Triangulate` geometry node (even though there are plans to change this, see !112264) So in practice, exporters (Alembic/FBX/OBJ/Collada) were breaking custom normals for game pipelines (unless everything was triangulated beforehand). This change builds upon 93c8955a722b (uses the use `BM_custom_loop_normals_to_vector_layer` / `BM_custom_loop_normals_from_vector_layer` pair of calls). In the case of the `Triangulate` modifier, this had its own try at preserving custom normals in 7d0fcaa69a64 -- doing very similar things but as an option -- this is now removed (so it is always done, which fits into "interpolate custom data if it's there" design that we have nowadays). NOTE: the "Triangulate Faces" operator already did the same
Philipp Oeser added 1 commit 2024-05-16 14:32:11 +02:00
`BM_mesh_triangulate` is used in exporters (when the "Triangulate"
option is ON), the `Triangulate` modifier and currently also in the
`Triangulate` geometry node (even though there are plans to change this,
see !112264)

This change builds upon 93c8955a72 (uses the use
`BM_custom_loop_normals_to_vector_layer` /
`BM_custom_loop_normals_from_vector_layer` pair of calls).

In the case of the `Triangulate` modifier, this has its own try at
preserving custom normals -- doing very similar things, could probably
be removed then

NOTE: the "Triangulate Faces" operator already did the same
Philipp Oeser requested review from Hans Goudey 2024-05-16 14:32:28 +02:00
Philipp Oeser added this to the Modeling project 2024-05-16 14:32:43 +02:00
Philipp Oeser requested review from Campbell Barton 2024-05-16 14:32:53 +02:00
Philipp Oeser added the
Interest
Pipeline, Assets & IO
label 2024-05-16 14:33:02 +02:00
Hans Goudey reviewed 2024-05-16 14:41:00 +02:00
Hans Goudey left a comment
Member

Does this make the same function calls in calling code redundant? Looks like there's code near other uses of BM_mesh_triangulate that should be removed here.

Does this make the same function calls in calling code redundant? Looks like there's code near other uses of `BM_mesh_triangulate` that should be removed here.
Author
Member

Does this make the same function calls in calling code redundant? Looks like there's code near other uses of BM_mesh_triangulate that should be removed here.

I might be blind, got an example?

> Does this make the same function calls in calling code redundant? Looks like there's code near other uses of `BM_mesh_triangulate` that should be removed here. I might be blind, got an example?
Member

Two examples, so far include the modifier's use_clnors property (which suggests this should be optional maybe?) and any code using the "triangulate" BMesh operator ( edbm_quads_convert_to_tris_exec)

Two examples, so far include the modifier's `use_clnors` property (which suggests this should be optional maybe?) and any code using the "triangulate" BMesh operator ( `edbm_quads_convert_to_tris_exec`)
Philipp Oeser added 1 commit 2024-05-16 15:17:28 +02:00
Author
Member

the modifier's use_clnors property (which suggests this should be optional maybe?)

you mean the use_clnors used for subsurf? Or the keep_clnors used in the Triangulate modifier [that could probably go completely]?

>the modifier's `use_clnors` property (which suggests this should be optional maybe?) you mean the `use_clnors` used for subsurf? Or the `keep_clnors` used in the Triangulate modifier [that could probably go completely]?
Member

Oh sorry, I meant keep_clnors. Removing that seems fine, it aligns better with the "interpolate custom data if it's there" design that we have nowadays. It would involve removing the keep_custom_normals RNA property though.

Oh sorry, I meant `keep_clnors`. Removing that seems fine, it aligns better with the "interpolate custom data if it's there" design that we have nowadays. It would involve removing the `keep_custom_normals` RNA property though.
Campbell Barton approved these changes 2024-05-17 05:29:40 +02:00
Philipp Oeser added 2 commits 2024-05-22 14:02:37 +02:00
Remove the "Keep Normals" option from the modifier
All checks were successful
buildbot/vexp-code-patch-lint Build done.
buildbot/vexp-code-patch-linux-x86_64 Build done.
buildbot/vexp-code-patch-darwin-x86_64 Build done.
buildbot/vexp-code-patch-darwin-arm64 Build done.
buildbot/vexp-code-patch-windows-amd64 Build done.
buildbot/vexp-code-patch-coordinator Build done.
10637f8473
This is now always done.
Basically reverts 7d0fcaa69a.
Philipp Oeser requested review from Hans Goudey 2024-05-22 14:02:56 +02:00
Hans Goudey approved these changes 2024-05-23 17:04:11 +02:00
Author
Member

@blender-bot build

@blender-bot build
Philipp Oeser merged commit f3c32a36bc into main 2024-05-23 17:33:54 +02:00
Philipp Oeser deleted branch 103562 2024-05-23 17:33:56 +02:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
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
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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
3 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#121871
No description provided.