Making "Touch Region"
Hi! and sorry for long topic
I have a question to you about efficiency of my script. First - the script - how it works:
im writing some script for adding supporting loop to models with turbosmooth. Its easy script making connect (with specyfic parameters) on ring of selected edges. After it adds ring, if user clicks with CTRL any of button there appears "touch region" that controlls Adjust Loops ( Graphite Modeling - Loop Tools - Adjust Loops - First spinner). [Im still working on this method - i will be appreciated any advices in my other topic]. "Touch Region" - I project this region to [0,1] (0-100%) space (depending of rollout position, mouse position). And now, i made it with couple of ways. Which of them will be most efficient and fast?
#1 Rollout itself - This method base primary on mouseover event of rollout.
Taking rollout position on create or new position after moved
on rollout moved val_newPosition do(rol_position)
Checking that mouse left button is pressed or released
on rollout LButtonDown val_mousePos do( b_isLeftPressed = true) on rollout LButtonUp val_mousePos do( b_isLeftPressed = false)
on rollout mousemove val_mousePos do ( if (b_isLeftPressed) then ( if ( * ) then ( FN_ADJUST_LOOPS()-- **main method! ) )
*checking that mouse is over specified area of rollout(by calculating <= and >= with mouse.screenPos (or val_mausePos) and rol_position
? hmmm..im not sure but think its faster way(than #2). Why not sure - cause every move of mouse over rollout cause to: first - check that left button is pressed - and then that this mouse position is over specified area...every move must calculate it.
-the region itself dont have any visual boundaries (i dont want to use group)
-precision of adjustLoops depends of size of "touch region"
#2 ImgTag + Timer (i must use timer cause all ImgTag events is called once per specyfic behavior - moveover, mouseDown etc..and while loop will be worse to calculate than mousemove from #1. Is there any event simmiliiar to mousemove?)
The idea is simmiliar to #1 but i used timer and "touch region" depends of region of ImgTag.
first i made ImgTag (colored area) then the timer with interval and set it to false (it is declarated but not started yet).
im checking that mouse left button is pressed or released (button work only on imgTag area)
on mineImgTag_01 lbuttondown lmbDOWN_v1 lmbDOWN_v2 do ( b_isLeftPressed = true print "WLACZAM TIMER" mineTimer.active = True ) on mineImgTag_01 lbuttonup lmbUP_v1 lmbUP_v2 do ( b_isLeftPressed = false print "TIMER OFF" mineTimer.active = false )
(im using bool value (b_isLeftPressed) to check state of left button later cause i think it faster than checking timer state)
I must check mouseout and mouse over cause while left button is pressed and i leave ImgTag area, b_isLeftPressed still will be true
on mineImgTag_01 mouseover v1 v2 do ( b_isInside = True ) on mineImgTag_01 mouseout v1 v2 do ( b_isInside = false )
every tick of timer (that depends of interval) will run if statement and if its true it will run main method.
on mineTimer tick do ( if(b_isInside AND b_isLeftPressed)then ( FN_ADJUST_LOOPS()-- **main method! ) )
Dont have to calculate that cursor is on specyfic area of rollout ("Touch Region"). It checking that cursor i over ImgTag.
-it can set precision of move over "touch region" by setting interval
i think that method with timer (dot net function?) is slower than #1 solution
Main Method - it sets adjustLoop (move 2 loops away/closer to itself) in range 0-100 depending of position on "touch region" ( [0,1] )
1. Do you know any better solution for making "touch region"?
2. Which one of this 2 solution is faster and more efficient?
Sorry for my english, for chaos in post and for so many "Touch Region" words :)