Exemplo n.º 1
0
        void Debug()
        {
            for (int j = 1; j < Map.HeightPoints - 1; j++)
            {
                for (int i = 1; i < Map.WidthPoints - 1; i++)
                {
                    float right = densityMatrix[Map.OneLayer + QuadrantVariables.Index(i + 1, j, Map.Values)];
                    float left  = densityMatrix[Map.OneLayer + QuadrantVariables.Index(i - 1, j, Map.Values)];
                    float up    = densityMatrix[Map.OneLayer + QuadrantVariables.Index(i, j + 1, Map.Values)];
                    float down  = densityMatrix[Map.OneLayer + QuadrantVariables.Index(i, j - 1, Map.Values)];

                    var point = QuadrantVariables.ConvertToWorld(new float3(i, 0, j), Map.Values);
                    if (right < left && right < up && right < down)
                    {
                        DebugProxy.DrawLine(point, point + new float3(0.2f, 0, 0), Color.red);
                        continue;
                    }
                    if (left < up && left < down && left < right)
                    {
                        DebugProxy.DrawLine(point, point + new float3(-0.2f, 0, 0), Color.red);
                        continue;
                    }
                    if (up < down && up < right && up < left)
                    {
                        DebugProxy.DrawLine(point, point + new float3(0, 0, 0.2f), Color.red);
                        continue;
                    }
                    if (down < left && down < up && down < right)
                    {
                        DebugProxy.DrawLine(point, point + new float3(0, 0, -0.2f), Color.red);
                        continue;
                    }
                }
            }
        }
        public static void AddGoalPoint(float3 goalPoint)
        {
            if (goalPoints.Length > 0)
            {
                var min = ClosestGoalPoint(goalPoint);
                if (math.length(goalPoints[min] - goalPoint) < minDistance)
                {
                    return;
                }
            }

            goalPoints.Add(goalPoint);
            var layer = new NativeArray <float>(Map.OneLayer, Allocator.TempJob);

            densityMatrix.AddRange(layer);
            tempMatrix.AddRange(layer);
            layer.Dispose();

            DebugProxy.Log(goalPoint + " / " + goalPoints.Length);
        }
 private void Debug(MapValues values, int groupId, Color color)
 {
     DebugProxy.Log("Debug Draw Before");
     if (goalPoints.Length == 0 || groupId < 0)
     {
         return;
     }
     DebugProxy.Log("Debug Draw");
     for (int index = values.LayerSize * groupId; index < values.LayerSize * (groupId + 1); index += 7)
     {
         var small  = index % values.LayerSize;
         var height = small / values.heightPoints;
         var width  = small % values.heightPoints;
         var point  = QuadrantVariables.ConvertToWorld(new float3(height, 0, width), values);
         if (densityMatrix[index] > 0f)
         {
             var minValue = GetMinValue(index, Map.Values, groupId, ShortestPathSystem.densityMatrix);
             DebugProxy.DrawLine(point, point + minValue.offsetVector, color);
         }
     }
 }