Fix #120239: Snap in edit mode is ignoring some self elements #120270
No reviewers
Labels
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
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#120270
Loading…
Reference in New Issue
No description provided.
Delete Branch "mano-wii/blender:fix_120239"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Caused by commit
1c77779160
, where we start creating a meshrepresenting the edited mesh.
Mesh Snap to Vertex works in the following order:
The problem occurs because, in editing mode, we ignore faces whose
vertices are being transformed. We mark this face as being hidden in
the snap. Consequently, we lose some vertices in triangles.
The solution is to consider the edges and vertices of hidden faces as
loose elements since, although connected to faces, they are still
visible to snap.
Therefore, two new types of BVHTree were created:
The disadvantage of this solution is that we can no longer rely oncached
mesh->loose_verts()
andmesh->loose_edges()
which can be badfor performance.
Tagging @HooglyBoogly as reviewer because:
@blender-bot build
@ -783,0 +800,4 @@
if (hide_edge[i]) {
continue;
}
for (const int vert_index : {edges[i][0], edges[i][1]}) {
vert_index
->vert
Just a shorter name that gets the same thing across. Conceptually a vertex is just an index in these arrays anyway
@ -783,0 +831,4 @@
AttributeAccessor attributes = mesh.attributes();
const OffsetIndices<int> &faces = mesh.faces();
const Span<int> &corner_edges = mesh.corner_edges();
const VArray<bool> &hide_poly = *attributes.lookup_or_default(
const
for the attribute accessor@ -783,0 +840,4 @@
if (hide_poly[i]) {
continue;
}
for (const int corner_index : faces[i]) {
for (const int edge : corner_edges.slice(faces[i])) {
@ -857,2 +938,2 @@
case BVHTREE_FROM_LOOSEVERTS: {
const LooseVertCache &loose_verts = mesh->loose_verts();
case BVHTREE_FROM_VERTS:
case BVHTREE_FROM_LOOSEVERTS:
Better keep the existing switch statements as is. Duplicating some code is better than the spaghetti logic happening here now.
@ -869,0 +960,4 @@
int mask_bits_act_len = -1;
BitSpan mask = {};
BitVector<> mask_stack;
if (bvh_cache_type == BVHTREE_FROM_LOOSEEDGES_NO_HIDDEN) {
Same here
@ -425,3 +425,3 @@
}
static eSnapMode mesh_snap_mode_supported(const Mesh *mesh)
static eSnapMode mesh_snap_mode_supported(const Mesh *mesh, const bool is_from_edit_mesh)
Better name
is_from_edit_mesh
something a bit more specific likeskip_hidden
. Otherwise it becomes a catch-all for changing the behavior of this function in arbitrary waysChanges made.
Given that the parameters
is_from_edit_mesh
anduse_hide
serve the same purpose of skipping hidden elements, I combined them once again and renamed it toskip_hidden
for better clarity.With this modification, both related issues (snapping to edit mesh for vertices and edges of a face being transformed and snapping to mesh with hidden loose elements) are addressed simultaneously.
Optionally, we could address the first issue separately by generating the BVHTrees within the snap system itself. These BVHTrees would be stored in a
SnapCache_EditMesh *em_cache
, which would then be passed as a parameter to the snap to Mesh function (snap_object_mesh
). This would allowsnap_object_mesh
to utilize these BVHTrees instead of storing them in theMesh
itself.The drawback of this approach is that resolving the other issue (snapping to mesh with hidden loose elements) would require creating the same BVHTree and storing it in the
Mesh
cache, essentially redoing the actual code in this PR.