hitTest(_:options:) not finding all geometry (iOS 11)

Hello,


I couldn't get hitTest (with no options) to detect geometries that are hidden behind some other geometry in iOS 11. My code works fine when ran on iOS 10. Anyone know why this is the case ?


Thanks

Replies

I'm not sure the exact reason, but it might be because of SCNHitTestSearchMode which was added from iOS11.

And I guess the default value is .closest (=0)

NSArray *hitResults = [self.mySCNView hitTest:location options:[NSDictionary dictionaryWithObjectsAndKeys:@NO, SCNHitTestIgnoreHiddenNodesKey, @1, SCNHitTestOptionSearchMode,  nil]];


The value 1 sets the search mode to SCNHitTestSearchModeAll instead of the default SCNHitTestSearchModeClosest (0).


There is also option SCNHitTestSearchModeAny (2). The documentation does not explain the difference between SCNHitTestSearchModeAll and SCNHitTestSearchModeAny.


https://developer.apple.com/documentation/scenekit/scnhittestsearchmode

I'm fighting also with hitTest:options:. I made another thread because it's not exactly the same situation but it may be related. FYI, I tried all options with no success getting the right hit point.

The difference between search mode any and all is that any returns any “one” result, regardless of whether it‘s the first or not. “All“ works as expected, ie. returns an array.

Here is how I could fix the issue with SCNHitTestSearchMode that was added from iOS11.


if #available(iOS 11.0, *) {

hitResults = scnView.hitTest(location, options: [SCNHitTestOption.searchMode: 1])

}