bool BeginReadRequest(int count, ref ReadRequest req) { if (count == 0) { return(false); } BeginReadMarker.Begin(); TextureSet TextureSet = null; if (AvailableRenderTextures.Count != 0) { TextureSet = AvailableRenderTextures.Pop(); } if (TextureSet == null) { TextureSet = new TextureSet(); TextureSet.Alloc(RenderTextureWidth, RenderTextureHeight); } else if (!TextureSet.IsValid()) { TextureSet.Release(); TextureSet.Alloc(RenderTextureWidth, RenderTextureHeight); } activeTarget = TextureSet; SensorCamera.SetTargetBuffers( activeTarget.colorTexture.rt.colorBuffer, activeTarget.depthTexture.rt.depthBuffer); SensorCamera.Render(); req = new ReadRequest() { TextureSet = TextureSet, Index = CurrentIndex, Count = count, Origin = SensorCamera.transform.position, CameraToWorldMatrix = SensorCamera.cameraToWorldMatrix, }; if (!Compensated) { req.Transform = transform.worldToLocalMatrix; } BeginReadMarker.End(); CurrentIndex = (CurrentIndex + count) % CurrentMeasurementsPerRotation; return(true); }
/// <summary> /// Processes a resize of the UWKView, which can cause the backing textures to be /// released/allocated. This is an expensive operation and should be avoided if possible /// </summary> void processResize(object sender, CommandProcessEventArgs args) { Command cmd = args.Cmd; if (cmd.retCode > 0) { if (cmd.retCode == 2) { TSet.Release(); TSet = new TextureSet(); TSet.Init(Width, Height, SmartRects); } else { } } else { Debug.Log("Error Resizing View: " + Name); } }