private static void SyncScene() { SceneView view = SceneView.lastActiveSceneView; if (view == null) { return; } cameraSettings._fov = camera.fieldOfView; int w = 256; int h = 145; if (fullScreen) { w = view.camera.pixelWidth / 2; h = view.camera.pixelHeight / 2; } //hack..size keeps toggling by 1 pixel wtf???? if (Mathf.Abs(w - width) > 2 || Mathf.Abs(h - height) > 2) { //Debug.Log("resize: " + w + "," + h); width = w; height = h; frameBuffer = null; updateCamera = true; BocsCyclesAPI.Cycles_request_reset(); hasUpdated = true; waitForNextFrame = true; nextUpdate = Time.realtimeSinceStartup + .25f; } if (frameBuffer == null) { UpdateFramebuffer(); hasUpdated = true; waitForNextFrame = true; nextUpdate = Time.realtimeSinceStartup + .25f; } if (camera.transform.position != lastPosition || camera.transform.rotation != lastRotation) { lastPosition = camera.transform.position; lastRotation = camera.transform.rotation; updateCamera = true; BocsCyclesAPI.Cycles_request_reset(); waitForNextFrame = true; hasUpdated = true; nextUpdate = Time.realtimeSinceStartup + .25f; } if (BocsCyclesAPI.Cycles_need_reset()) { hasUpdated = true; waitForNextFrame = true; nextUpdate = Time.realtimeSinceStartup + .25f; } if (hasUpdated && Time.realtimeSinceStartup > nextUpdate) { if (BocsCyclesAPI.Cycles_need_settings()) { BocsCyclesAPI.UpdateSettings(camera, cameraSettings, width, height, samples); } else if (updateCamera) { BocsCyclesAPI.UpdateCameraPositon(camera, cameraSettings, width, height); } BocsCyclesAPI.Cycles_render_async(); hasUpdated = false; updateCamera = false; } }