示例#1
0
        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);
        }