/// <summary> /// This are the vertices that create the marine bound /// </summary> private void FindVertexUnderNeathWater() { var yS = UList.FindYAxisCommonValues(m.AllVertexs, H.Descending); float firstUnder = UList.FindFirstYBelow(yS, Program.gameScene.WaterBody.transform.position.y); _marineBounds = UList.FindVectorsOnSameHeight(m.AllVertexs, firstUnder, 0.05f); //0.07f _marineBounds = UList.EliminateDuplicatesByDist(_marineBounds, 0.3f); //0.2 float firstClos = UList.FindFirstYBelow(yS, m.IniTerr.MathCenter.y - 1f); var closer = UList.FindVectorsOnSameHeight(m.AllVertexs, firstClos, 0.02f); //0.07f closer = UList.EliminateDuplicatesByDist(closer, 0.3f); //0.2 _marineBounds.AddRange(closer); float lowest = UMath.ReturnMinimumDifferentThanZero(yS) + 1f; var low = UList.FindVectorsOnSameHeight(m.AllVertexs, lowest, 0.01f); //0.07f low = UList.EliminateDuplicatesByDist(low, 0.4f); //0.2 _marineBounds.AddRange(low); //RenderMarineBounds(); Debug.Log(_marineBounds.Count + " _marineBounds"); //AddMarinePositions(); DefineSeaPath(_marineBounds); addMarine = true; //AddMarineBoundsToCrystal(); }
private float valYSearch = 0.0001f;//0.05f private void PullMostCommonYLayer() { var yS = UList.FindYAxisCommonValues(m.AllVertexs, H.Descending); float yCommon = UList.FindFirstYBelow(yS, m.IniTerr.MathCenter.y); _commomLayer = UList.FindVectorsOnSameHeight(m.Vertices.ToList(), yCommon, valYSearch); Debug.Log("_commomLayer.Count:" + _commomLayer.Count); if (_commomLayer.Count == 0 && secCount < 1000) { valYSearch += 0.001f; secCount++; PullMostCommonYLayer(); } else if (_commomLayer.Count == 0 && secCount >= 1000) { throw new Exception("Not pull anything from CommonY Layer"); } }