Highlighting and Selectability of gizmos using custom geometry

Hi,
Does anyone know how to make gizmos with custom geometry to properly highlight in the 3D view for Blender 2.8?

There is a python template called “gizmo_custom_geometry.py” which adds a gizmo with some custom geometry for the energy of lamps. When run, it appers properly along the Z axis of the lamp, and you can select it and move it. But the problem is that for some reason the gizmo is not becoming highlighted when the cursor is over the drawn custom geometry, instead it becomes highlighted when the cursor is over some kind of random area in the middle. This makes it hard to select. By adding the “SCALE” option to the GizmoGroup class, you can zoom into the geometry, making this fact even more evident.

This doesn’t happen with other built-in gizmos like “GIZMO_GT_arrow_3d” for any of the available draw types. The highlighting follows the 3D geometry properly in those cases, so I know it’s not impossible to make it work right.

I also noticed that there is some offset between the real geometry of the gizmo and the selectable area, which is very nice, and one of the main reasons why I want to use the default methods to create gizmos, instead of other hacky methods. If I’m not wrong I believe that this offset is also settable, but I don’t know how to specify that.

1 Like

Same here, is this getting addressed?

Finition is bad and the API info is missing about different gizmos

They just don’t care about this :confused:

This is very much still an issue, and the fact that the supplied example demontrates this problem is telling.

I’ve had most success with defining a gizmo using values in the 0-1 range, then using a scale_basis of 0.1.
Also, it seem to help to ensure the shape is as centered at the origin as possible.

For instance, if you create a simple triangle gizmo from this:
triangle = ((1, 0, 0), (-1, -1, 0), (-1, 1, 0))
using 0.1 for the scale_basis it selects very well.

Use a scale_basis of 1 (default) and the selectable area is outside, to the bottom right.

Curiously, creating a gizmo from
triangle = ((0.1, 0, 0), (-0.1, -0.1, 0), (-0.1, 0.1, 0))
using a scale_basis of 1, also doesn’t work and can only be selected from the outside, to the bottom left.

Something clearly doesn’t work correctly.

Apparently gizmo geometry complexity plays a role in this.

These triangle gizmos have selection issues:
tri_right = ((1, 0, 0), (-1, -1, 0), (-1, 1, 0))
tri_right = ((-1.0, -1.0, 0.0), (1.0, 0.0, 0.0), (-1.0, 1.0, 0.0))

Whereas this one with rounded corners selects great, with any scale basis:
tri_right = ((-1.0, 0.8235555291175842, 0.0), (-1.0, -0.8235555291175842, 0.0), (-0.8421832323074341, 0.921091616153717, 0.0), (-0.8421832323074341, -0.921091616153717, 0.0), (-0.8421832323074341, 0.921091616153717, 0.0), (-1.0, -0.8235555291175842, 0.0), (-1.0, -0.8235555291175842, 0.0), (-0.9922758936882019, -0.8742178082466125, 0.0), (-0.8909512758255005, -0.9368398189544678, 0.0), (-0.8909512758255005, -0.9368398189544678, 0.0), (-0.9922758936882019, -0.8742178082466125, 0.0), (-0.9349455833435059, -0.9337749481201172, 0.0), (-0.9922758936882019, -0.8742178082466125, 0.0), (-0.9698596596717834, -0.9121968150138855, 0.0), (-0.9349455833435059, -0.9337749481201172, 0.0), (-0.8909512758255005, -0.9368398189544678, 0.0), (-0.8421832323074341, -0.921091616153717, 0.0), (-1.0, -0.8235555291175842, 0.0), (-0.8421832323074341, -0.921091616153717, 0.0), (0.8421832323074341, -0.07890836894512177, 0.0), (0.8421832323074341, 0.07890836894512177, 0.0), (0.8421832323074341, -0.07890836894512177, 0.0), (0.8832272291183472, -0.050662294030189514, 0.0), (0.8421832323074341, 0.07890836894512177, 0.0), (0.8832272291183472, -0.050662294030189514, 0.0), (0.9048053026199341, -0.017457038164138794, 0.0), (0.9048053026199341, 0.017457038164138794, 0.0), (0.9048053026199341, 0.017457038164138794, 0.0), (0.8832272291183472, 0.050662294030189514, 0.0), (0.8832272291183472, -0.050662294030189514, 0.0), (0.8832272291183472, 0.050662294030189514, 0.0), (0.8421832323074341, 0.07890836894512177, 0.0), (0.8832272291183472, -0.050662294030189514, 0.0), (0.8421832323074341, 0.07890836894512177, 0.0), (-0.8421832323074341, 0.921091616153717, 0.0), (-0.8421832323074341, -0.921091616153717, 0.0), (-0.8421832323074341, 0.921091616153717, 0.0), (-0.8909512758255005, 0.9368398189544678, 0.0), (-1.0, 0.8235555291175842, 0.0), (-0.8909512758255005, 0.9368398189544678, 0.0), (-0.9349455833435059, 0.9337749481201172, 0.0), (-0.9698596596717834, 0.9121968150138855, 0.0), (-0.9698596596717834, 0.9121968150138855, 0.0), (-0.9922758936882019, 0.8742178082466125, 0.0), (-0.8909512758255005, 0.9368398189544678, 0.0), (-0.9922758936882019, 0.8742178082466125, 0.0), (-1.0, 0.8235555291175842, 0.0), (-0.8909512758255005, 0.9368398189544678, 0.0))

This problem seems to have finally been addressed for Blender 2.91.
The fix comes from: https://developer.blender.org/rBefc97b3919ea4fd46b9d2e931ca3fea27e7ea31c

This is one of the bug reports related to this problem, now closed: https://developer.blender.org/T61388

I tried the template with a build of 2.91 and everything seems to work fine, with all scale basis, even with the problematic triangle cases that you mentioned.

Well, it took more then a year, but finally resolved.

1 Like

That seems to be working much better now! Thanks for letting me know, perfect timing!

1 Like