Reset() 개인적인 메소드

private Reset ( ) : void
리턴 void
예제 #1
0
        void IUpdatableGraph.UpdateAreaInit(GraphUpdateObject o)
        {
            if (!o.updatePhysics)
            {
                return;
            }

            AstarProfiler.Reset();
            AstarProfiler.StartProfile("UpdateAreaInit");
            AstarProfiler.StartProfile("CollectMeshes");

            RelevantGraphSurface.UpdateAllPositions();

            // Calculate world bounds of all affected tiles
            IntRect touchingTiles = GetTouchingTiles(o.bounds);
            Bounds  tileBounds    = GetTileBounds(touchingTiles);

            // Expand TileBorderSizeInWorldUnits voxels in all directions
            tileBounds.Expand(new Vector3(1, 0, 1) * TileBorderSizeInWorldUnits * 2);

            var meshes = CollectMeshes(tileBounds);

            if (globalVox == null)
            {
                // Create the voxelizer and set all settings
                globalVox = new Voxelize(CellHeight, cellSize, walkableClimb, walkableHeight, maxSlope, maxEdgeLength);
            }

            globalVox.inputMeshes = meshes;

            AstarProfiler.EndProfile("CollectMeshes");
            AstarProfiler.EndProfile("UpdateAreaInit");
        }
예제 #2
0
        public override void Scan()
        {
            AstarProfiler.Reset();
            //AstarProfiler.StartProfile ("Base Scan");

            //base.Scan ();

            //AstarProfiler.EndProfile ("Base Scan");
            if (useCRecast)
            {
                ScanCRecast();
            }
            else
            {
                MeshFilter[] filters;
                ExtraMesh[]  extraMeshes;

                if (!CollectMeshes(out filters, out extraMeshes))
                {
                    nodes = new Node[0];
                    return;
                }

                Voxelize vox = new Voxelize(cellHeight, cellSize, walkableClimb, walkableHeight, maxSlope);

                vox.maxEdgeLength      = maxEdgeLength;
                vox.forcedBounds       = forcedBounds;
                vox.includeOutOfBounds = includeOutOfBounds;


                //g.GetComponent<Voxelize>();
                vox.VoxelizeMesh(filters, extraMeshes);

                /*bool[,] open = new bool[width,depth];
                 * int[,] visited = new int[width+1,depth+1];
                 *
                 * for (int z=0;z<depth;z++) {
                 *      for (int x = 0;x < width;x++) {
                 *              open[x,z] = graphNodes[z*width+x].walkable;
                 *      }
                 * }*/

                /*for (int i=0;i<depth*width;i++) {
                 *      open[i] = graphNodes[i].walkable;
                 * }
                 *
                 *
                 * int wd = width*depth;
                 *
                 * List<int> boundary = new List<int>();
                 *
                 * int p = 0;
                 *
                 * for (int i=0;i<wd;i++) {
                 *      if (!open[i]) {
                 *              boundary.Add (i);
                 *
                 *              p = i;
                 *
                 *              int backtrack = i-1;
                 *
                 *
                 *      }*/

                vox.ErodeWalkableArea(Mathf.CeilToInt(2 * characterRadius / cellSize));


                vox.BuildDistanceField();

                vox.BuildRegions();

                VoxelContourSet cset = new VoxelContourSet();

                vox.BuildContours(contourMaxError, 1, cset, Voxelize.RC_CONTOUR_TESS_WALL_EDGES);

                VoxelMesh mesh;

                vox.BuildPolyMesh(cset, 3, out mesh);


                Vector3[] vertices = new Vector3[mesh.verts.Length];

                AstarProfiler.StartProfile("Build Nodes");

                for (int i = 0; i < vertices.Length; i++)
                {
                    vertices[i] = (Vector3)mesh.verts[i];
                }

                matrix = Matrix4x4.TRS(vox.voxelOffset, Quaternion.identity, Int3.Precision * Voxelize.CellScale);
                //Int3.Precision*Voxelize.CellScale+(Int3)vox.voxelOffset

                //GenerateNodes (this,vectorVertices,triangles, out originalVertices, out _vertices);

                NavMeshGraph.GenerateNodes(this, vertices, mesh.tris, out _vectorVertices, out _vertices);

                AstarProfiler.EndProfile("Build Nodes");

                AstarProfiler.PrintResults();
            }
        }