XbimWebUI icon indicating copy to clipboard operation
XbimWebUI copied to clipboard

Only draw one pixel in getID to lower performance impact on mousedown

Open SBRK opened this issue 7 years ago • 5 comments

Viewer.getID draws a viewport of half the size of the regular viewport. This could be greatly improved by drawing a viewport of only one pixel, offseting the screen to have only the pixel at x,y coordinates drawn. This is how we had implemented picking in our 3D engine at my previous company.

SBRK avatar Dec 12 '18 15:12 SBRK

This is a great idea. You are most welcome to contribute with a pull request :-)

martin1cerny avatar Dec 13 '18 08:12 martin1cerny

I will probably, although the develop branch is confusing and I had to change a lot to make it build.

On a same fashion, there's no need to call getID at all when no handlers are bound to the pick/dblclick events

SBRK avatar Dec 13 '18 10:12 SBRK

Here: https://github.com/xBimTeam/XbimWebUI/pull/218

Slight performance gain, although I'm still having long (> 100ms) getID calls in some conditions, not too sure why

SBRK avatar Dec 13 '18 14:12 SBRK

Thank you very much! I'll review and merge in the next few days.

martin1cerny avatar Dec 14 '18 07:12 martin1cerny

After much experimentation and research, readPixels is slow regardless of how many pixels are read or drawn. I wanted to have picking at every frame in order to have mouse hover interactions but on integrated graphics card it axes the framerate in half. Might try to do picking via raycasting instead. Nevertheless, my PR is still a small improvement from before

SBRK avatar Dec 17 '18 13:12 SBRK