Threshold of the 'Select Similar' operator (Shift G) is very limited at large scales. #81542

Open
opened 2020-10-08 15:08:01 +02:00 by Adam Preisler · 6 comments

Hi,
since I'm working on a project in Unreal Engine it needs to be actually done in centimeters (meaning in mesh-terms it's 100 bigger than meter mesh).

Here is the blend file: ShiftG_SelectSimilarArea_CantPutInMoreThan1.000.blend
Try to select a face and Shift+G -> Select Similar (not sure if the shortcut stayed that way)
image.png

I'm running into an issue here and there where some functions expect the mesh to be in meters and work worse in centimeters (or not at all)

For example here I was using Shift+G and Area to get the faces with the same area. Because the areas in the centimeters model are so big number-wise it doesn't find any match. So either I think the amount needs to be unlimited (I would put in 100 and that would probably have the same results as when the mesh is 100x smaller) or this needs to be addressed from the unit scale side of things.

This is in Meters (scaled the mesh 0.01), we get a good window selection because they are mostly the same:
image.png
And in Centimeters nothing more than the one face is selected.
image.png

Maybe the scale in Units should be used in these operators to make the mesh smaller?
image.png

Thanks for looking into this.

Hi, since I'm working on a project in Unreal Engine it needs to be actually done in centimeters (meaning in mesh-terms it's 100 bigger than meter mesh). Here is the blend file: [ShiftG_SelectSimilarArea_CantPutInMoreThan1.000.blend](https://archive.blender.org/developer/F8967827/ShiftG_SelectSimilarArea_CantPutInMoreThan1.000.blend) Try to select a face and Shift+G -> Select Similar (not sure if the shortcut stayed that way) ![image.png](https://archive.blender.org/developer/F8967832/image.png) I'm running into an issue here and there where some functions expect the mesh to be in meters and work worse in centimeters (or not at all) For example here I was using Shift+G and Area to get the faces with the same area. Because the areas in the centimeters model are so big number-wise it doesn't find any match. So either I think the amount needs to be unlimited (I would put in 100 and that would probably have the same results as when the mesh is 100x smaller) or this needs to be addressed from the unit scale side of things. This is in Meters (scaled the mesh 0.01), we get a good window selection because they are mostly the same: ![image.png](https://archive.blender.org/developer/F8967814/image.png) And in Centimeters nothing more than the one face is selected. ![image.png](https://archive.blender.org/developer/F8967820/image.png) Maybe the scale in Units should be used in these operators to make the mesh smaller? ![image.png](https://archive.blender.org/developer/F8967810/image.png) Thanks for looking into this.
Author

Added subscriber: @AdamPreisler

Added subscriber: @AdamPreisler

Added subscriber: @mano-wii

Added subscriber: @mano-wii

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'

We could make the threshold value unlimited, but we cannot set a unit for it, since this unit depends on the "type" property (which can be Area, Length or Angle).
Unfortunately, if I'm not mistaken, there is no API to change the subtype of one property depending on another.

It is really inconvenient to limit the threshold value to 1.0.
So I'm marking this report as TO DO (Papercuts).

We could make the threshold value unlimited, but we cannot set a unit for it, since this unit depends on the "type" property (which can be Area, Length or Angle). Unfortunately, if I'm not mistaken, there is no API to change the subtype of one property depending on another. It is really inconvenient to limit the threshold value to 1.0. So I'm marking this report as TO DO (Papercuts).
Germano Cavalcante changed title from Using Shift+G (Select Similar) is broken when using different units than default meters to Threshold of the 'Select Similar' operator (Shift G) is very limited at large scales. 2020-10-10 01:54:47 +02:00

Added subscriber: @erik85

Added subscriber: @erik85
Erik Abrahamsson self-assigned this 2020-10-24 15:00:56 +02:00

I tried to fix this in a simple way by multiplying the threshold value with the value that is compared against. And if delta is negative, the threshold is multiplied by 0.5 to make the range between 50% smalller to 100% bigger. Do you see any problems with this? Will it mess with any other select similar modes?

bool ED_select_similar_compare_float_tree(const KDTree_1d *tree,
                                          const float length,
                                          const float thresh,
                                          const int compare)
{
  /* Length of the edge we want to compare against. */
  float nearest_edge_length;

  switch (compare) {
    case SIM_CMP_EQ:
      /* Compare to the edge closest to the current edge. */
      nearest_edge_length = length;
      break;
    case SIM_CMP_GT:
      /* Compare against the shortest edge. */
      /* -FLT_MAX leads to some precision issues and the wrong edge being selected.
       * For example, in a tree with 1, 2 and 3, which is stored squared as 1, 4, 9,
       * it returns as the nearest length/node the "4" instead of "1". */
      nearest_edge_length = -1.0f;
      break;
    case SIM_CMP_LT:
      /* Compare against the longest edge. */
      nearest_edge_length = FLT_MAX;
      break;
    default:
      BLI_assert(0);
      return false;
  }

  KDTreeNearest_1d nearest;
  if (BLI_kdtree_1d_find_nearest(tree, &nearest_edge_length, &nearest) != -1) {
    float delta = length - nearest.co[0];

--->    const float calc_thresh = fabsf(nearest.co[0]) * thresh * (delta < FLT_EPSILON ? 0.5f : 1.0f);
    return ED_select_similar_compare_float(delta, calc_thresh, compare);

  }

  return false;
}```
I tried to fix this in a simple way by multiplying the threshold value with the value that is compared against. And if delta is negative, the threshold is multiplied by 0.5 to make the range between 50% smalller to 100% bigger. Do you see any problems with this? Will it mess with any other select similar modes? ``` bool ED_select_similar_compare_float_tree(const KDTree_1d *tree, const float length, const float thresh, const int compare) { /* Length of the edge we want to compare against. */ float nearest_edge_length; switch (compare) { case SIM_CMP_EQ: /* Compare to the edge closest to the current edge. */ nearest_edge_length = length; break; case SIM_CMP_GT: /* Compare against the shortest edge. */ /* -FLT_MAX leads to some precision issues and the wrong edge being selected. * For example, in a tree with 1, 2 and 3, which is stored squared as 1, 4, 9, * it returns as the nearest length/node the "4" instead of "1". */ nearest_edge_length = -1.0f; break; case SIM_CMP_LT: /* Compare against the longest edge. */ nearest_edge_length = FLT_MAX; break; default: BLI_assert(0); return false; } KDTreeNearest_1d nearest; if (BLI_kdtree_1d_find_nearest(tree, &nearest_edge_length, &nearest) != -1) { float delta = length - nearest.co[0]; ---> const float calc_thresh = fabsf(nearest.co[0]) * thresh * (delta < FLT_EPSILON ? 0.5f : 1.0f); return ED_select_similar_compare_float(delta, calc_thresh, compare); } return false; }```
Philipp Oeser removed the
Interest
Modeling
label 2023-02-09 15:28:57 +01:00
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#81542
No description provided.