CGCookie / retopoflow

A suite of retopology tools for Blender
2.51k stars 249 forks source link

[BUG] Strokes tool: unhandled exception on Ctrl+LMB #1346

Open jfranmatheu opened 3 days ago

jfranmatheu commented 3 days ago

Retopoflow Version: latest, v4.0.0 branch, hash=bf36eeaf6d12d4ae171c3740a92d71c5e82fdca5

Blender Version/Hash: 4.2.3 LTS, hash=0e22e4fcea03

Platform Version/Distribution: Windows 11, 10.0.22631

 

Issue:

Unhandled exception in Stroke tool when Ctrl+Click. The consequent crash glitches the cursor graphic on screen, since it is not cleared afterwhile.

image

Exception Traceback:

RFCore_Operator.__init__
CACHING BVHS FOR ALL SOURCE OBJECTS
  0.00secs
RFCore_Operator executing
RFOperator.modal: Unhandled Exception Caught in self.update: BMVert.co
____________________________________________________________________________________________________
Exception Info
- Time: 2024-11-13 14:32:01.312271
- Count: 1
- Hash: 411c938379d6efc02f0a344c55e5beef
- Info:
  - EXCEPTION (<class 'TypeError'>): BMVert.co
  -     C:\Users\JF\AppData\Roaming\Blender Foundation\Blender\4.2\scripts\addons\retopoflow\retopoflow\rfoperators\transform.py
  - 000 0345:translate() bmv.co = co
  - 001 0310:update() self.translate(context, event)
  -     C:\Users\JF\AppData\Roaming\Blender Foundation\Blender\4.2\scripts\addons\retopoflow\retopoflow\common\operator.py
  - 002 0143:modal() ret = self.update(context, event)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RFOperator.modal: Unhandled Exception Caught in self.update: BMVert.co
____________________________________________________________________________________________________
Exception Info
- Time: 2024-11-13 14:32:16.100580
- Count: 2
- Hash: 411c938379d6efc02f0a344c55e5beef
- Info:
  - EXCEPTION (<class 'TypeError'>): BMVert.co
  -     C:\Users\JF\AppData\Roaming\Blender Foundation\Blender\4.2\scripts\addons\retopoflow\retopoflow\rfoperators\transform.py
  - 000 0345:translate() bmv.co = co
  - 001 0310:update() self.translate(context, event)
  -     C:\Users\JF\AppData\Roaming\Blender Foundation\Blender\4.2\scripts\addons\retopoflow\retopoflow\common\operator.py
  - 002 0143:modal() ret = self.update(context, event)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RFOperator.modal: Unhandled Exception Caught in self.update: BMVert.co
____________________________________________________________________________________________________
Exception Info
- Time: 2024-11-13 14:32:16.599833
- Count: 3
- Hash: 411c938379d6efc02f0a344c55e5beef
- Info:
  - EXCEPTION (<class 'TypeError'>): BMVert.co
  -     C:\Users\JF\AppData\Roaming\Blender Foundation\Blender\4.2\scripts\addons\retopoflow\retopoflow\rfoperators\transform.py
  - 000 0345:translate() bmv.co = co
  - 001 0310:update() self.translate(context, event)
  -     C:\Users\JF\AppData\Roaming\Blender Foundation\Blender\4.2\scripts\addons\retopoflow\retopoflow\common\operator.py
  - 002 0143:modal() ret = self.update(context, event)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Traceback (most recent call last):
  File "C:\Users\JF\AppData\Roaming\Blender Foundation\Blender\4.2\scripts\addons\retopoflow\retopoflow\rfcore.py", line 418, in modal
    RFCore.handle_update(context, event)
  File "C:\Users\JF\AppData\Roaming\Blender Foundation\Blender\4.2\scripts\addons\retopoflow\retopoflow\rfcore.py", line 234, in handle_update
    if brush: brush.update(context, event)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\JF\AppData\Roaming\Blender Foundation\Blender\4.2\scripts\addons\retopoflow\retopoflow\rfbrushes\strokes_brush.py", line 171, in update
    self.operator.process_stroke(context, self.stroke, self.stroke_cycle, self.snap_bmv0, self.snap_bmv1)
  File "C:\Users\JF\AppData\Roaming\Blender Foundation\Blender\4.2\scripts\addons\retopoflow\retopoflow\rftool_strokes\strokes.py", line 114, in process_stroke
    logic = Strokes_Logic(context, stroke, cycle, snap_bmv0, snap_bmv1, self.span_insert_mode, self.initial_cut_count, RFTool_Strokes.rf_brush.radius)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\JF\AppData\Roaming\Blender Foundation\Blender\4.2\scripts\addons\retopoflow\retopoflow\rftool_strokes\strokes_logic.py", line 118, in __init__
    self.length3D = sum((p1-p0).length for (p0,p1) in iter_pairs(self.stroke3D, self.is_cycle))
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\JF\AppData\Roaming\Blender Foundation\Blender\4.2\scripts\addons\retopoflow\retopoflow\rftool_strokes\strokes_logic.py", line 118, in <genexpr>
    self.length3D = sum((p1-p0).length for (p0,p1) in iter_pairs(self.stroke3D, self.is_cycle))
                         ~~^~~
TypeError: unsupported operand type(s) for -: 'NoneType' and 'NoneType'

 

How to Reproduce:

jfranmatheu commented 2 days ago

Issue

After some superficial analysis, I've seen that raycast_point_valid_sources function can return None values, so in Strokes_Logic.__init__(), the self.stroke3D list can contain invalid values when there is no raycast hit, leading to a further crash.

Potential bugfix:

I made a quick patch in case you need to give it a try: 1346.patch