@@ -51,6 +51,7 @@ def __init__(self, view: PaintView) -> None:
5151 self ._view : PaintView = view
5252 self ._view .canUndoChanged .connect (self ._onCanUndoChanged )
5353 self ._view .canRedoChanged .connect (self ._onCanRedoChanged )
54+ self ._view .currentPaintedObjectMeshDataChanged .connect (self ._updateState )
5455
5556 self ._picking_pass : Optional [PickingPass ] = None
5657 self ._faces_selection_pass : Optional [SelectionPass ] = None
@@ -198,40 +199,6 @@ def clear(self) -> None:
198199 self ._view .clearPaint ()
199200 self ._updateScene (update_node = True )
200201
201- @staticmethod
202- def _get_intersect_ratio_via_pt (a : numpy .ndarray , pt : numpy .ndarray , b : numpy .ndarray , c : numpy .ndarray ) -> float :
203- # compute the intersection of (param) A - pt with (param) B - (param) C
204- if all (a == pt ) or all (b == c ) or all (a == c ) or all (a == b ):
205- return 1.0
206-
207- # compute unit vectors of directions of lines A and B
208- udir_a = a - pt
209- udir_a /= numpy .linalg .norm (udir_a )
210- udir_b = b - c
211- udir_b /= numpy .linalg .norm (udir_b )
212-
213- # find unit direction vector for line C, which is perpendicular to lines A and B
214- udir_res = numpy .cross (udir_b , udir_a )
215- udir_res_len = numpy .linalg .norm (udir_res )
216- if udir_res_len == 0 :
217- return 1.0
218- udir_res /= udir_res_len
219-
220- # solve system of equations
221- rhs = b - a
222- lhs = numpy .array ([udir_a , - udir_b , udir_res ]).T
223- try :
224- solved = numpy .linalg .solve (lhs , rhs )
225- except numpy .linalg .LinAlgError :
226- return 1.0
227-
228- # get the ratio
229- intersect = ((a + solved [0 ] * udir_a ) + (b + solved [1 ] * udir_b )) * 0.5
230- a_intersect_dist = numpy .linalg .norm (a - intersect )
231- if a_intersect_dist == 0 :
232- return 1.0
233- return numpy .linalg .norm (pt - intersect ) / a_intersect_dist
234-
235202 def _nodeTransformChanged (self , * args ) -> None :
236203 self ._cache_dirty = True
237204
@@ -453,7 +420,7 @@ def _updateActiveView(self) -> None:
453420 def _updateState (self ):
454421 painted_object = self ._view .getPaintedObject ()
455422 if painted_object is not None and self ._controller .getActiveTool () == self :
456- if painted_object .callDecoration ("getPaintTexture" ) is not None :
423+ if painted_object .callDecoration ("getPaintTexture" ) is not None and painted_object . getMeshData (). hasUVCoordinates () :
457424 new_state = PaintTool .Paint .State .READY
458425 else :
459426 new_state = PaintTool .Paint .State .PREPARING_MODEL
@@ -472,6 +439,7 @@ def _onPrepareTextureFinished(self, job: Job):
472439 self ._prepare_texture_job = None
473440 self ._state = PaintTool .Paint .State .READY
474441 self .propertyChanged .emit ()
442+ self ._updateScene ()
475443
476444 def _updateIgnoreUnselectedObjects (self ):
477445 ignore_unselected_objects = self ._controller .getActiveView ().name == "PaintTool"
0 commit comments