SceneKit hit testing issue with orthographic camera
| Originator: | miles.chris | ||
| Number: | rdar://13333586 | Date Originated: | 04-Mar-2013 |
| Status: | Closed | Resolved: | 25-Jun-2013 |
| Product: | Mac OS X SDK | Product Version: | 10.8.2 |
| Classification: | Other Bug | Reproducible: | Always |
ATTN: SceneKit Team
Summary:
SceneKit hit testing does not take into account the scale applied to the camera when usesOrthographicProjection is enabled.
Steps to Reproduce:
1. Create a SceneKit view and scene containing a few nodes with geometry, as normal.
2. Add one camera and enable "usesOrthographicProjection" on the SCNCamera, to switch on orthographic projection. Apply a scale to the camera.
SCNCamera *orthoCamera = [SCNCamera camera];
orthoCamera.usesOrthographicProjection = YES;
SCNNode *cameraNode = [SCNNode node];
cameraNode.camera = orthoCamera;
cameraNode.position = SCNVector3Make(0.0f, 0.0f, 1.0f);
cameraNode.scale = SCNVector3Make(0.3f, 0.3f, 0.3f);
[scene.rootNode addChildNode:cameraNode];
3. Enable update tracking in the view and override the mouseMoved: method to hit test the scene with the mouse location.
- (void)mouseMoved:(NSEvent *)event
{
NSPoint mouseLocation = [self convertPoint:[event locationInWindow] fromView:nil];
NSArray *hits = [self hitTest:mouseLocation options:nil];
NSLog(@"hits: %@", hits);
}
Expected Results:
The result of hit testing should correctly return all nodes underneath the mouse pointer. This is the result we get if "usesOrthographicProjection" is not enabled.
Actual Results:
Hit testing does not match nodes in their visible positions. Nodes are matched, but in incorrect positions.
It turns out that hit testing is not taking into account the scale applied to the camera when usesOrthographicProjection is enabled. The workaround suggested at http://blog.wadetregaskis.com/scnview-hittestoptions-doesnt-work-correctly-for-orthographic-projections/ demonstrates this.
Regression:
n/a
Notes:
References:
https://devforums.apple.com/thread/181198?tstart=0
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
Fixed in Mavericks.
Fixed by Scene Kit team in Mavericks.
I confirmed that this is fixed in OS X Mavericks Seed Build 13A497d
This issue has been verified as resolved and can be closed.