ARKit - Extend the reach of "hitTest" - ios

I want to perform a hit testing from a point on the screen to a Cube in a 3D world. I've been using hitTest from ARKit. It works when I'm standing close to the cube, but when I start moving backwards, it stops working. I'm assuming this is because it's locked to the camera's zRange.
I've tried to set the clipToZRange option to false, like so:
let hits = self.sceneView.hitTest(loc, options: [SCNHitTestOption.clipToZRange: false])`
but it doesn't seem to have any effect.
Am I not setting the option right, or is this a bug?
I am using the latest Xcode and iOS betas.

Turns out the showFeaturePoints debug option from ARKit interferes with hitTest...

Related

AudioKit shouldOptimizeForRealtimePlot causing plot to go blank

I've got an iOS project set up in Xcode utilizing AudioKit to display a realtime plot of a chosen onboard microphone on the iOS device.
I am currently attempting to set the flag for an AKNodeOutputPlot where shouldOptimizeForRealtimePlot = true, but I've found that if I even add that line of code, whether it's set to true or false, to the project (in the ViewController the plot in which the plot is displayed, OR as a key-value in IB), the plot no longer displays.
If I remove the line of code, my plot resumes functionality as normal.
Has anyone else run into this?
My plot is setup mostly in IB, I pretty much just use the VC to set the input node and pause/resume the plot, but if you'd like to see any extra code, or a screenshot of my setup in IB, I'm happy to oblige.
Thank you for your assistance.

MapKit iOS rendererForOverlay refreshing out of control

I have a MapKit issue with MKMapView using addOverlay and rendererForOverlay. Testing and debugging is being done on a device (iPhone 7 iOS 11.1.1) with Xcode 9.1 (9B55). The overlay renderer is being refreshed repeatedly for all tiles in the map view (2500 calls per sec to drawMapRect:). The calls to the renderer are ignoring the changed rectangle in setNeedsDisplayInMapRect: and are not initiated by setNeedsDisplayInMapRect. This refreshing continues forever even after all map updates were finished with Xcode reporting the app is using over 160% CPU.
Xcode Debug Navigator Image Link
The MKMapView code is based on the Apple Sample code 'BreadCrumb' available from https://developer.apple.com/library/content/samplecode/Breadcrumb/Introduction/Intro.html. There are no significant structural changes to this code.
Has anyone else experienced this or have any suggestions of where to start looking for a solution?
Running the Apple Breadcrumb sample did not exhibit the same problem. After putting this back into my project and adding the changes from my project I was finally able to isolate the problem to having inserted 'self.alpha = 0.5' into drawMapRect:. It does not matter whether the alpha property is set to 1.0 or some other value, the problem will still occur.
- (void)drawMapRect:(MKMapRect)mapRect
zoomScale:(MKZoomScale)zoomScale
inContext:(CGContextRef)context;
{
CrumbPath *crumbs = (CrumbPath *)(self.overlay);
self.alpha = 0.5; // <-------- THE PROBLEM
With the problem resolved overlay renderer calls reverted to between 40 and 80 per second with no calls occurring without map updates and calls to setNeedsDisplayInMapRect:.

Underscan issue with AirPlay mirroring

I'm having some issues with AirPlay. The thing is, I'm developing with the ATV3, and my TV set supports 1080p. But when I start screen mirroring and receive the new instance of UIScreen, the bounds and the applicationFrame are both giving me a 720p resolution.
But it gets weird when I actually moved the subviews to a negative value, and the whole screen gets covered. So, technically my iPhone is streaming at 1080p, but the bounds returned by the UIScreen are underscanned.
I've tried modifying the overscanCompensation before getting the bounds or the applicationFrame (tried both with all 3 overscanCompensation values available) but I'm still getting the same result.
Here is a picture of what I'm getting (sorry, it's the worst picture in the planet, I know, but I was using my phone to stream the image to the ATV :) )
Red view is the 720p reported by bounds.
It gets even weirder when I actually try this out in my ATV2 (it is supposedly limited to 720p even if it supports 1080p) and the result is exactly the same.
Anyway, if someone knows the method to get the real screen display to avoid putting a settings view in my app, I'll really appreciate it.
Thanks in advance :)
When you mentioned that you tried all 3 overscanCompensation modes, I presume you mean the 3 documented modes:
typedef enum {
UIScreenOverscanCompensationScale,
UIScreenOverscanCompensationInsetBounds,
UIScreenOverscanCompensationInsetApplicationFrame,
} UIScreenOverscanCompensation;
However, there is a fourth mode, which is not there, but should fix your problems: just set your overscanCompensation to 3.
Also, take a look at this SO question.
The answer of Ivan solved the same issue for me! But I also had the borders when using AirPlay Mirroring. I got rid of the borders without setting the overscanCompensation property by changing a setting on my Apple TV: try setting 'Settings > Audio & Video > Adjust For AirPlay Overscan' to Off (default On).
The setting that works best for most TVs is:
externalScreen.overscanCompensation = UIScreenOverscanCompensationInsetBounds | UIScreenOverscanCompensationInsetApplicationFrame; // this is the same as setting it to 3
Just setting it to UIScreenOverscanCompensationInsetApplicationFrame can cause misalignment of the UIWindow contents.
3 is a bitmask of UIScreenOverscanCompensationInsetBounds(1) and UIScreenOverscanCompensationInsetApplicationFrame(2) for those wondering where that number comes from and why it works.

touchesBegan only fired within 768x768 pixel rectangle

I'm seeing weird behaviour with my iPad app on both simulator (5.1 and 6.0) and my device (iPad2 running iOS6.0). Whichever orientation the app starts in, touchesBegan is only fired for new touches in the region (0,0) - (767,767) - in portrait mode the bottom of the screen doesn't respond, in landscape the right side.
However, touchesMoved & touchesEnded work on the whole display - if I touch and drag to the 'broken' region, the touch release event is received.
I further noted that while on the iOS 6 simulator my app looks right even though it doesn't work right, on the iOS 5.1 simulator the rendering was also a bit messed up initially too:
The whole display should be grey and that box with sliders in the bottom-right corner. Again, 768 seems the magic value here. Rotating a couple of times fixes this render issue but not the input issue... start in portrait mode and rotate 180 degrees and it now looks right but the top stops responding rather than the bottom.
There is a 3rd-partly library being used here, so my main question is what might cause this kind of problem, what should be I be looking for? I'm also curious as to why the two simulators give different results
If you're touchesBegan, touchesMoved, and touchesEnded all are looking for a location within your self.view, then you might not be in the correct frame area for the touches to be received. I just had a similar problem and I explicitly changed the size of the frame using:
self.view.frame = CGRectMake(0,0,1024,1536);
since my game is two screens tall. After readjusting the frame size, touchesBegan was working fine. Hopefully this helps!

presentationLayer position property yielding bad values on iPad, no problem with iPhone

I have a game with several small objects animated using CAKeyframeAnimation. Objects animate perfectly for BOTH iPhone and iPad. However, the value of the position property of the animated CALayers' presentationLayers only yield reasonable values on the iPhone. I use the current position of the animating objects for hit testing. Any ideas of differences in this area between iPad and iPhone/iPod Touch?
The position points for iPhone show expected incremental change as objects animate; on iPad I see peculiar values, for example this sequence:
<-36893488147419103232.000000,2.607987>,
<-0.000000,2.658927>,
<0.000000,2.709929>,
<36893488147419103232.000000,2.755450>, ...
Other properties of the presentationLayer are correct (these are properties whose values don't change during the animation, however).
After the animation finishes, the presentationLayer position value IS accurate.
Exactly same problem here!! and it looks that is a bug starting with 3.2 version of the SDK...
Actually I did a iPhone app (using 3.1 SDK) that it is completely based on CAAnimation, when I installed and ran the the app on an iPhone with 3.2 nothing works!!!... but on devices that has 3.1 works perfectly. I google it and I found another people with exactly the same problem.
take a look at the bottom of the following forum
http://www.iphonedevsdk.com/forum/iphone-sdk-development/19622-current-position-animating-calayer.html
Could you solved this issue or found a workaround?

Resources