public void Report_ManyRandomElements_ShouldCorrectlyReturnAllCandidateColliders() { const int ObjectsCount = 10000; var shepard = new TestBox(10, 20); var random = new Random(); var list = new List <TestBox>(); list.Add(shepard); quadTree.Insert(shepard); for (int i = 0; i < ObjectsCount; i++) { var x = random.Next(0, WorldWidth - 10); var y = random.Next(0, WorldHeight - 10); var obj = new TestBox(x, y); list.Add(obj); quadTree.Insert(obj); } var listCollisions = PerformCollisionSearchList(shepard, list) .OrderBy(e => e) .ToList(); var quadTreeCollisions = PerformCollisionSearchQuadTree(shepard, quadTree) .OrderBy(e => e) .ToList(); CollectionAssert.AreEqual(quadTreeCollisions, listCollisions); }
private void createBox(Action <Box> setupAction = null) => AddStep("create box", () => { Clear(); Add(new Container { Anchor = Anchor.Centre, Origin = Anchor.Centre, Size = new Vector2(200), Children = new Drawable[] { new Box { RelativeSizeAxes = Axes.Both, Colour = new Color4(50, 50, 50, 255) }, blendedBox = new TestBox { Anchor = Anchor.Centre, Origin = Anchor.Centre, RelativeSizeAxes = Axes.Both, Colour = new Color4(100, 100, 100, 255), Size = new Vector2(0.5f), } } }); setupAction?.Invoke(blendedBox); });
/// <summary> /// 处理闭合查询错误回告 /// </summary> public IEnumerable <TestBox> ProcessCloseCheckForFalse() { List <TestBox> boxes = new List <TestBox>(); if (receiveData[7].Count != 0) { CAN_MSG_T msg = receiveData[7].Dequeue(); if (msg.data[2] == 0x01) { for (int i = 0; i < 3; i++) { TestBox box = new TestBox(msg.data[0] & 0x0f, msg.data[4 + i]); boxes.Add(box); } } else { for (int i = 0; i < 4; i++) { TestBox box = new TestBox(msg.data[0] & 0x0f, msg.data[3 + i]); boxes.Add(box); } } return(boxes); } return(null); }
public override void Load() { if (!Main.dedServ) { face = new UserInterface(); tb = new TestBox(); // tb.visible = true; face.SetState(tb); } }
public static void Main(string[] args) { QuadTree <TestBox> quadTree = new QuadTree <TestBox>(200, 200, 5); var source = new TestBox(0, 0); quadTree.Insert(source); quadTree.Insert(new TestBox(0, 10)); quadTree.Insert(new TestBox(0, 10)); quadTree.Insert(new TestBox(0, 10)); quadTree.Insert(new TestBox(0, 10)); }
public static void Main(string[] args) { QuadTree <TestBox> quadTree = new QuadTree <TestBox>(200, 200, 5); var source = new TestBox(0, 0); quadTree.Insert(source); quadTree.Insert(new TestBox(0, 10)); quadTree.Insert(new TestBox(0, 10)); quadTree.Insert(new TestBox(0, 10)); quadTree.Insert(new TestBox(0, 10)); var collisions = quadTree.Report(source.Bounds); }
public static void Main(string[] args) { QuadTree <TestBox> quadTree = new QuadTree <TestBox>(200, 200, 5); var source = new TestBox(0, 0); quadTree.Insert(source); quadTree.Insert(new TestBox(0, 10)); quadTree.Insert(new TestBox(0, 10)); quadTree.Insert(new TestBox(0, 10)); quadTree.Insert(new TestBox(0, 10)); var collisions = quadTree.Report(source.Bounds); Console.WriteLine(string.Join(" ", collisions)); Console.WriteLine(collisions.Count); }
static List <TestBox> PerformCollisionSearchList( TestBox obj, List <TestBox> list) { var result = new List <TestBox>(); for (int i = 0; i < list.Count; i++) { if (obj.Bounds.Intersects(list[i].Bounds) && obj != list[i]) { result.Add(list[i]); } } return(result); }
static List <TestBox> PerformCollisionSearchQuadTree( TestBox obj, QuadTree <TestBox> quadTree) { var result = new List <TestBox>(); var collisionCandidates = quadTree.Report(obj.Bounds).ToList(); for (int i = 0; i < collisionCandidates.Count; i++) { if (obj.Bounds.Intersects(collisionCandidates[i].Bounds) && obj != collisionCandidates[i]) { result.Add(collisionCandidates[i]); } } return(result); }
public static void Main() { QuadTree <TestBox> quadTree = new QuadTree <TestBox>(200, 200, 5); var source = new TestBox(0, 0); quadTree.Insert(source); quadTree.Insert(new TestBox(0, 10)); quadTree.Insert(new TestBox(-10, -10, 200, 200)); quadTree.Insert(new TestBox(5, 5)); quadTree.Insert(new TestBox(-10, -10, 150, 150)); var collisions = quadTree.Report(source.Bounds); foreach (var collision in collisions) { Console.WriteLine(collision); } }
private void Update() { TimeCounter += Time.deltaTime; if (TimeCounter < .5f) { return; } TimeCounter = 0; TestPoints.Clear(); for (int i = 0; i < NumberOfPoints; i++) { TestPoints.Add(UnityEngine.Random.insideUnitSphere * 3f); } TestBox.EnclosePoints(TestPoints.ToArray()); }
public override void Setup() { base.Setup(); NonRotatedBox = new TestBox( new BoxGeometry { Size = new float2(5f, 10f) }, new float3(-100f, 0f, 0f), quaternion.identity ); RotatedBox = new TestBox( new BoxGeometry { Size = new float2(20f, 30f) }, new float3(100f, 0f, 0f), quaternion.RotateZ(math.radians(90f)) ); }
public TestFilledGBuffer(DX11Game game, int width, int height) { this.game = game; GBuffer = new GBuffer(game.Device, width, height); var device = game.Device; var context = device.ImmediateContext; var diffuseTexture = Texture2D.FromFile(device, SlimDXDirectX11Test.Wallpaper001_png); diffuseTextureRv = new ShaderResourceView(device, diffuseTexture); shader = BasicShader.LoadAutoreload(game, new FileInfo(CompiledShaderCache.Current.RootShaderPath + "Deferred\\RenderGBuffer.fx")); shader.SetTechnique("Technique1"); box = new TestBox(device, shader.GetCurrentPass(0).Description.Signature); }
public MainWindow() { this.InitializeComponent(); RuntimeComponent1.UserControl userControl = new RuntimeComponent1.UserControl(); Binding testBlockBinding = new Binding() { Path = new PropertyPath("Text") }; TestBlock.DataContext = MyControl; TestBlock.SetBinding(TextBlock.TextProperty, testBlockBinding); Binding textBoxBinding = new Binding() { Path = new PropertyPath("Text"), Mode = BindingMode.TwoWay, Converter = new StringToStringConverter() }; TestBox.DataContext = MyControl; TestBox.SetBinding(TextBox.TextProperty, textBoxBinding); Binding sourceBlockBinding = new Binding() { Path = new PropertyPath("Source"), Converter = new UriToStringConverter() }; SourceBlock.DataContext = MyControl; SourceBlock.SetBinding(TextBlock.TextProperty, sourceBlockBinding); Binding sourceBoxBinding = new Binding() { Path = new PropertyPath("Source"), Mode = BindingMode.TwoWay, Converter = new UriToStringConverter() }; SourceBox.DataContext = MyControl; SourceBox.SetBinding(TextBox.TextProperty, sourceBoxBinding); }
public void TestTasksCanceledDuringLoadSequence() { var references = new WeakList <TestBox>(); AddStep("populate panels", () => { references.Clear(); for (int i = 0; i < 16; i++) { DelayedLoadUnloadWrapper loadUnloadWrapper; flow.Add(new Container { Size = new Vector2(128), Child = loadUnloadWrapper = new DelayedLoadUnloadWrapper(() => { var content = new TestBox { RelativeSizeAxes = Axes.Both }; references.Add(content); return(content); }, 0), }); // cancel load tasks after the delayed load has started. loadUnloadWrapper.DelayedLoadStarted += _ => game.Schedule(() => loadUnloadWrapper.UnbindAllBindables()); } }); AddStep("remove all panels", () => flow.Clear(false)); AddUntilStep("references lost", () => { GC.Collect(); return(!references.Any()); }); }
public void TestUpdateBeforeDrawFromLateAddition() { var receiver = new Container { Size = new Vector2(100), Child = new Box { Anchor = Anchor.Centre, Origin = Anchor.Centre, Size = new Vector2(50), Colour = Color4.Red } }; var sender = new HookableContainer(); var greenBox = new TestBox { Colour = Color4.Green }; AddStep("add children", () => { Children = new Drawable[] { new SpriteText { Text = "Red box should be visible, green should not be visible" }, // Order is important receiver, sender, }; }); sender.OnUpdateAfterChildren = () => receiver.Add(greenBox); AddStep("wait one frame", () => { }); AddAssert("green not present", () => !greenBox.IsPresent); }
public override void SetUp() { base.SetUp(); const int transforms_count = 10000; ManualClock clock; target = new TestBox { Clock = new FramedClock(clock = new ManualClock()) }; // transform one target member over a long period target.RotateTo(360, transforms_count * 2); // transform another over the same period many times for (int i = 0; i < transforms_count; i++) { target.Delay(i).MoveTo(new Vector2(0.01f), 1f); } clock.CurrentTime = target.LatestTransformEndTime; target.Clock.ProcessFrame(); }
private void TestBox_TextChanged(object sender, TextChangedEventArgs e) { TestBox.ScrollToEnd(); }
public void TestSetup() { uut = new TestBox(); }
public void Report_ManyRandomElements_ShouldCorrectlyReturnAllCandidateColliders() { const int ObjectsCount = 10; var shepard = new TestBox(10, 20); var random = new Random(); var list = new List<TestBox>(); list.Add(shepard); quadTree.Insert(shepard); for (int i = 0; i < ObjectsCount; i++) { var x = random.Next(0, WorldWidth - 10); var y = random.Next(0, WorldHeight - 10); var obj = new TestBox(x, y); list.Add(obj); quadTree.Insert(obj); } var listCollisions = PerformCollisionSearchList(shepard, list) .OrderBy(e => e) .ToList(); var quadTreeCollisions = PerformCollisionSearchQuadTree(shepard, quadTree) .OrderBy(e => e) .ToList(); CollectionAssert.AreEqual(quadTreeCollisions, listCollisions); }
static List<TestBox> PerformCollisionSearchList( TestBox obj, List<TestBox> list) { var result = new List<TestBox>(); Console.WriteLine(list.Count); for (int i = 0; i < list.Count; i++) { if (obj.Bounds.Intersects(list[i].Bounds) && obj != list[i]) { result.Add(list[i]); } } return result; }
static List<TestBox> PerformCollisionSearchQuadTree( TestBox obj, QuadTree<TestBox> quadTree) { var result = new List<TestBox>(); var collisionCandidates = quadTree.Report(obj.Bounds).ToList(); Console.WriteLine(collisionCandidates.Count); for (int i = 0; i < collisionCandidates.Count; i++) { if (obj.Bounds.Intersects(collisionCandidates[i].Bounds) && obj != collisionCandidates[i]) { result.Add(collisionCandidates[i]); } } return result; }