static int EnsureCapacity(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         Spine.ExposedList <Spine.Animation> obj = (Spine.ExposedList <Spine.Animation>)ToLua.CheckObject <Spine.ExposedList <Spine.Animation> >(L, 1);
         int arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
         obj.EnsureCapacity(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
示例#2
0
        public ExposedList <int> Triangulate(ExposedList <float> verticesArray)
        {
            float[]           items        = verticesArray.Items;
            int               newSize      = verticesArray.Count >> 1;
            ExposedList <int> indicesArray = this.indicesArray;

            indicesArray.Clear(true);
            int[] indices = indicesArray.Resize(newSize).Items;
            for (int i = 0; i < newSize; i++)
            {
                indices[i] = i;
            }
            ExposedList <bool> isConcaveArray = this.isConcaveArray;

            bool[] flagArray = isConcaveArray.Resize(newSize).Items;
            int    index     = 0;
            int    num4      = newSize;

            while (index < num4)
            {
                flagArray[index] = IsConcave(index, newSize, items, indices);
                index++;
            }
            ExposedList <int> triangles = this.triangles;

            triangles.Clear(true);
            triangles.EnsureCapacity(Math.Max(0, newSize - 2) << 2);
            while (newSize > 3)
            {
                int num5 = newSize - 1;
                int num6 = 0;
                int num7 = 1;
Label_00B9:
                if (!flagArray[num6])
                {
                    int   num8  = indices[num5] << 1;
                    int   num9  = indices[num6] << 1;
                    int   num10 = indices[num7] << 1;
                    float num11 = items[num8];
                    float num12 = items[num8 + 1];
                    float num13 = items[num9];
                    float num14 = items[num9 + 1];
                    float num15 = items[num10];
                    float num16 = items[num10 + 1];
                    for (int j = (num7 + 1) % newSize; j != num5; j = (j + 1) % newSize)
                    {
                        if (flagArray[j])
                        {
                            int   num18 = indices[j] << 1;
                            float num19 = items[num18];
                            float num20 = items[num18 + 1];
                            if ((PositiveArea(num15, num16, num11, num12, num19, num20) && PositiveArea(num11, num12, num13, num14, num19, num20)) && PositiveArea(num13, num14, num15, num16, num19, num20))
                            {
                                goto Label_0194;
                            }
                        }
                    }
                    goto Label_01D2;
                }
Label_0194:
                if (num7 == 0)
                {
                    do
                    {
                        if (!flagArray[num6])
                        {
                            break;
                        }
                        num6--;
                    }while (num6 > 0);
                }
                else
                {
                    num5 = num6;
                    num6 = num7;
                    num7 = (num7 + 1) % newSize;
                    goto Label_00B9;
                }
Label_01D2:
                triangles.Add(indices[((newSize + num6) - 1) % newSize]);
                triangles.Add(indices[num6]);
                triangles.Add(indices[(num6 + 1) % newSize]);
                indicesArray.RemoveAt(num6);
                isConcaveArray.RemoveAt(num6);
                newSize--;
                int num21 = ((newSize + num6) - 1) % newSize;
                int num22 = (num6 != newSize) ? num6 : 0;
                flagArray[num21] = IsConcave(num21, newSize, items, indices);
                flagArray[num22] = IsConcave(num22, newSize, items, indices);
            }
            if (newSize == 3)
            {
                triangles.Add(indices[2]);
                triangles.Add(indices[0]);
                triangles.Add(indices[1]);
            }
            return(triangles);
        }
示例#3
0
        public ExposedList <int> Triangulate(ExposedList <float> verticesArray)
        {
            float[]           items       = verticesArray.Items;
            int               num         = verticesArray.Count >> 1;
            ExposedList <int> exposedList = indicesArray;

            exposedList.Clear();
            int[] items2 = exposedList.Resize(num).Items;
            for (int i = 0; i < num; i++)
            {
                items2[i] = i;
            }
            ExposedList <bool> exposedList2 = isConcaveArray;

            bool[] items3 = exposedList2.Resize(num).Items;
            int    j      = 0;

            for (int num2 = num; j < num2; j++)
            {
                items3[j] = IsConcave(j, num, items, items2);
            }
            ExposedList <int> exposedList3 = triangles;

            exposedList3.Clear();
            exposedList3.EnsureCapacity(Math.Max(0, num - 2) << 2);
            while (num > 3)
            {
                int num3 = num - 1;
                int num4 = 0;
                int num5 = 1;
                while (true)
                {
                    if (!items3[num4])
                    {
                        int   num6  = items2[num3] << 1;
                        int   num7  = items2[num4] << 1;
                        int   num8  = items2[num5] << 1;
                        float num9  = items[num6];
                        float num10 = items[num6 + 1];
                        float num11 = items[num7];
                        float num12 = items[num7 + 1];
                        float num13 = items[num8];
                        float num14 = items[num8 + 1];
                        for (int num15 = (num5 + 1) % num; num15 != num3; num15 = (num15 + 1) % num)
                        {
                            if (!items3[num15])
                            {
                                continue;
                            }
                            int   num16 = items2[num15] << 1;
                            float p3x   = items[num16];
                            float p3y   = items[num16 + 1];
                            if (!PositiveArea(num13, num14, num9, num10, p3x, p3y) || !PositiveArea(num9, num10, num11, num12, p3x, p3y) || !PositiveArea(num11, num12, num13, num14, p3x, p3y))
                            {
                                continue;
                            }
                            goto IL_0194;
                        }
                        break;
                    }
                    goto IL_0194;
IL_0194:
                    if (num5 == 0)
                    {
                        while (items3[num4])
                        {
                            num4--;
                            if (num4 <= 0)
                            {
                                break;
                            }
                        }
                        break;
                    }
                    num3 = num4;
                    num4 = num5;
                    num5 = (num5 + 1) % num;
                }
                exposedList3.Add(items2[(num + num4 - 1) % num]);
                exposedList3.Add(items2[num4]);
                exposedList3.Add(items2[(num4 + 1) % num]);
                exposedList.RemoveAt(num4);
                exposedList2.RemoveAt(num4);
                num--;
                int num17 = (num + num4 - 1) % num;
                int num18 = (num4 != num) ? num4 : 0;
                items3[num17] = IsConcave(num17, num, items, items2);
                items3[num18] = IsConcave(num18, num, items, items2);
            }
            if (num == 3)
            {
                exposedList3.Add(items2[2]);
                exposedList3.Add(items2[0]);
                exposedList3.Add(items2[1]);
            }
            return(exposedList3);
        }