Example #1
0
        public static void AddPoint(Vector3 pPoint, int pPointIndex)
        {
            //index < 0 = the point was re-added during the tree merging process
            //(where the index is not passed) - use the last index
            if (pPointIndex < 0)
            {
                pPointIndex = currentPointIndex;
            }

            currentPointIndex = pPointIndex;

            ProcessDebug(pPoint, pPointIndex);

            pointCounter++;

            CProjectData.Points.vegeArray.AddPointInField(pPoint);
            CProjectData.Points.vegeDetailArray.AddPointInField(pPoint);


            List <CTree> possibleTrees = GetPossibleTreesFor(pPoint, EPossibleTreesMethod.ClosestHigher, false);

            CTree selectedTree = SelectBestPossibleTree(possibleTrees, pPoint, true);

            /*if(selectedTree == null && detectMethod == EDetectionMethod.AddFactor2D)
             * {
             *      CTreeField f = CProjectData.Points.treeDetailArray.GetFieldContainingPoint(pPoint);
             *      List<CTree> treesInHood = f.GetDetectedTreesFromNeighbourhood();
             *      foreach(CTree tree in treesInHood)
             *      {
             *              selectedTree = tree;
             *              break;
             *      }
             * }*/

            if (selectedTree != null)
            {
                selectedTree.AddPoint(pPoint, pPointIndex);
            }
            else if (CProjectData.Points.treeDetailArray.GetFieldContainingPoint(pPoint).DetectedTrees.Count > 0)
            {
                //new tree cant be created on field where another tree was already detected - shouldnt happen
                CDebug.Error("trying to create tree on a field where a tree already is");
                return;
            }
            else
            {
                CreateNewTree(pPoint);
            }
        }