private static void GetVertexComponentSize(uint[] sizes, uint[] aligns, uint type, uint count, ref uint biggest, ref uint size)
 {
     if (sizes[type] != 0)
     {
         size  = MemorySystem.Align(size, aligns[type]);
         size += sizes[type] * count;
         if (aligns[type] > biggest)
         {
             biggest = aligns[type];
         }
     }
 }
        private static uint DetermineVertexSize(uint vertexType, out uint alignmentDelta)
        {
            // Kindly yoinked (with permission) from ector's DaSh

            uint positionType = (vertexType & VertexType.PositionMask) >> 7;
            uint normalType   = (vertexType & VertexType.NormalMask) >> 5;
            uint textureType  = (vertexType & VertexType.TextureMask);
            uint weightCount  = ((vertexType & VertexType.WeightCountMask) >> 14) + 1;
            uint weightType   = (vertexType & VertexType.WeightMask) >> 9;
            uint colorType    = (vertexType & VertexType.ColorMask) >> 2;
            uint morphCount   = (vertexType & VertexType.MorphCountMask) >> 18;

            uint size    = 0;
            uint biggest = 0;

            if (weightType > 0)
            {
                GetVertexComponentSize(v_weightSizes, v_weightAlign, weightType, weightCount, ref biggest, ref size);                   // WRONG - count?
            }
            if (textureType > 0)
            {
                GetVertexComponentSize(v_textureSizes, v_textureAlign, textureType, 1, ref biggest, ref size);
            }
            if (colorType > 0)
            {
                GetVertexComponentSize(v_colorSizes, v_colorAlign, colorType, 1, ref biggest, ref size);
            }
            if (normalType > 0)
            {
                GetVertexComponentSize(v_normalSizes, v_normalAlign, normalType, 1, ref biggest, ref size);
            }
            GetVertexComponentSize(v_positionSizes, v_positionAlign, positionType, 1, ref biggest, ref size);

            // do something with morph count?
            Debug.Assert(morphCount == 0);

            uint result = MemorySystem.Align(size, biggest);

            alignmentDelta = result - size;
            return(result);
        }