示例#1
0
        public void testCopyToEdgeCases()
        {
            var source = new IndexData();

            source.NumIndices = 6;

            var target = new IndexData();

            target.NumIndices = 6;

            source.CopyTo(target, 1, 1, 0, 1);
            Assert.IsTrue(target.UseQuadLayout);

            source.CopyTo(target, 3, 0, 1, 1);
            Assert.IsTrue(target.UseQuadLayout);

            source.CopyTo(target, 1, 1, 0, 2);
            Assert.IsTrue(target.UseQuadLayout);

            source.CopyTo(target, 10, 5, 2, 2);
            Assert.IsTrue(target.UseQuadLayout);

            source.CopyTo(target, 13, 8, 1, 4);
            Assert.IsTrue(target.UseQuadLayout);

            source.CopyTo(target, 10, 3, 4, 1);
            Assert.IsFalse(target.UseQuadLayout);
            Assert.AreEqual(6, target.GetIndex(10));
        }
示例#2
0
        public void testCopyToWithOffset()
        {
            var source = new IndexData();

            source.AddTriangle(1, 2, 3);
            source.AddTriangle(4, 5, 6);

            var target = new IndexData();

            target.AddTriangle(7, 8, 9);
            source.CopyTo(target, 1, 10, 3, 3);

            Assert.AreEqual(4, target.NumIndices);
            Assert.AreEqual(7, target.GetIndex(0));
            Assert.AreEqual(14, target.GetIndex(1));
            Assert.AreEqual(15, target.GetIndex(2));
            Assert.AreEqual(16, target.GetIndex(3));
        }
示例#3
0
 /// <summary>
 /// Copies the index data of the style's current target to the target of another style.
 /// The given offset value will be added to all indices during the process.
 ///
 /// <para>This method is used when batching meshes together for rendering. The parameter
 /// <code>targetStyle</code> will point to the style of a <code>MeshBatch</code> (a
 /// subclass of <code>Mesh</code>). Subclasses may override this method if they need
 /// to modify the index data in that process.</para>
 /// </summary>
 public virtual void BatchIndexData(MeshStyle targetStyle, int targetIndexId = 0, int offset = 0,
                                    int indexId = 0, int numIndices = -1)
 {
     _indexData.CopyTo(targetStyle._indexData, targetIndexId, offset, indexId, numIndices);
 }
示例#4
0
        public void testCopyTo()
        {
            // arbitrary data -> arbitrary data
            var source = new IndexData();

            source.AddTriangle(1, 2, 3);
            source.AddTriangle(4, 5, 6);

            var target = new IndexData();

            target.AddTriangle(7, 8, 9);
            source.CopyTo(target, 0, 0, 3, 3);

            Assert.AreEqual(3, target.NumIndices);
            Assert.AreEqual(4, target.GetIndex(0));
            Assert.AreEqual(5, target.GetIndex(1));
            Assert.AreEqual(6, target.GetIndex(2));

            source.CopyTo(target, 3);
            Assert.AreEqual(9, target.NumIndices);

            // quad data -> quad data
            source.Clear();
            target.Clear();

            source.AddTriangle(0, 1, 2);
            target.AddQuad(0, 1, 2, 3);
            source.CopyTo(target, 6, 4);

            Assert.IsTrue(target.UseQuadLayout);
            Assert.AreEqual(9, target.NumIndices);
            Assert.AreEqual(2, target.GetIndex(5));
            Assert.AreEqual(4, target.GetIndex(6));
            Assert.AreEqual(5, target.GetIndex(7));
            Assert.AreEqual(6, target.GetIndex(8));

            // quad data -> arbitrary data
            target.Clear();
            target.AddQuad(1, 2, 3, 4);
            source.CopyTo(target, 6, 4);

            Assert.IsTrue(source.UseQuadLayout);
            Assert.IsFalse(target.UseQuadLayout);
            Assert.AreEqual(9, target.NumIndices);
            Assert.AreEqual(3, target.GetIndex(5));
            Assert.AreEqual(4, target.GetIndex(6));
            Assert.AreEqual(5, target.GetIndex(7));
            Assert.AreEqual(6, target.GetIndex(8));

            // arbitrary data -> quad data
            source.Clear();
            source.AddTriangle(1, 2, 3);
            target.Clear();
            target.AddQuad(0, 1, 2, 3);
            source.CopyTo(target, 6, 4);

            Assert.IsFalse(source.UseQuadLayout);
            Assert.IsFalse(target.UseQuadLayout);
            Assert.AreEqual(9, target.NumIndices);
            Assert.AreEqual(2, target.GetIndex(5));
            Assert.AreEqual(5, target.GetIndex(6));
            Assert.AreEqual(6, target.GetIndex(7));
            Assert.AreEqual(7, target.GetIndex(8));
        }