Can't select vertices in a negative scale object, with ALT-B mask active and "limit selection to visible" disabled #42264

Closed
opened 2014-10-16 22:58:20 +02:00 by Marcus Richter · 10 comments

System Information
Windows 8.1
CPU: FX 8350
GPU: GTX 660Ti
RAM: 24Gb DDR3

Blender Version
Broken: Any version
Worked: None

Short description of error
Users can't select vertices in an object that has been flipped on the x/y/z axis in object mode, if ALT-B mask is active and "limit selection to visible" is disabled.
It must be a bug since selecting without an ALT-B mask is possible.
The problem can be solved by applying the scale of the object and flipping the normals

Exact steps for others to reproduce the error
bug_report.blend
To reproduce, start a new project, add any object, scale to negative on any axis, ALT-B mask part of the viewport, disable "limit selection to visible" and you won't be able to select vertices in the object.

**System Information** Windows 8.1 CPU: FX 8350 GPU: GTX 660Ti RAM: 24Gb DDR3 **Blender Version** Broken: Any version Worked: None **Short description of error** Users can't select vertices in an object that has been flipped on the x/y/z axis in object mode, if ALT-B mask is active and "limit selection to visible" is disabled. It must be a bug since selecting without an ALT-B mask is possible. The problem can be solved by applying the scale of the object and flipping the normals **Exact steps for others to reproduce the error** [bug_report.blend](https://archive.blender.org/developer/F117845/bug_report.blend) To reproduce, start a new project, add any object, scale to negative on any axis, ALT-B mask part of the viewport, disable "limit selection to visible" and you won't be able to select vertices in the object.
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @mstuff

Added subscriber: @mstuff
Author

Feel free to add this to low priority, it is not important.
Also I accidentally added a wireframe modifier to the object in the .blend, just ignore it.

Feel free to add this to low priority, it is not important. Also I accidentally added a wireframe modifier to the object in the .blend, just ignore it.

Added subscriber: @mont29

Added subscriber: @mont29

Added subscriber: @ideasman42

Added subscriber: @ideasman42
Bastien Montagne self-assigned this 2014-10-18 23:03:27 +02:00

Wow… this one was a nice hidden one, took me some time to figure it out.

Dev note: Issue comes from the fact that we transform a bbox with the object matrix… which can lead to bad-ordered bbox, yielding invalid clipping planes (ED_view3d_clipping_local, in view3d_edit.c). Here is a proposed patch, which merely ensure all eight bbox vertices are in the right order (as defined in DNA_object_types.h).

P156: #42264

diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 6c0b9f3..aba6e24 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -4390,6 +4390,41 @@ static void calc_clipping_plane(float clip- [x]- [x], const BoundBox *clipbb)
 	}
 }
 
+/* BoundBox is expected to be sorted in a specific order (see its declaration), some operations may break this. */
+static void sort_boundbox(BoundBox *bb)
+{
+	int i, j, k;
+
+	/* X-sorting. */
+	for (i = 0; i < 4; i++) {
+		if (bb->vec- [x]- [x] > bb->vec[i + 4][0]) {
+			swap_v3_v3(bb->vec- [x], bb->vec[i + 4]);
+		}
+	}
+
+	/* Y-sorting. */
+	for (i = 0, j = 3; i < 2; i++, j -= 2) {
+		k = i + 4;
+		if (bb->vec- [x]- [x] > bb->vec[i + j][1]) {
+			swap_v3_v3(bb->vec- [x], bb->vec[i + j]);
+		}
+		if (bb->vec- [x]- [x] > bb->vec[k + j][1]) {
+			swap_v3_v3(bb->vec- [x], bb->vec[k + j]);
+		}
+	}
+
+	/* Z-sorting. */
+	for (i = 0, j = 1; i < 4; i += 3, j -= 2) {
+		k = i + 4;
+		if (bb->vec- [x]- [x] > bb->vec[i + j][2]) {
+			swap_v3_v3(bb->vec- [x], bb->vec[i + j]);
+		}
+		if (bb->vec- [x]- [x] > bb->vec[k + j][2]) {
+			swap_v3_v3(bb->vec- [x], bb->vec[k + j]);
+		}
+	}
+}
+
 static void calc_local_clipping(float clip_local- [x]- [x], BoundBox *clipbb, float mat- [x][4])
 {
 	BoundBox clipbb_local;
@@ -4402,6 +4437,9 @@ static void calc_local_clipping(float clip_local- [x]- [x], BoundBox *clipbb, float
 		mul_v3_m4v3(clipbb_local.vec- [x], imat, clipbb->vec[i]);
 	}
 
+	/* Above obmat multiplication may have broken 'good' sorting of our local bbox! */
+	sort_boundbox(&clipbb_local);
+
 	calc_clipping_plane(clip_local, &clipbb_local);
 }
 

However, I have a feeling such bbox manipulations should be done in BLI (math_geom perhaps? or even its own file?), that kind of issue may very well exist in other places too… That’d be a bigger task though, Campbell, what do you think?

Wow… this one was a nice hidden one, took me some time to figure it out. Dev note: Issue comes from the fact that we transform a bbox with the object matrix… which can lead to bad-ordered bbox, yielding invalid clipping planes (`ED_view3d_clipping_local`, in `view3d_edit.c`). Here is a proposed patch, which merely ensure all eight bbox vertices are in the right order (as defined in `DNA_object_types.h`). [P156: #42264](https://archive.blender.org/developer/P156.txt) ``` diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 6c0b9f3..aba6e24 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -4390,6 +4390,41 @@ static void calc_clipping_plane(float clip- [x]- [x], const BoundBox *clipbb) } } +/* BoundBox is expected to be sorted in a specific order (see its declaration), some operations may break this. */ +static void sort_boundbox(BoundBox *bb) +{ + int i, j, k; + + /* X-sorting. */ + for (i = 0; i < 4; i++) { + if (bb->vec- [x]- [x] > bb->vec[i + 4][0]) { + swap_v3_v3(bb->vec- [x], bb->vec[i + 4]); + } + } + + /* Y-sorting. */ + for (i = 0, j = 3; i < 2; i++, j -= 2) { + k = i + 4; + if (bb->vec- [x]- [x] > bb->vec[i + j][1]) { + swap_v3_v3(bb->vec- [x], bb->vec[i + j]); + } + if (bb->vec- [x]- [x] > bb->vec[k + j][1]) { + swap_v3_v3(bb->vec- [x], bb->vec[k + j]); + } + } + + /* Z-sorting. */ + for (i = 0, j = 1; i < 4; i += 3, j -= 2) { + k = i + 4; + if (bb->vec- [x]- [x] > bb->vec[i + j][2]) { + swap_v3_v3(bb->vec- [x], bb->vec[i + j]); + } + if (bb->vec- [x]- [x] > bb->vec[k + j][2]) { + swap_v3_v3(bb->vec- [x], bb->vec[k + j]); + } + } +} + static void calc_local_clipping(float clip_local- [x]- [x], BoundBox *clipbb, float mat- [x][4]) { BoundBox clipbb_local; @@ -4402,6 +4437,9 @@ static void calc_local_clipping(float clip_local- [x]- [x], BoundBox *clipbb, float mul_v3_m4v3(clipbb_local.vec- [x], imat, clipbb->vec[i]); } + /* Above obmat multiplication may have broken 'good' sorting of our local bbox! */ + sort_boundbox(&clipbb_local); + calc_clipping_plane(clip_local, &clipbb_local); } ``` However, I have a feeling such bbox manipulations should be done in BLI (math_geom perhaps? or even its own file?), that kind of issue may very well exist in other places too… That’d be a bigger task though, Campbell, what do you think?

This issue was referenced by 3138d39047

This issue was referenced by 3138d390478524bd6c9d25454933ab8cf5ecb349

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

Closed by commit 3138d39047.

Closed by commit 3138d39047.

This issue was referenced by 68b0b7c1f1

This issue was referenced by 68b0b7c1f1be8bf6d2541f094e5d61b8b2b505d6
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
4 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#42264
No description provided.