WhirlyGlobe icon indicating copy to clipboard operation
WhirlyGlobe copied to clipboard

Excessive Momentum in WhirlyGlobe

Open ghost opened this issue 7 years ago • 4 comments

http://www.mulps.pw/temp/WhirlyGlobeMomentum.mp4

In the video the small circle around the cursor shows when the mouse button is pressed. Please mentally replace the pressed mouse button with a finger in contact with touch screen.

Pretty self-explanatory. In real life, when rotating an object with your finger, if you stop moving your finger while in contact with the object the object will not continue to rotate. You can hold your finger steady to "brake" the motion.

Perhaps the WhirlyGlobe momentum code could record the last fraction of a second of the finger speed to calculate the momentum motion.

ghost avatar Jun 14 '17 18:06 ghost

It's using the velocity from the touch. I added a little debugging code and I can see there's always a velocity even when it seems like there shouldn't be.

You could try adding a cutoff, but it might need to be screen size specific. Line 313 in PanDelegateFixed.mm. Just set vel.x and vel.y to 0.0 if it's a below a certain cutoff. I couldn't say what that cutoff is, though.

mousebird avatar Jun 15 '17 16:06 mousebird

Thanks, Steve.

Apple's velocity code is a bit primitive. I have edited PanDelegateFixed.mm to look at the speed of the last 10th of a second of movement. It is not perfect but I feel it is a vast improvement.

Here is a new demo video of the solution:

http://www.mulps.pw/temp/WhirlyGlobeMomentumNew.mp4

ghost avatar Jun 15 '17 20:06 ghost

Cool. Thanks!

mousebird avatar Jun 15 '17 20:06 mousebird

My pleasure!

ghost avatar Jun 15 '17 23:06 ghost