Exemplo n.º 1
0
        // Create the job that will perform the clipping
        bool CreateMeshJob()
        {
            NativeArray <Triangle> sourceTriangleArray = new NativeArray <Triangle>(MaxDecalTriangles, Allocator.TempJob);
            int numSourceTriangles = GatherTriangles(sourceTriangleArray);

            if (numSourceTriangles == 0)
            {
                sourceTriangleArray.Dispose();
                return(false);
            }

            NativeArray <int>      numGeneratedTriangles  = new NativeArray <int>(1, Allocator.TempJob);
            NativeArray <Triangle> generatedTriangleArray = new NativeArray <Triangle>(MaxDecalTriangles, Allocator.TempJob);

            m_clippingJob = new ClippingJob();
            m_clippingJob.NumSourceTriangles    = numSourceTriangles;
            m_clippingJob.SourceTriangles       = sourceTriangleArray;
            m_clippingJob.GeneratedTriangles    = generatedTriangleArray;
            m_clippingJob.NumGeneratedTriangles = numGeneratedTriangles;

            m_clippingJob.ScratchPoints         = new NativeArray <float4>(10, Allocator.TempJob);
            m_clippingJob.ScratchTriangleEdges  = new NativeArray <Edge>(3, Allocator.TempJob);
            m_clippingJob.ScratchTrianglePlanes = new NativeArray <Plane>(1, Allocator.TempJob);
            UnitCube.GenerateStructures(out m_clippingJob.UnitCubeEdges, out m_clippingJob.UnitCubePlanes);

            return(true);
        }
Exemplo n.º 2
0
        public static void DrawGizmos(TRS trs)
        {
            NativeArray <Edge>  unitCubeEdges;
            NativeArray <Plane> unitCubePlanes;

            UnitCube.GenerateStructures(out unitCubeEdges, out unitCubePlanes);

            foreach (var e in unitCubeEdges)
            {
                GizmoLine(e, trs);
            }

            Gizmos.color = Color.green;
            GizmoLine(UnitCube.Edge0, trs);
            GizmoLine(UnitCube.Edge1, trs);
            GizmoLine(UnitCube.Edge2, trs);
            GizmoLine(UnitCube.Edge3, trs);

            float4 extrapolate0 = GizmoLineExtrapolate(UnitCube.Edge0.Vertex0, trs);
            float4 extrapolate1 = GizmoLineExtrapolate(UnitCube.Edge1.Vertex0, trs);
            float4 extrapolate2 = GizmoLineExtrapolate(UnitCube.Edge2.Vertex0, trs);
            float4 extrapolate3 = GizmoLineExtrapolate(UnitCube.Edge3.Vertex0, trs);

            GizmoLine(extrapolate0, extrapolate1, trs);
            GizmoLine(extrapolate1, extrapolate2, trs);
            GizmoLine(extrapolate2, extrapolate3, trs);
            GizmoLine(extrapolate3, extrapolate0, trs);

            unitCubeEdges.Dispose();
            unitCubePlanes.Dispose();
        }