protected override PropertyEditor AutoCreateMemberEditor(MemberInfo info) { if (info.IsEquivalent(ReflectionInfo.Property_DrawTechnique_PreferredVertexFormat)) { List <VertexDeclaration> vertexTypes = new List <VertexDeclaration>(); vertexTypes.Add(null); foreach (TypeInfo vertexType in DualityApp.GetAvailDualityTypes(typeof(IVertexData))) { if (vertexType.IsClass) { continue; } if (vertexType.IsAbstract) { continue; } if (vertexType.IsInterface) { continue; } vertexTypes.Add(VertexDeclaration.Get(vertexType.AsType())); } ObjectSelectorPropertyEditor e = new ObjectSelectorPropertyEditor(); e.EditedType = (info as PropertyInfo).PropertyType; e.Items = vertexTypes.Select(decl => new ObjectItem(decl, decl != null ? decl.DataType.Name : "None")); this.ParentGrid.ConfigureEditor(e); return(e); } return(base.AutoCreateMemberEditor(info)); }
[Test] public void EmptyArray() { VertexBatch <VertexC1P3> typedBatch = new VertexBatch <VertexC1P3>(); IVertexBatch abstractBatch = typedBatch; Assert.AreEqual(0, typedBatch.Count); Assert.AreEqual(VertexDeclaration.Get <VertexC1P3>(), typedBatch.Declaration); Assert.IsNotNull(typedBatch.Vertices); Assert.AreEqual(0, typedBatch.Vertices.Count); Assert.AreEqual(0, abstractBatch.Count); Assert.AreEqual(VertexDeclaration.Get <VertexC1P3>(), abstractBatch.Declaration); }
protected override void OnLoaded() { base.OnLoaded(); this.prefFormat = VertexDeclaration.Get(this.prefType); }
[Test] public void RentAndClear() { VertexBatchStore memory = new VertexBatchStore(); // Repeatedly rent slices of varying types from memory { VertexSlice <VertexC1P3> slice = memory.Rent <VertexC1P3>(4); slice[0] = new VertexC1P3 { Color = new ColorRgba(0) }; slice[1] = new VertexC1P3 { Color = new ColorRgba(1) }; slice[2] = new VertexC1P3 { Color = new ColorRgba(2) }; slice[3] = new VertexC1P3 { Color = new ColorRgba(3) }; } { VertexSlice <VertexC1P3T2> slice = memory.Rent <VertexC1P3T2>(3); slice[0] = new VertexC1P3T2 { Color = new ColorRgba(4) }; slice[1] = new VertexC1P3T2 { Color = new ColorRgba(5) }; slice[2] = new VertexC1P3T2 { Color = new ColorRgba(6) }; } { VertexSlice <VertexC1P3> slice = memory.Rent <VertexC1P3>(2); slice[0] = new VertexC1P3 { Color = new ColorRgba(7) }; slice[1] = new VertexC1P3 { Color = new ColorRgba(8) }; } { VertexSlice <VertexC1P3> slice = memory.Rent <VertexC1P3>(1); slice[0] = new VertexC1P3 { Color = new ColorRgba(9) }; } // Assert correct storage property values Assert.AreEqual( 1 + Math.Max( VertexDeclaration.Get <VertexC1P3>().TypeIndex, VertexDeclaration.Get <VertexC1P3T2>().TypeIndex), memory.TypeIndexCount); Assert.AreEqual(1, memory.GetBatchCount <VertexC1P3>()); Assert.AreEqual(1, memory.GetBatchCount <VertexC1P3T2>()); // Retrieve specific internal vertex arrays VertexBatch <VertexC1P3> batchA = memory.GetBatch <VertexC1P3>(0); VertexBatch <VertexC1P3T2> batchB = memory.GetBatch <VertexC1P3T2>(0); RawList <VertexC1P3> verticesA = batchA.Vertices; RawList <VertexC1P3T2> verticesB = batchB.Vertices; // Assert that they contain all the data we submitted in the correct order Assert.AreEqual(7, batchA.Count); Assert.AreEqual(3, batchB.Count); Assert.AreEqual(7, verticesA.Count); Assert.AreEqual(3, verticesB.Count); Assert.AreEqual(new ColorRgba(0), verticesA[0].Color); Assert.AreEqual(new ColorRgba(1), verticesA[1].Color); Assert.AreEqual(new ColorRgba(2), verticesA[2].Color); Assert.AreEqual(new ColorRgba(3), verticesA[3].Color); Assert.AreEqual(new ColorRgba(4), verticesB[0].Color); Assert.AreEqual(new ColorRgba(5), verticesB[1].Color); Assert.AreEqual(new ColorRgba(6), verticesB[2].Color); Assert.AreEqual(new ColorRgba(7), verticesA[4].Color); Assert.AreEqual(new ColorRgba(8), verticesA[5].Color); Assert.AreEqual(new ColorRgba(9), verticesA[6].Color); // Clear all vertices memory.Clear(); // Assert correct storage property values Assert.AreEqual(0, memory.TypeIndexCount); Assert.AreEqual(0, memory.GetBatchCount <VertexC1P3>()); Assert.AreEqual(0, memory.GetBatchCount <VertexC1P3T2>()); // Assert that the vertices are gone, but capacity isn't Assert.AreEqual(0, batchA.Count); Assert.AreEqual(0, batchB.Count); Assert.AreEqual(0, verticesA.Count); Assert.AreEqual(0, verticesB.Count); Assert.GreaterOrEqual(verticesA.Capacity, 7); Assert.GreaterOrEqual(verticesB.Capacity, 3); }