Ejemplo 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;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public static MinValue GetMinValue(float3 position, MapValues values, float3 goal, NativeList <float> matrix)
        {
            var index = QuadrantVariables.IndexFromPosition(position, position, values);

            if (goalPoints.Length <= 0)
            {
                return(new MinValue()
                {
                    index = index.key,
                    offsetVector = new float3(0, 0, 0),
                    value = 0f,
                    goalPoint = goal,
                });
            }
            var min = ClosestGoalPoint(goal);

            if (index.key < 0)
            {
                return(new MinValue()
                {
                    index = index.key,
                    offsetVector = new float3(0, 0, 0),
                    value = 0f,
                    goalPoint = goal,
                });
            }
            return(GetMinValue(index.key + min * values.LayerSize, values, min, matrix));
        }
Ejemplo n.º 3
0
            public void Execute(Entity entity, int index, [ReadOnly] ref Translation translation, [ReadOnly] ref Tdata data)
            {
                int key = QuadrantVariables.GetPositionHashMapKey(translation.Value);

                quadrantHashMap.Add(key, new MyData()
                {
                    entity   = entity,
                    position = translation.Value,
                    data     = data
                });
            }
Ejemplo n.º 4
0
        private void NewGoalPointAdded()
        {
            var clearJob = new ClearJob()
            {
                array    = densityMatrix,
                array2   = tempMatrix,
                minIndex = densityMatrix.Length - Map.OneLayer * (goalPoints.Length - LastGoalPointCount)
            };
            var clearHandle = clearJob.Schedule(densityMatrix.Length, batchSize);

            clearHandle.Complete();

            while (LastGoalPointCount < goalPoints.Length)
            {
                var index = QuadrantVariables.IndexFromPosition(goalPoints[LastGoalPointCount], float3.zero, Map.Values);
                densityMatrix[index.key + Map.OneLayer * LastGoalPointCount] = 0.5f;
                tempMatrix[index.key + Map.OneLayer * LastGoalPointCount]    = 0.5f;
                LastGoalPointCount++;
            }
        }
Ejemplo n.º 5
0
 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);
         }
     }
 }