Fix #116262: Modal knife tool can crash if used on hidden object #119383

Merged
Philipp Oeser merged 1 commits from lichtwerk/blender:116262_b into blender-v4.1-release 2024-03-12 17:02:46 +01:00

1 Commits

Author SHA1 Message Date
Philipp Oeser e0e36ed5a7 Fix #116262: Modal knife tool can crash if used on hidden object
This could happen if objects were hidden after going to editmode and
knife was used on them.

In that case, raycasting would (rightfully) fail, but there is a
fallback in place using the back-buffer selection method (in which the
hidden object is still present). So a face would be found, but this
makes all following code confusing/wrong since we are working with
coordinates / faces under the assumption there would be a valid/
corresponding object to it in `KnifeTool_OpData` > `objects` -- which is
not the case...

So to resolve, just check if the object is visible before calling
`EDBM_face_find_nearest` in knife code.

Alternativeliy, we could also add a check for Base viewport visibility
to all the bmesh `find_nearest` functions (a bit hesitant though since i
am not sure this would be desired in all cases)
2024-03-12 15:26:26 +01:00