Exemplo n.º 1
0
        #pragma warning restore 612, 618

        private static void TessellateShape(Shape vectorShape, List <Geometry> geoms, TessellationOptions tessellationOptions, bool isConvex)
        {
            UnityEngine.Profiling.Profiler.BeginSample("TessellateShape");

            // Don't generate any geometry for pattern fills since these are generated from another SceneNode
            if (vectorShape.Fill != null && !(vectorShape.Fill is PatternFill))
            {
                Color shapeColor = Color.white;
                if (vectorShape.Fill is SolidFill)
                {
                    shapeColor = ((SolidFill)vectorShape.Fill).Color;
                }

                shapeColor.a *= vectorShape.Fill.Opacity;

                if (isConvex && vectorShape.Contours.Length == 1)
                {
                    TessellateConvexContour(vectorShape, vectorShape.PathProps.Stroke, shapeColor, geoms, tessellationOptions);
                }
                else
                {
                    TessellateShapeLibTess(vectorShape, shapeColor, geoms, tessellationOptions);
                }
            }

            var stroke = vectorShape.PathProps.Stroke;

            if (stroke != null && stroke.HalfThickness > ShapeUtils.Epsilon)
            {
                foreach (var c in vectorShape.Contours)
                {
                    Vector2[]   strokeVerts;
                    UInt16[]    strokeIndices;
                    Vector2[][] strokePats;
                    ShapeUtils.TessellatePath(c, vectorShape.PathProps, tessellationOptions, out strokeVerts, out strokeIndices, out strokePats);
                    if (strokeIndices.Length > 0)
                    {
                        geoms.Add(new Geometry()
                        {
                            Vertices = strokeVerts, Indices = strokeIndices, Paths = strokePats, Color = vectorShape.PathProps.Stroke.Color
                        });
                    }
                }
            }

            UnityEngine.Profiling.Profiler.EndSample();
        }
Exemplo n.º 2
0
        private static void TessellatePath(BezierContour contour, PathProperties pathProps, List <Geometry> geoms, TessellationOptions tessellationOptions)
        {
            UnityEngine.Profiling.Profiler.BeginSample("TessellatePath");

            if (pathProps.Stroke != null)
            {
                Vector2[]   vertices;
                UInt16[]    indices;
                Vector2[][] paths;
                ShapeUtils.TessellatePath(contour, pathProps, tessellationOptions, out vertices, out indices, out paths);

                var color = pathProps.Stroke.Color;
                if (indices.Length > 0)
                {
                    geoms.Add(new Geometry()
                    {
                        Vertices = vertices, Indices = indices, Paths = paths, Color = color
                    });
                }
            }

            UnityEngine.Profiling.Profiler.EndSample();
        }