Axiom.Components.Terrain.TerrainQuadTreeNode.CalcSkirtVertexIndex C# (CSharp) Method

CalcSkirtVertexIndex() protected method

protected CalcSkirtVertexIndex ( ushort mainIndex, bool isCol ) : ushort
mainIndex ushort
isCol bool
return ushort
        protected ushort CalcSkirtVertexIndex(ushort mainIndex, bool isCol)
        {
            VertexDataRecord vdr = this.VertextDataRecord;
            // row / col in main vertex resolution
            ushort row = (ushort)(mainIndex / vdr.Size);
            ushort col = (ushort)(mainIndex % vdr.Size);

            // skrits are after main vertices, so skip them
            ushort ubase = (ushort)(vdr.Size * vdr.Size);

            // The layout in vertex data is:
            // 1. row skirts
            //    numSkirtRowsCols rows of resolution vertices each
            // 2. column skirts
            //    numSkirtRowsCols cols of resolution vertices each

            // No offsets used here, this is an index into the current vertex data, 
            // which is already relative
            if (isCol)
            {
                ushort skirtNum = (ushort)(col / vdr.SkirtRowColSkip);
                ushort colBase = (ushort)(vdr.NumSkirtRowsCols * vdr.Size);
                return (ushort)(ubase + colBase + vdr.Size * skirtNum + row);
            }
            else
            {
                ushort skirtNum = (ushort)(row / vdr.SkirtRowColSkip);
                return (ushort)(ubase + vdr.Size * skirtNum + col);
            }
        }