public void FinishParse()
        {
            BSSD = new BlockShapeSubDetails();
            for (int i = 0; i < 64; i++)
            {
                BSSD.Verts[i] = GetVertices(Vector3.Zero, (i & 1) == 1, (i & 2) == 2, (i & 4) == 4, (i & 8) == 8, (i & 16) == 16, (i & 32) == 32);
                BSSD.Norms[i] = GetNormals(Vector3.Zero, (i & 1) == 1, (i & 2) == 2, (i & 4) == 4, (i & 8) == 8, (i & 16) == 16, (i & 32) == 32);
                BSSD.TCrds[i] = GetTCoords(Vector3.Zero, Material.DEBUG, (i & 1) == 1, (i & 2) == 2, (i & 4) == 4, (i & 8) == 8, (i & 16) == 16, (i & 32) == 32).ToArray();
            }
            EntityShape es = GetShape(DamageMode, out Location offset, false);

            Coll = es.GetCollidableInstance();
            Coll.LocalPosition = offset.ToBVector();
            Vector3 zero = Vector3.Zero;

            BEPUutilities.Quaternion ident = BEPUutilities.Quaternion.Identity;
            Coll.UpdateWorldTransform(ref zero, ref ident);
            RigidTransform rt = new RigidTransform(zero, ident);

            Coll.UpdateBoundingBoxForTransform(ref rt);
            EntityShape es2 = GetShape(DamageMode, out offset, true);
        }
        private void Subdivide()
        {
            // TODO: Save TCs and work with them properly.
            Shape p = new Shape();
            Dictionary <Location, Point> ps = new Dictionary <Location, Point>();

            for (int i = 0; i < BSSD.Verts[0].Count; i++)
            {
                Location t = new Location(BSSD.Verts[0][i]);
                if (!ps.ContainsKey(t))
                {
                    ps.Add(t, new Point(BSSD.Verts[0][i]));
                }
            }
            for (int i = 0; i < BSSD.Verts[0].Count; i += 3)
            {
                Point a = ps[new Location(BSSD.Verts[0][i])];
                Point b = ps[new Location(BSSD.Verts[0][i + 1])];
                Point c = ps[new Location(BSSD.Verts[0][i + 2])];
                if (i + 3 < BSSD.Verts[0].Count)
                {
                    Point a2 = ps[new Location(BSSD.Verts[0][i + 3])];
                    Point b2 = ps[new Location(BSSD.Verts[0][i + 4])];
                    Point c2 = ps[new Location(BSSD.Verts[0][i + 5])];
                    bool  ac = a2 == a || a2 == b || a2 == c;
                    bool  bc = b2 == a || b2 == b || b2 == c;
                    bool  cc = c2 == a || c2 == b || c2 == c;
                    if (ac && bc && cc)
                    {
                        SysConsole.Output(OutputType.WARNING, this + " has weird setup: " + a + ", " + b + ", " + c);
                        p.AddFace(SubdivisionUtilities.CreateFaceF(p.AllEdges, a, b, c));
                    }
                    else if (ac && cc)
                    {
                        p.AddFace(SubdivisionUtilities.CreateFaceF(p.AllEdges, a, b, b2, c));
                        i += 3;
                    }
                    else if (ac && bc)
                    {
                        p.AddFace(SubdivisionUtilities.CreateFaceF(p.AllEdges, a, b, c, c2));
                        i += 3;
                    }
                    else if (bc && cc)
                    {
                        p.AddFace(SubdivisionUtilities.CreateFaceF(p.AllEdges, a, b, c, a2));
                        i += 3;
                    }
                    else
                    {
                        p.AddFace(SubdivisionUtilities.CreateFaceF(p.AllEdges, a, b, c));
                    }
                }
                else
                {
                    p.AddFace(SubdivisionUtilities.CreateFaceF(p.AllEdges, a, b, c));
                }
            }
            CatmullClarkSubdivider cmcs = new CatmullClarkSubdivider();
            Shape          res          = cmcs.Subdivide(p);
            List <Vector3> vecs         = new List <Vector3>();
            List <Vector3> norms        = new List <Vector3>();
            List <Vector3> Tcs          = new List <Vector3>();

            foreach (Face face in res.Faces)
            {
                for (int i = 0; i < 3; i++)
                {
                    vecs.Add(face.AllPoints[i].Position);
                    norms.Add(face.Normal);
                    Tcs.Add(new Vector3(0, 0, BSSD.TCrds[0][0].Z));
                }
            }
            BSSD = new BlockShapeSubDetails();
            Vector3[] tcrds = Tcs.ToArray();
            for (int i = 0; i < BSSD.Verts.Length; i++)
            {
                BSSD.Verts[i] = vecs;
                BSSD.Norms[i] = norms;
                BSSD.TCrds[i] = tcrds;
            }
        }