Exemplo n.º 1
0
        private static void _SafeAreaCallbackShrink(IntPtr lineCollectionPtr, IntPtr safeAreaDetailRectPtr)
        {
            if (lineCollectionPtr == IntPtr.Zero || safeAreaDetailRectPtr == IntPtr.Zero)
            {
                Debug.LogError("BoundarySystem callback is inValid!");
                return;
            }

            if (instance.boundarySystemCallbackShrink != null)
            {
                List <Vector3>         boundaryPoints = new List <Vector3>();
                List <List <Vector3> > unusedLines    = new List <List <Vector3> >();

                int byteNum  = Marshal.SizeOf(typeof(Pvr_SafeAreaAlgoAPI.GSALine));
                int byteNum2 = Marshal.SizeOf(typeof(Pvr_SafeAreaAlgoAPI.GSAPoint3i));
                // boundary
                Pvr_SafeAreaAlgoAPI.GSALineCollection collection = Pvr_BoundaryAPI.IntPtrToStruct <Pvr_SafeAreaAlgoAPI.GSALineCollection>(lineCollectionPtr);
                IntPtr ptr;

                for (int i = 0; i < collection.lineCount; i++)
                {
                    ptr = new IntPtr(collection.lineArray.ToInt64() + (byteNum * i));
                    Pvr_SafeAreaAlgoAPI.GSALine line = (Pvr_SafeAreaAlgoAPI.GSALine)Marshal.PtrToStructure(ptr, typeof(Pvr_SafeAreaAlgoAPI.GSALine));

                    List <Vector3> newLine = new List <Vector3>();

                    for (int j = 0; j < line.pointCount; j++)
                    {
                        IntPtr tptr = new IntPtr(line.pointArray.ToInt64() + (byteNum2 * j));
                        Pvr_SafeAreaAlgoAPI.GSAPoint3i point = (Pvr_SafeAreaAlgoAPI.GSAPoint3i)Marshal.PtrToStructure(tptr, typeof(Pvr_SafeAreaAlgoAPI.GSAPoint3i));
                        newLine.Add(new Vector3(point.x / 1000f, point.y / 1000f, point.z / 1000f));
                    }

                    if (i == 0) // first line for colsed boundary
                    {
                        boundaryPoints = newLine;
                    }
                    else
                    {
                        unusedLines.Add(newLine);
                    }
                }

                // Rect Detail Points
                List <Vector3> rectPoints = new List <Vector3>();
                Pvr_SafeAreaAlgoAPI.GSALineCollection safeAreaRectLineCollection = Pvr_BoundaryAPI.IntPtrToStruct <Pvr_SafeAreaAlgoAPI.GSALineCollection>(safeAreaDetailRectPtr);
                IntPtr safeAreaRectLinePtr;

                for (int i = 0; i < safeAreaRectLineCollection.lineCount; i++)
                {
                    safeAreaRectLinePtr = new IntPtr(safeAreaRectLineCollection.lineArray.ToInt64() + (byteNum * i));
                    Pvr_SafeAreaAlgoAPI.GSALine line = (Pvr_SafeAreaAlgoAPI.GSALine)Marshal.PtrToStructure(safeAreaRectLinePtr, typeof(Pvr_SafeAreaAlgoAPI.GSALine));

                    for (int j = 0; j < line.pointCount; j++)
                    {
                        IntPtr tptr = new IntPtr(line.pointArray.ToInt64() + (byteNum2 * j));
                        Pvr_SafeAreaAlgoAPI.GSAPoint3i point = (Pvr_SafeAreaAlgoAPI.GSAPoint3i)Marshal.PtrToStructure(tptr, typeof(Pvr_SafeAreaAlgoAPI.GSAPoint3i));
                        rectPoints.Add(new Vector3(point.x / 1000f, point.y / 1000f, point.z / 1000f));
                    }
                }

                instance.boundarySystemCallbackShrink(rectPoints, boundaryPoints, unusedLines);
            }
        }
Exemplo n.º 2
0
        private static void _SafeAreaCallback(IntPtr lineCollectionPtr, IntPtr safeAreaRectPtr)
        {
            if (lineCollectionPtr == IntPtr.Zero || safeAreaRectPtr == IntPtr.Zero)
            {
                Debug.LogError("BoundarySystem callback is inValid!");
                return;
            }

            if (instance.boundarySystemCallback != null)
            {
                List <Vector3>         boundaryPoints = new List <Vector3>();
                List <List <Vector3> > unusedLines    = new List <List <Vector3> >();

                int byteNum  = Marshal.SizeOf(typeof(Pvr_SafeAreaAlgoAPI.GSALine));
                int byteNum2 = Marshal.SizeOf(typeof(Pvr_SafeAreaAlgoAPI.GSAPoint3i));
                // boundary
                Pvr_SafeAreaAlgoAPI.GSALineCollection collection = Pvr_BoundaryAPI.IntPtrToStruct <Pvr_SafeAreaAlgoAPI.GSALineCollection>(lineCollectionPtr);
                IntPtr ptr;

                for (int i = 0; i < collection.lineCount; i++)
                {
                    ptr = new IntPtr(collection.lineArray.ToInt64() + (byteNum * i));
                    Pvr_SafeAreaAlgoAPI.GSALine line = (Pvr_SafeAreaAlgoAPI.GSALine)Marshal.PtrToStructure(ptr, typeof(Pvr_SafeAreaAlgoAPI.GSALine));

                    List <Vector3> newLine = new List <Vector3>();

                    for (int j = 0; j < line.pointCount; j++)
                    {
                        IntPtr tptr = new IntPtr(line.pointArray.ToInt64() + (byteNum2 * j));
                        Pvr_SafeAreaAlgoAPI.GSAPoint3i point = (Pvr_SafeAreaAlgoAPI.GSAPoint3i)Marshal.PtrToStructure(tptr, typeof(Pvr_SafeAreaAlgoAPI.GSAPoint3i));
                        newLine.Add(new Vector3(point.x / 1000f, point.y / 1000f, point.z / 1000f));
                    }

                    if (i == 0) // first line for colsed boundary
                    {
                        boundaryPoints = newLine;
                    }
                    else
                    {
                        unusedLines.Add(newLine);
                    }
                }

                // rect
                Pvr_SafeAreaAlgoAPI.GSARect algoResult   = Pvr_BoundaryAPI.IntPtrToStruct <Pvr_SafeAreaAlgoAPI.GSARect>(safeAreaRectPtr);
                BoundaryPlayerArea          playAreaInfo = new BoundaryPlayerArea();
                playAreaInfo.lowerleft  = new Vector3(algoResult.leftup.x / 1000f, algoResult.leftup.y / 1000f, algoResult.leftup.z / 1000f);
                playAreaInfo.upperleft  = new Vector3(algoResult.leftdown.x / 1000f, algoResult.leftdown.y / 1000f, algoResult.leftdown.z / 1000f);
                playAreaInfo.upperRight = new Vector3(algoResult.rightdown.x / 1000f, algoResult.rightdown.y / 1000f, algoResult.rightdown.z / 1000f);
                playAreaInfo.lowerRight = new Vector3(algoResult.rightup.x / 1000f, algoResult.rightup.y / 1000f, algoResult.rightup.z / 1000f);
                playAreaInfo.center     = new Vector3(algoResult.center.x / 1000f, algoResult.center.y / 1000f, algoResult.center.z / 1000f);
                playAreaInfo.width      = algoResult.width;
                playAreaInfo.height     = algoResult.height;
                playAreaInfo.isLegal    = algoResult.isLegal == 0 ? false : true;

                // extra info
                playAreaInfo.extraInfo.overMaxRange      = algoResult.legalData.overMaxRange == 0 ? false : true;
                playAreaInfo.extraInfo.includeBigGap     = algoResult.legalData.includeBigGrap == 0 ? false : true;
                playAreaInfo.extraInfo.bigGapNum         = algoResult.legalData.bigGapNum;
                playAreaInfo.extraInfo.centerOut         = algoResult.legalData.centerOut == 0 ? false : true;
                playAreaInfo.extraInfo.removeNarrow      = algoResult.legalData.removeNarrow == 0 ? false : true;
                playAreaInfo.extraInfo.overMaxRange_more = algoResult.legalData.overMaxRange_more == 0 ? false : true;
                playAreaInfo.extraInfo.validShrinkArea   = algoResult.legalData.validShrinkArea;

                instance.boundarySystemCallback(playAreaInfo, boundaryPoints, unusedLines);
            }
        }