Decoupling x-ray and limit selection to visible

Made an account just to chime in and add a +1 to this. I’m a user attempting the move from Maya to Blender, and this is the most annoying thing. Also, face dots? The heckie is that, lemme select my faces normally pls.

2 Likes

Raycast selection is so important. XSI and MODO gets this right. In Blender its so clunky to have to toggle wireframe or Xray mode to select backfacing polygons/components.
See what the Modo 2 Blender keymap does in this regard. It uses a script to temporarily toggle Xray mode while you’re selecting with your mmb.
Williams assertion that other apps only have one method is not correct. In Modo you can either select what you see, or select backfacing polys. MMB selects backfacing and RMB selects what you can see.
XSI had this as well. And I’m pretty sure they are not the only ones. In fact the only other app which doesn’t have a raycast (backfacing polys) selection is LightWave and that program is on death row.

I am doing some blender again and still can’t believe this design decision. Maybe you can change this into a donation challenge. I would be willing to contribute. :slight_smile:

I would even be happy if the checkbox would burried deep down in the preferences so I can enable it once.

3 Likes

@kio Hey Ben, now that 2.82’s stable release is out, do you think you could redo the patch you did for this new version? I still use that custom build of Blender. Since then some files were moved around by the devs so applying your changes isn’t quite as easy as before. New plugin versions like BoxCutter are slowly leaving that old version behind.

Even if the Blender devs don’t implement this, it would be fantastic if you could re-apply your changes to this new stable build so that others can use it.

Same here! :slight_smile: It’s been essential for me as well.

I have a workaround that might help ease the pain of those who need this feature. (But I think this functionality should be part of blender, properly implemented.)
I wrote myself a small script some time ago, I guess it’s not much different than what’s included in the suggested add-ons.
It’s a macro that in the moment of box selection it triggers x-ray and hides the back wires. When the selection is finished x-ray is turned off. It doesn’t interfere with regular x-ray usage.

oskar_select_through_small
Limitations:

  • in the moment of box selection the face dots are used instead
  • occasionally when you click, drag and release very fast (usually when deselecting) it might not turn off the x-ray. It gets fixed on the next selection.

The same idea can be used for lasso selection.

I made a 2 min video showing how to install it and add it to your keymap.

Here is the script, just copy this to a new text file and save it as a python script.
(oskar_select_through.py for example)

# ##### BEGIN GPL LICENSE BLOCK #####
#
#  This program is free software; you can redistribute it and/or
#  modify it under the terms of the GNU General Public License
#  as published by the Free Software Foundation; either version 2
#  of the License, or (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software Foundation,
#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####


import bpy
from bpy.types import Operator, Macro

bl_info = {
    'name': 'Select Through',
    'description': 'Box select components in shaded mode that are not visible. Optional/default behavior in most 3D software.',
    'author': 'Oskar',
    'license': 'GPL',
    'version': (0, 1),
    'blender': (2, 80, 0),
    'category': 'Interface'
    }

class OSR_OT_xray_on(bpy.types.Operator):
    """Turn xray on"""
    bl_idname = "osr.xray_on"
    bl_label = "OSR: XRay On"
    
    
    # ==== CHANGE SETTINGS HERE ====
    
    # This controls the alpha of the shaded geometry, while box selecting.
    xray_alpha = 1
    
    # This controls the opacity of the wires that are behind (not visible in shaded mode). 
    # If you want to see a bit of the wires and components behind while selecting set it above 0 to max 1.
    backwire_opacity = 0
    # ==============================
    
    
    def execute(self, context):
        scene = bpy.context.scene
        # There seems to be a problem. Sometimes the macro is not executed properly when we click very fast. 
        # Instead of all classes in the macro, just the first one is executed.
        prop = scene.get("osr_select_through_macro_fail", None)
        
        # If xray_off did not fail
        if prop is None or prop == False:
            scene["osr_xray_last_state"] = context.space_data.shading.show_xray
            scene["osr_xray_last_alpha"] = context.space_data.shading.xray_alpha

        if scene["osr_xray_last_state"] == False:
            context.space_data.shading.show_xray = True
            context.space_data.shading.xray_alpha = self.xray_alpha
            context.space_data.overlay.backwire_opacity = self.backwire_opacity
        
        # We consider the macro failed unless xray_off is executed
        scene["osr_select_through_macro_fail"] = True
        
        return {'FINISHED'}
        
class OSR_OT_xray_off(bpy.types.Operator):
    """Turn x-ray off"""
    bl_idname = "osr.xray_off"
    bl_label = "OSR: XRay Off"
    
    def execute(self, context):
        
        scene = bpy.context.scene
        prop = scene.get("osr_select_through_macro_fail", None)
        
        if prop is not None:
            context.space_data.shading.show_xray = scene["osr_xray_last_state"]
            context.space_data.shading.xray_alpha = scene["osr_xray_last_alpha"]
        
        # Set the default backwire_opacity
        context.space_data.overlay.backwire_opacity = .5
        
        scene["osr_select_through_macro_fail"] = False
        return {'FINISHED'}


class OSR_OT_select_through_macro(Macro):    
    bl_idname = 'osr.select_through'
    bl_label = 'OSR: Select Through'
    bl_options = {'REGISTER', 'UNDO'}


classes = (
    OSR_OT_xray_on,
    OSR_OT_xray_off,
    OSR_OT_select_through_macro,
    )


def register():
    for c in classes:
        bpy.utils.register_class(c)
    
    OSR_OT_select_through_macro.define("OSR_OT_xray_on")
    OSR_OT_select_through_macro.define("VIEW3D_OT_select_box")
    OSR_OT_select_through_macro.define('OSR_OT_xray_off')
    

def unregister():
    for c in reversed(classes):
        bpy.utils.unregister_class(c)


if __name__ == "__main__":
    register()

    

Command for the keymap:

osr.select_through
6 Likes

Thanks for sharing Oskar, this seems like a good workaround, even if not perfect. I assume this is compatible with the latest stable release of 2.82? I might need to resort to this if @kio doesn’t show up.

Unfortunately, this fixes only one third of the issue.

Other two thirds are:

  1. Xray in face mode uses face dots radically changing the selection method
  2. In edge mode, edge selection randomly changes between overlap and contain, making it impossible to reliably select edges.

Yeah, another thing I love about benjamin’s build is how it seems to remove the facedot center selections during Xray mode.

@Rawalanche yep, unfortunately you’re right.
About edge mode, it seems like if there are no edges completely covered by the selection box it uses overlap and if there is at least one it uses contain. Which is not the way it works in shaded mode and it’s kind of weird.

Yes, it works with 2.83 Alpha too.

I agree it’s utterly inconsistent behavior for Blender’s box/lasso edge selection to switch between contained and overlap testing while face selection always uses overlap testing.

This “smart” testing should really be exposed in the tool setting or keymap option for the box/lasso(and circle?) operator so the user can control it.

  • Smart test (current behavior)
  • Overlap test
  • Contained test

There’s a relatively popular proposal on right click select that would perfectly tie into exposing the test type to user control.

No. The already ridiculously cluttered mess of different selection method switches should not become even more cluttered.

Hello @Justo , could you give us some quick instructions to custom build with this patch ? I have been searching for hours without succes for the correct commit version to do the “git apply D6322.diff”… i am also a bit lost as i get errors such as “trailing whitespace.” when i try to “git apply”.
cheers

I believe this thread is relevant for the discussion.

1 Like

Hey there - I was lucky enough that I did it alongside a coworker who deals with coding a lot more frequently than I, so he handled the brunt of it. No idea about that trailing whitespace error, sorry. As for searching the correct commit version, I recall we just chose the closest one matching the date from Benjamin’s first post of the patch.

I could upload the compiled Blender version though, if you’d like. :slight_smile:

Nice gif)
Interesting solution

2 Likes

The main issue, is that this option conflicts with Blender’s current paradigm, which is ‘you select what you can see’.

This is the key issue. We have to approach this as a disagreement in design philosophy. It’s not about “it’s just because this is how it’s done in other apps”. I think we need to at least make an attempt to compromise first and a find a solution that works for the community as a whole, including potential new users. Blender just has a different philosophy. There are many traditional Blender users that prefer this paradigm. However, it’s not consistent since you can double click to select an object behind and select-through with box selection in object mode without turning on X-ray. I think we should start from the inconsistency in implementation of this design philosophy first and work our way through a good compromise in design philosophy. I come from using other apps as well, but we need to take a step back and imagine how we would react if Blender users go to Maya, Modo, 3DsMax, Houdini, etc. forums and disagree this way. This is a difficult design problem to solve. I don’t envy William. He’s constantly caught between long time Blender users and users coming from other apps.

I find it hard to see what’s the problem in allowing users to select things differently…If we’re speaking stricly about design philosophies only, I would expect the best app ever to be flexible enough to mold itself to its users’ preferences. You want to select things with Right click? Sure. Left click? No problem. Select through geometry, or only visible elements? As you wish.

(54:23) It pains me too how this topic is brought up almost every livestream and it’s glossed over so fast haha

6 Likes

If Blender users went on a Maya forum and disagreed with select-through then the Maya users would tell them to enable “Automatic camera-based selection” in the settings for the Select Tool.

The end.

Because Maya is flexible enough to let the user choose either selection philosophy (“select-through” or “you select what you can see”). You can make Maya’s component selection work exactly like Blender and you don’t even need addons or custom code. It’s built-in and everyone can be happy with their preferred selection philosophy.

In a broad sense the push/pull between newcomers and Blender veterans is indeed difficult but in this specific instance giving the user the ability to choose whether they want to select-through or not is already a solved problem and does not require overthinking. Both can exist in the same program. The “compromise” is to become more flexible and let the end user make their own preferred choice. Neither philosophy should be the only way to select things.

6 Likes

Exatctly! I couldn’t agree more!