WPF VisualTreeHelper.HitTest using multiple threads

In my application, there is a transparent InkCanvas on top of a Viewport3D object. The Viewport3D shows a large 3D mesh. The user will sketch on the InkCanvas in order to select a portion of the 3D model that the Viewport3D is rendering. The user is allowed to draw circles on the InkCanvas.
When the user sketches, I iterate over all the points that fall inside of the drawn circle and I use the VisualTreeHelper.HitTest function to perform raycasting and determine which vertices of the Viewport3D mesh coincide with the sketch.

The problem is that VisualTreeHelper.HitTest is very slow. In case I used a Parallel.For I still would not be able to perform multiple raycastings on the Viewport3D in parallel (due to the fact that the owning thread of the Viewport3D object is the UI thread and I'd have to use Viewport3D's Dispatcher.Invoke function which will defeat the purpose of having a Parallel.For in the first place.)

Is there a way to speed this up using multiple threads? Better yet, is there an alternative solution?

-------------Problems Reply------------

After a lot of searching, I think what I want is impossible in the WPF framework. I switched to OpenTK for that purpose and implemented the raycasting myself.
Now I have a WPF-mimick in OpenTK with a much better performance. The code is available here if anyone is interested.

Category:c# Views:1 Time:2018-04-15

Related post

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.163 (s). 11 q(s)