Skip to content

Conversation

rcarmo
Copy link

@rcarmo rcarmo commented May 4, 2025

I noticed that the batch_for_shader function was generating internal errors in Blender 4.4, so I went down that rabbit hole and indirectly fixed all the selection errors I was having - and also refactored the workplane selection.

Right now box selection works, including for overlapping entities (at least as far as I can understand it), so I think this fixes #50 as well

@rcarmo rcarmo mentioned this pull request May 4, 2025
@hlorus
Copy link
Owner

hlorus commented May 4, 2025

Hey these are great changes, thanks! I still have some input however:

Overlapping entity selection:

Workplane selection:

  • the workplane selection doesn't seem to respect depth, so the workplane that is last drawn obscures the other planes, can this be improved?
  • it would be great if the edges of the workplane would have priority such that they could also be selected if obscured by another plane

@rcarmo
Copy link
Author

rcarmo commented May 4, 2025

No, you should just be able to click to cycle through overlapping entities (I am testing with two lines that partially overlap). Box selection works as far as I can tell.

I will look at the workplace selection a bit better. I was annoyed that I could't select them without clicking the edges because, to be honest, they are very small targets. I might need to track drawing order...

@rcarmo
Copy link
Author

rcarmo commented May 4, 2025

Well, I can now pick workplanes through other workplanes, but I can't really get it to work reliably regarding the edges. I think I'll pause this, I've found I can easily select any workplane by moving the mouse to it even through another....

@rcarmo
Copy link
Author

rcarmo commented May 4, 2025

If you're OK with this, can we merge this one? I'd like to keep PRs relatively small.

@hlorus
Copy link
Owner

hlorus commented May 5, 2025

It behaves a bit weird, when i move the cursor away from the plane it stays hovered, also i cannot manage to select a plane border through another plane.

Screencast.From.2025-05-05.08-08-37.mp4

Normal entity selection is almost entirely broken for me.

@rcarmo
Copy link
Author

rcarmo commented May 5, 2025

Well, that's because I am clamping the selection to make it easier to use with a trackpad.

As to the borders, I've tried many things, but I just can't make them be consistently "in front" of the planes and they are very hard to select, even when increasing the tolerance/line width (I dialed that back in my last commit, must have affected the selection because there is just the one constant).

I'll have another go. I can remove the clamping and tweak the tolerances again, but TBH selecting the planes via the borders doesn't seem trivial.

@hlorus
Copy link
Owner

hlorus commented May 6, 2025

Amazing, the workplane selection works great! I still get an error when trying to write out the selection texture:
AttributeError: 'NoneType' object has no attribute 'draw'
Traceback (most recent call last):
File "/home/yoga/Dropbox/blend/extensions/CAD_Sketcher/gizmos/constraint.py", line 169, in draw
icon_manager.draw(self.type, col)

Also in the selection texture when a sketch is active i get a big rectangle, it seems that the sketches workplane is still drawn an occludes other entities:
image

@rcarmo
Copy link
Author

rcarmo commented May 6, 2025

Oh, I'm not done yet. I had to turn on workplane drawing to test the selection buffer and also broke constraint drawing. I just ran out of time yesterday.

I might still move some stuff off global_data and into constants (ZAXIS) or utilities as I go along...

@rcarmo
Copy link
Author

rcarmo commented May 6, 2025

This is sort of OK-ish now. I am going to test it and then revisit the stacked/overlapping entities thing. I think it's still working, but I haven't tried to actually use it since yesterday.

# return
# Check if workplane should be shown in selection buffer when inside a sketch
active_sketch = context.scene.sketcher.active_sketch
if active_sketch and active_sketch.wp != self:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workplane is a 3d element so it should never be drawn when a sketch is active

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not, I think. I split those out into two separate calls but didn't update the comments... Can you see it in the selection buffer?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes i still see the black square in the selection buffer when a sketch is active

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latest push should fix that. I made the logic a bit more explicit. But I still need to go back and validate that overlapping selections work and hoist a few more constants.

@rcarmo
Copy link
Author

rcarmo commented May 17, 2025

Ok, this took a while, but I can now cycle through overlapping lines by double-clicking on them. Lines in the selection stack cycle through a similar color for now, as I don't have more time today, but would appreciate it if you could test this on your end and check if the behavior works for you...
image

@hlorus
Copy link
Owner

hlorus commented May 19, 2025

The behavior seems to work in a case where two lines intersect like on your picture but i cannot get it to work with parallel overlapping edges like in the picture below.
Also it seems that it does not respect the selection mode since on double-click the first line should be deselected again such that there's always just one line selected at a time.

image

@rcarmo
Copy link
Author

rcarmo commented May 19, 2025

Hmmm. OK. I think I know why. I need to check if double clicking is being properly propagated as well, but that test case should help. Will see if I can spend a couple of hours this week on it.

@hlorus hlorus mentioned this pull request Jun 19, 2025
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Overlapping entity selection
2 participants