< Summary

Class:SimpleOverlappingTracker
Assembly:OverlappingTracker
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Helpers/RectsOverlappingTracker/SimpleOverlappingTracker.cs
Covered lines:9
Uncovered lines:0
Coverable lines:9
Total lines:31
Line coverage:100% (9 of 9)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SimpleOverlappingTracker(...)0%110100%
Reset()0%110100%
RegisterPosition(...)0%330100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Helpers/RectsOverlappingTracker/SimpleOverlappingTracker.cs

#LineLine coverage
 1using System.Collections.Generic;
 2using UnityEngine;
 3
 4public class SimpleOverlappingTracker
 5{
 6    /// <summary>
 7    /// How much overlapping is allowed
 8    /// </summary>
 9    internal readonly float sqrTooCloseDistance;
 65110    internal readonly List<Vector2> positions = new List<Vector2>();
 11
 195312    public SimpleOverlappingTracker(float tooCloseDistance) { sqrTooCloseDistance = tooCloseDistance * tooCloseDistance;
 13
 2014    public void Reset() { positions.Clear(); }
 15
 16    /// <summary>
 17    /// Add a position to the cluster, returns true if the position is allowed
 18    /// </summary>
 19    /// <returns></returns>
 20    public bool RegisterPosition (Vector2 position)
 21    {
 1622        for (var i = 0; i < positions.Count; i++)
 23        {
 324            Vector2 toCompare = positions[i];
 325            if ((toCompare - position).sqrMagnitude < sqrTooCloseDistance)
 126                return false;
 27        }
 528        positions.Add(position);
 529        return true;
 30    }
 31}