googlevr / gvr-ios-sdk

Google VR SDK for iOS
http://developers.google.com/vr/ios/
Other
647 stars 191 forks source link

move headPose initialization into GVRRenderer constructor #272

Closed jamezilla closed 7 years ago

jamezilla commented 7 years ago

I have a scene renderer declared like this in a GVRRendererViewController subclass:

    private lazy var sceneRenderer: GVRSceneRenderer = {
        let sr = GVRSceneRenderer()
        sr.hidesReticle = true
        sr.renderList.add(self.videoRenderer)
        sr.add(toHeadRotationYaw: 0, andPitch: -0.125)  // <--- doesn't work
        return sr
    }()

Adding yaw or pitch doesn't work like this. It turns out _headPose is null on line 123 in GVRRenderer.mm.

Moving that call to viewDidLoad in the view controller didn't help, but moving it to viewDidAppear fixed the problem. headPose isn't allocated until initializeGl is called so it makes sense that it would exist once the view has been painted.

Moving headpose initialization into GVRRenderer's init makes this API a little more friendly.

Thank you for GVRKit. It's a million times better than the old APIs. And extra kudos for making it open source.

sanjayc77 commented 7 years ago

Thanks for the PR and your kind words. We are not setup to take contributions directly, but will address this in the next release.