some wrong edges selected after knife project #45009

Closed
opened 2015-06-09 21:52:30 +02:00 by mathieu menuet · 8 comments

System Information
Win7 x64

Blender Version
Broken: 94e7ac5

Short description of error
After calling "knife project" some edges are in the selection although they shouldn't.

Exact steps for others to reproduce the error
Open Attached file, call "knife project"
bug_knife_project_selection.blend
You get this:
bug knife project selection.png
Notice the triangle in red circle which shouldn't be selected.

**System Information** Win7 x64 **Blender Version** Broken: 94e7ac5 **Short description of error** After calling "knife project" some edges are in the selection although they shouldn't. **Exact steps for others to reproduce the error** Open Attached file, call "knife project" [bug_knife_project_selection.blend](https://archive.blender.org/developer/F188429/bug_knife_project_selection.blend) You get this: ![bug knife project selection.png](https://archive.blender.org/developer/F188430/bug_knife_project_selection.png) Notice the triangle in red circle which shouldn't be selected.
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @bliblubli

Added subscriber: @bliblubli

Added subscribers: @ideasman42, @mont29

Added subscribers: @ideasman42, @mont29
Bastien Montagne self-assigned this 2015-06-10 13:29:22 +02:00

Hehe, was fun to track down… So, issue comes from erroneous code to chose a point inside a 'knife face' (edbm_mesh_knife_face_point()) - computing the area of triangulated face is rather fantasist, this oneliner patch fixes it:

P232: #45009

diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index cfd0d3f..b7e1128 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -3371,9 +3371,7 @@ static void edbm_mesh_knife_face_point(BMFace *f, float r_cent[3])
 		const float *p3 = loops[index- [x]- [x]]->v->co;
 		float area;
 
-		float cross[3];
-		cross_v3_v3v3(cross, p2, p3);
-		area = fabsf(dot_v3v3(p1, cross));
+		area = area_squared_tri_v3(p1, p2, p3);
 		if (area > area_best) {
 			j_best = j;
 			area_best = area;

Note that the issue only appears when triangulation of the face produces degenerated triangles, with all three points aligned on a cutting edge, which is the case in this example. Quite a nice corner case. ;)

@ideasman42 see anything wrong in proposed patch?

Hehe, was fun to track down… So, issue comes from erroneous code to chose a point inside a 'knife face' (`edbm_mesh_knife_face_point()`) - computing the area of triangulated face is rather fantasist, this oneliner patch fixes it: [P232: #45009](https://archive.blender.org/developer/P232.txt) ``` diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index cfd0d3f..b7e1128 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -3371,9 +3371,7 @@ static void edbm_mesh_knife_face_point(BMFace *f, float r_cent[3]) const float *p3 = loops[index- [x]- [x]]->v->co; float area; - float cross[3]; - cross_v3_v3v3(cross, p2, p3); - area = fabsf(dot_v3v3(p1, cross)); + area = area_squared_tri_v3(p1, p2, p3); if (area > area_best) { j_best = j; area_best = area; ``` Note that the issue only appears when triangulation of the face produces degenerated triangles, with all three points aligned on a cutting edge, which is the case in this example. Quite a nice corner case. ;) @ideasman42 see anything wrong in proposed patch?

Btw, this code can still theoretically generate points outside of actual quad face...

Btw, this code can still theoretically generate points outside of actual quad face...

This issue was referenced by ec3c2d3be9

This issue was referenced by ec3c2d3be9ac97446d3f32cc9f3e90e2ad93422f

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Author

thanks for the fix Bastien! Glad you had some fun :) Nailing bug is sometime really hard and boring :(

thanks for the fix Bastien! Glad you had some fun :) Nailing bug is sometime really hard and boring :(
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
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#45009
No description provided.