Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

3D Hit Testing Filter

$
0
0

I have a 3D WPF scene that has a main "mesh" and a couple 3D "UI" meshes.  Only the 3D "UI" meshes need to respond to mouse input.  Since the main mesh is large, I want to save performance by filtering it out of 3D hit testing.  So I found the page on hit test filtering:

http://msdn.microsoft.com/en-us/library/system.windows.media.hittestfiltercallback.aspx

First, does the hit test filter really skip objects from being hit tested or just filtered from the results?  The mesh I want to skip has a large triangle count.

I do something like the following in my filter handler:

private HitTestFilterBehavior HitTestFilter(DependencyObject obj)
        {
            ModelVisual3D modelVis = obj as ModelVisual3D;

            // Filter out the surface mesh, as we do not hit test against it.
            if(modelVis == SurfaceVisual)
            {
                // Visual object and descendants are NOT part of hit test results enumeration.
                return HitTestFilterBehavior.ContinueSkipSelfAndChildren;
            }
            else
            {
                // Visual object is part of hit test results enumeration.
                return HitTestFilterBehavior.Continue;
            }
        }

Is casting to ModelVisual3D the right strategy to filter a particular mesh?  I set breakpoints and it works, but is it the best practice for what I am trying to do?  


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>