public void IncompleteRead() { BlockStream stream; CreateBlockStream1And2Int(out stream); BlockStream.Reader reader = stream; reader.BeginForEachIndex(0); reader.Read <byte>(); Assert.Throws <ArgumentException>(() => reader.EndForEachIndex()); reader.BeginForEachIndex(1); stream.Dispose(); }
public void Execute(int index) { int count = Reader.BeginForEachIndex(index); Assert.AreEqual(count, index); for (int i = 0; i != index; i++) { Assert.AreEqual(index - i, Reader.RemainingItemCount); var peekedValue = Reader.Peek <int>(); var value = Reader.Read <int>(); Assert.AreEqual(i, value); Assert.AreEqual(i, peekedValue); } Reader.EndForEachIndex(); }
private void Draw() { for (int i = 0; i < m_DebugStreams.Count; i++) { BlockStream.Reader reader = m_DebugStreams[i]; for (int j = 0; j != reader.ForEachCount; j++) { reader.BeginForEachIndex(j); while (reader.RemainingItemCount != 0) { switch (reader.Read <Type>()) { case Type.Point: reader.Read <Point>().Draw(); break; case Type.Line: reader.Read <Line>().Draw(); break; case Type.Arrow: reader.Read <Line>().DrawArrow(); break; case Type.Plane: reader.Read <Line>().DrawPlane(); break; case Type.Circle: reader.Read <Line>().DrawCircle(); break; case Type.Arc: reader.Read <Arc>().Draw(); break; case Type.Cone: reader.Read <Cone>().Draw(); break; case Type.Text: reader.Read <Text>().Draw(ref reader); break; case Type.Box: reader.Read <Box>().Draw(); break; default: return; // unknown type } } reader.EndForEachIndex(); } } }
// Update is called once per frame private void Update() { Vector3 imageCenter = transform.TransformPoint(new Vector3(0, 0, -ImagePlane)); if (ExpectingResults) { BlockStream.Reader reader = lastResults.PixelData; for (int i = 0; i < lastResults.PixelData.ForEachCount; i++) { reader.BeginForEachIndex(i); while (reader.RemainingItemCount > 0) { int x = reader.Read <int>(); int y = reader.Read <int>(); Color c = reader.Read <Color>(); blasterTexture.SetPixel(x, y, c); } reader.EndForEachIndex(); } blasterTexture.Apply(); lastResults.PixelData.Dispose(); ExpectingResults = false; } if (BasePhysicsDemo.DefaultWorld == null) { return; } RayTracerSystem rbs = BasePhysicsDemo.DefaultWorld.GetExistingSystem <RayTracerSystem>(); if (rbs == null || !rbs.IsEnabled) { return; } Vector3 lightDir = new Vector3(0, 0, -1); GameObject sceneLight = GameObject.Find("Directional Light"); if (sceneLight != null) { lightDir = sceneLight.transform.rotation * lightDir; } Vector3 up = transform.rotation * new Vector3(0, 1, 0); Vector3 right = transform.rotation * new Vector3(1, 0, 0); lastResults = rbs.AddRequest(new RayTracerSystem.RayRequest { PinHole = transform.position, ImageCenter = imageCenter, Up = up, Right = right, LightDir = lightDir, RayLength = RayLength, PlaneHalfExtents = planeHalfExtents, AmbientLight = AmbientLight, ImageResolution = ImageRes, AlternateKeys = AlternateKeys, CastSphere = CastSphere, Shadows = Shadows, CollisionFilter = CollisionFilter.Default }); ExpectingResults = true; }