public void ClearWorks() { var tree = new RBush <Point>(maxEntries: 4); tree.BulkLoad(points); tree.Clear(); Assert.Equal(0, tree.Count); Assert.Empty(tree.Root.children); }
private void RebuildDynamicIndex() { RTreeDynamic.Clear(); foreach (var body in Bodies) { body.Project(Time); body.Envelope = new Envelope( body.Position.X - body.Size, body.Position.Y - body.Size, body.Position.X + body.Size, body.Position.Y + body.Size); } RTreeDynamic.BulkLoad(Bodies.Where(b => !b.IsStatic)); }
public void Step() { if (Processing) { throw new Exception("Reentered"); } Processing = true; lock (this.Bodies) { var start = DateTime.Now; Time = (uint)((start.Ticks - OffsetTicks) / 10000); RTree.Clear(); foreach (var body in Bodies) { body.Project(Time); } RTree.BulkLoad(Bodies); var origActors = Actors.ToList(); foreach (var actor in Actors) { int actors = Actors.Count(); actor.Think(); if (Actors.Count() != actors) { throw new Exception("Collection modified in think time"); } } foreach (var actor in Actors.ToList()) { actor.CreateDestroy(); } foreach (var body in Bodies) { if (body.IsDirty) { body.DefinitionTime = this.Time; body.OriginalPosition = body.Position; body.OriginalAngle = body.Angle; body.IsDirty = false; } } ProcessLeaderboard(); var elapsed = DateTime.Now.Subtract(start).TotalMilliseconds; if (elapsed > Hook.StepTime) { Console.WriteLine("**** 100% processing time warning"); } else if (elapsed > Hook.StepTime * 0.8f) { Console.WriteLine("*** 80% processing time warning"); } else if (elapsed > Hook.StepTime * 0.5f) { Console.WriteLine("** 50% processing time warning"); } } Processing = false; }