本地合并备份

This commit is contained in:
lishuo committed 2021-04-27 15:15:51 +08:00
1 parent 2b275d6dc5
commit 4353a38c96
44 files changed
+5568 -4294

No files matched your search

@@ -12,7 +12,8 @@ namespace Assets.Scenes.Ride.Scripts
public class ChartDataSourceScript:MonoBehaviour, IComparer<DoubleVector2>
{
public string Category = "Player 2";
public int DownSampleToPoints = 200;
public int DownSampleToPoints = 0;
public int targetPoints = 500;
public List<DoubleVector2> mData = new List<DoubleVector2>(); // the data held by the chart
double pageSize = 2f;
double currentPagePosition = 0.0;
@@ -24,15 +25,24 @@ namespace Assets.Scenes.Ride.Scripts
{
graph = GetComponent<GraphChartBase>();
}
public bool isEnd(int index)
public double GetRealTimeStart()
{
return index - start == 51;
return graph.HorizontalScrolling / mData.Count();
}
public bool isMid(int index)
public double GetRealTimeEnd()
{
return index - start == 26;
return (graph.HorizontalScrolling+ graph.DataSource.HorizontalViewSize) / mData.Count();
}
public bool ReachEnd()
{
return graph.HorizontalScrolling + graph.DataSource.HorizontalViewSize >= mData.Count;
}
public bool ReachMid(int index)
{
return index - graph.HorizontalScrolling >= graph.DataSource.HorizontalViewSize / 2;
}
bool VerifySorted(List<DoubleVector2> data)
{
@@ -67,6 +77,8 @@ namespace Assets.Scenes.Ride.Scripts
double sampleCount = ((double)total) / (double)DownSampleToPoints;
// graph.DataSource.AddPointToCategory(Category, mData[start].x, mData[start].y);
pointMap.Clear();
for (int i = 0; i < DownSampleToPoints; i++)
{
int fractionStart = start + (int)(i * sampleCount); // the first point with a fraction
@@ -74,16 +86,19 @@ namespace Assets.Scenes.Ride.Scripts
fractionEnd = Math.Min(fractionEnd, mData.Count - 1);
double x = 0, y = 0;
double divide = 0.0;
List<int> l = new List<int>();
for (int j = fractionStart; j < fractionEnd; j++) // avarge the poins
{
x += mData[j].x;
y += mData[j].y;
l.Add(j);
divide++;
}
if (divide > 0.0)
{
x /= divide;
y /= divide;
pointMap.Add(l, i);
graph.DataSource.AddPointToCategory("Player 2", x, y);
}
else
@@ -91,8 +106,21 @@ namespace Assets.Scenes.Ride.Scripts
}
// graph.DataSource.AddPointToCategory(Category, mData[last].x, mData[last].y);
}
public int GetViewIndex(int index)
{
foreach (var item in pointMap)
{
if (item.Key.Contains(index))
{
return item.Value;
}
}
return index;
}
int FindClosestIndex(double position) // if you want to know what is index is currently displayed . use binary search to find it
private IDictionary<IList<int>, int> pointMap = new Dictionary<IList<int>, int>();
public int FindClosestIndex(double position) // if you want to know what is index is currently displayed . use binary search to find it
{
//NOTE :: this method assumes your data is sorted !!!
int res = mData.BinarySearch(new DoubleVector2(position, 0.0), this);
@@ -130,7 +158,7 @@ namespace Assets.Scenes.Ride.Scripts
}
public int start, end;
void LoadPage(double pagePosition)
public void LoadPage(double pagePosition)
{
if (graph != null)
{
@@ -141,7 +169,9 @@ namespace Assets.Scenes.Ride.Scripts
findPointsForPage(pagePosition, out start, out end); // get the page edges
graph.DataSource.ClearCategory("Player 2"); // clear the cateogry
graph.DataSource.HorizontalViewSize = targetPoints > mData.Count ? mData.Count : targetPoints;
if (DownSampleToPoints <= 0)
LoadWithoutDownSampling(start, end);
else