Odd behavior of Draw
-
It's recommended to use invalidate instead of refresh unless you have a good specific reason to use refresh. Otherwise you end up unnecessarily redrawing the viewport too often which might impact performance.
-
@TT,
what is the underlying difference between
refresh
andinvalidate
?the API has the same description for both and they are used interchangeably by many...
On one of my plugins, using both was the only way to guarantee it worked...
john
-
View.invalidate marks the view for redraw but it might not be updated immediately. It'll be throttled.
View.redraw force a redraw immediately.View.invalidate should be the first choice - View.redraw should be used when you know you really need it.
I've had to use view.redraw in cases where I make mesh updates in the mouse events (for live mesh preview). There I had to force a redraw otherwise things would appear choppy. But even then I'd try to manually throttle view.redraw.
-
TT: any idea what logic or basis SketchUp uses to decide when to conduct the next redraw after view.invalidate? That is, I take your answer to mean that SU queues up the draw and then waits for an appropriate opportunity to do it. But what is an "appropriate opportunity"? Is there something besides view.redraw that a Tool can or should do to encourage it? Waiting a random, indeterminate amount of time before the next draw is sure to cause an interactive Tool to be jittery! I'm drawing a "rubber band" tracking the mouse cursor to show dynamically what is happening. Jitters in that would make it quite unusable (maybe on a complex model with a slow redraw it is already so)!
-
@tt_su said:
View.invalidate marks the view for redraw but it might not be updated immediately. It'll be throttled.
View.redraw force a redraw immediately.View.invalidate should be the first choice - View.redraw should be used when you know you really need it.
I've had to use view.redraw in cases where I make mesh updates in the mouse events (for live mesh preview). There I had to force a redraw otherwise things would appear choppy. But even then I'd try to manually throttle view.redraw.
I don't find view.redraw in the API and it caused an "undefined method" error when I tried to use it.
-
I think tt mistyped '
redraw
' forview.refresh
-
My bad. What TIG said.
-
Well I have tried all the suggested combinations and nothing seems to solve the "problem". Perhaps it is just my 7 year old laptop!!!!!
-
Do you have a small reproducible snippet?
-
@sdmitch said:
Well I have tried all the suggested combinations and nothing seems to solve the "problem". Perhaps it is just my 7 year old laptop!!!!!
Since these draw operations go directly to OpenGL, this explanation seems quite possible! There could be a bug in either your laptop's OpenGL drivers or an incompatibility in how SketchUp uses OpenGL.
Advertisement