Exemplo n.º 1
0
    public void SimpleAABBTree_InsertTwoDisjointedElementsRemoveOne_ChecksOtherRemains()
    {//TODO: STILL
        SimpleAABBTree myTree   = new SimpleAABBTree();
        var            myEntity = new SimpleAABBTreeStaticOBJ(new BoundingBox(new Vector3(0, 0, 0), new Vector3(1, 1, 1)));

        myTree.Insert(myEntity);
        var         myEntity2 = new SimpleAABBTreeStaticOBJ(new BoundingBox(new Vector3(1.1f, 1.1f, 1.1f), new Vector3(2, 2, 2)));
        BoundingBox myBox     = new BoundingBox(new Vector3(1.1f, 1.1f, 1.1f), new Vector3(2, 2, 2));

        myTree.Insert(myEntity2);

        myTree.Remove(myEntity);

        var Results = myTree.BoundingPrimativeCast <Object>(myBox);

        Assert.IsTrue(Results.Count == 1);
        bool correctObject = false;

        foreach (object A in Results)
        {
            if (A == myEntity2)
            {
                correctObject = true;
            }
        }
        Assert.IsTrue(correctObject);
    }
Exemplo n.º 2
0
    public void SimpleAABBTree_InsertTwoOverlappingElementsRemoveOne_ChecksOtherRemains()
    {
        SimpleAABBTree myTree   = new SimpleAABBTree();
        var            myEntity = new SimpleAABBTreeStaticOBJ(new BoundingBox(new Vector3(0, 0, 0), new Vector3(1, 1, 1)));

        myTree.Insert(myEntity);
        BoundingBox myBox     = new BoundingBox(new Vector3(0.5f, 0.5f, 0.5f), new Vector3(2, 2, 2));
        var         myEntity2 = new SimpleAABBTreeStaticOBJ(myBox);

        myTree.Insert(myEntity2);

        myTree.Remove(myEntity);

        var Results = myTree.BoundingPrimativeCast <Object>(myBox);

        Assert.AreEqual(1, Results.Count, "Results didn't match expected number of items in the Tree.");
        bool correctObject = false;

        foreach (object A in Results)
        {
            if (A == myEntity2)
            {
                correctObject = true;
            }
        }
        Assert.IsTrue(correctObject);
    }
Exemplo n.º 3
0
    public void SimpleAABBTree_InsertTwoElements_Intersects_TreeCheck()
    {
        SimpleAABBTree myTree   = new SimpleAABBTree();
        var            myEntity = new SimpleAABBTreeStaticOBJ(new BoundingBox(new Vector3(0, 0, 0), new Vector3(1, 1, 1)));

        myTree.Insert(myEntity);
        myEntity = new SimpleAABBTreeStaticOBJ(new BoundingBox(new Vector3(0.5f, 0.5f, 0.5f), new Vector3(2, 2, 2)));
        BoundingBox myBox = new BoundingBox(new Vector3(0.5f, 0.5f, 0.5f), new Vector3(2, 2, 2));

        myTree.Insert(myEntity);

        var Results = myTree.BoundingPrimativeCast <Object>(myBox);

        Assert.IsTrue(Results.Count == 2);
        bool correctObject = false;

        foreach (object A in Results)
        {
            if (A == myEntity)
            {
                correctObject = true;
            }
        }
        Assert.IsTrue(correctObject);
    }
Exemplo n.º 4
0
    public void SimpleAABBTree_BoundingBoxHitDetection_HitOne_TreeOnlyHasNone()
    {
        SimpleAABBTree myTree = new SimpleAABBTree();

        BoundingBox         myTestBox = new BoundingBox(new Vector3(0f, 0f, 0f), new Vector3(2, 2, 2));
        RayCastHit <Object> myHit     = myTree.BoundingPrimativeCast <Object>(myTestBox);

        Assert.AreEqual(0, myHit.Count);
    }
Exemplo n.º 5
0
    public void SimpleAABBTree_BoundingBoxHitDetection_HitOne_TreeOnlyHasOne()
    {
        SimpleAABBTree myTree   = new SimpleAABBTree();
        var            myEntity = new SimpleAABBTreeStaticOBJ(new BoundingBox(new Vector3(0, 0, 0), new Vector3(1, 1, 1)));

        myTree.Insert(myEntity);
        BoundingBox         myTestBox = new BoundingBox(new Vector3(0f, 0f, 0f), new Vector3(2, 2, 2));
        RayCastHit <Object> myHit     = myTree.BoundingPrimativeCast <Object>(myTestBox);

        Assert.AreEqual(1, myHit.Count);
    }