///<summary>
 /// Constructs a new StaticGroupShape.
 ///</summary>
 ///<param name="collidables">List of collidables in the StaticGroup.</param>
 ///<param name="owner">StaticGroup directly associated with this shape.</param>
 public StaticGroupShape(IList<Collidable> collidables, StaticGroup owner)
 {
     this.StaticGroup = owner;
     CollidableTree = new BoundingBoxTree<Collidable>(collidables);
     //Rather than hooking up a bunch of ShapeChanged events here that don't capture the full capacity of change
     //in our child collidables, we will rely on the user telling the collidable tree to reformat itself directly.
 }
Beispiel #2
0
 ///<summary>
 /// Constructs a new StaticGroupShape.
 ///</summary>
 ///<param name="collidables">List of collidables in the StaticGroup.</param>
 ///<param name="owner">StaticGroup directly associated with this shape.</param>
 public StaticGroupShape(IList <Collidable> collidables, StaticGroup owner)
 {
     this.StaticGroup = owner;
     CollidableTree   = new BoundingBoxTree <Collidable>(collidables);
     //Rather than hooking up a bunch of ShapeChanged events here that don't capture the full capacity of change
     //in our child collidables, we will rely on the user telling the collidable tree to reformat itself directly.
 }
    void FixedUpdate()
    {
        bbTree = new BoundingBoxTree(objects, BoundingBoxTree.interieurOrderAxe.axeX);

        foreach (PhysicsObjectGraphics obj in physicsObjects)
        {
            obj.ApplyPhysics();
        }
        foreach (CubeGraphics obj in staticObjects)
        {
            obj.ApplyPhysics();
        }
    }
Beispiel #4
0
 ///<summary>
 /// Constructs a new compound hierarchy.
 ///</summary>
 ///<param name="owner">Owner of the hierarchy.</param>
 public CompoundHierarchy(CompoundCollidable owner)
 {
     this.owner = owner;
     var children = new CompoundChild[owner.children.count];
     Array.Copy(owner.children.Elements, children, owner.children.count);
     //In order to initialize a good tree, the local space bounding boxes should first be computed.
     //Otherwise, the tree would try to create a hierarchy based on a bunch of zeroed out bounding boxes!
     for (int i = 0; i < children.Length; i++)
     {
         children[i].CollisionInformation.worldTransform = owner.Shape.shapes.Elements[i].LocalTransform;
         children[i].CollisionInformation.UpdateBoundingBoxInternal(0);
     }
     tree = new BoundingBoxTree<CompoundChild>(children);
 }
        ///<summary>
        /// Constructs a new compound hierarchy.
        ///</summary>
        ///<param name="owner">Owner of the hierarchy.</param>
        public CompoundHierarchy(CompoundCollidable owner)
        {
            this.owner = owner;
            var children = new CompoundChild[owner.children.Count];

            Array.Copy(owner.children.Elements, children, owner.children.Count);
            //In order to initialize a good tree, the local space bounding boxes should first be computed.
            //Otherwise, the tree would try to create a hierarchy based on a bunch of zeroed out bounding boxes!
            for (int i = 0; i < children.Length; i++)
            {
                children[i].CollisionInformation.worldTransform = owner.Shape.shapes.Elements[i].LocalTransform;
                children[i].CollisionInformation.UpdateBoundingBoxInternal(F64.C0);
            }
            tree = new BoundingBoxTree <CompoundChild>(children);
        }
Beispiel #6
0
 public SceneGraph()
 {
     Root = new SceneGroup (this);
     Index = new BoundingBoxTree<SceneNode> ();
 }
Beispiel #7
0
        public static void TestBEPU(TestCollidableBEPU[] leaves, BEPUutilities.BoundingBox[] queries, int queryCount, int selfTestCount, int refitCount)
        {
            GC.Collect();
            {
                var warmLeaves = GetLeavesBEPU(2, 2, 2, 10, 10);
                BoundingBoxTree <TestCollidableBEPU> tree = new BoundingBoxTree <TestCollidableBEPU>(warmLeaves);
                Console.WriteLine($"BEPU Cachewarm Build, root AABB: {tree.BoundingBox}");

                tree.Refit();

                RawList <TestCollidableBEPU> results = new RawList <TestCollidableBEPU>();
                BEPUutilities.BoundingBox    aabb    = new BEPUutilities.BoundingBox {
                    Min = new BEPUutilities.Vector3(0, 0, 0), Max = new BEPUutilities.Vector3(1, 1, 1)
                };

                results.Count = 0;
                tree.GetOverlaps(aabb, results);

                var overlaps = new List <TreeOverlapPair <TestCollidableBEPU, TestCollidableBEPU> >(100);
                for (int i = 0; i < selfTestCount; ++i)
                {
                    tree.GetOverlaps(tree, overlaps);
                }
            }
            GC.Collect();

            {
                var startTime = Stopwatch.GetTimestamp() / (double)Stopwatch.Frequency;
                BoundingBoxTree <TestCollidableBEPU> tree = new BoundingBoxTree <TestCollidableBEPU>(leaves);
                var endTime = Stopwatch.GetTimestamp() / (double)Stopwatch.Frequency;
                Console.WriteLine($"BEPU Build Time: {endTime - startTime}, root AABB: {tree.BoundingBox}");

                startTime = Stopwatch.GetTimestamp() / (double)Stopwatch.Frequency;
                for (int i = 0; i < refitCount; ++i)
                {
                    tree.Refit();
                }
                endTime = Stopwatch.GetTimestamp() / (double)Stopwatch.Frequency;
                Console.WriteLine($"BEPU Refit Time: {endTime - startTime}");

                RawList <TestCollidableBEPU> results = new RawList <TestCollidableBEPU>();
                var queryMask = queries.Length - 1;
                startTime = Stopwatch.GetTimestamp() / (double)Stopwatch.Frequency;
                for (int i = 0; i < queryCount; ++i)
                {
                    results.Count = 0;
                    tree.GetOverlaps(queries[i & queryMask], results);
                }
                endTime = Stopwatch.GetTimestamp() / (double)Stopwatch.Frequency;
                Console.WriteLine($"BEPU Query Time: {endTime - startTime}, overlaps: {results.Count}");

                //var overlaps = new RawList<TreeOverlapPair<TestCollidableBEPU, TestCollidableBEPU>>(280000);
                //startTime = Stopwatch.GetTimestamp() / (double)Stopwatch.Frequency;
                //for (int i = 0; i < selfTestCount; ++i)
                //{
                //    overlaps.Count = 0;
                //    tree.GetOverlaps(tree, overlaps);
                //}
                //endTime = Stopwatch.GetTimestamp() / (double)Stopwatch.Frequency;
                //Console.WriteLine($"BEPU SelfTree Time: {endTime - startTime}, overlaps: {overlaps.Count}");
            }
        }
Beispiel #8
0
 public SceneGraph()
 {
     Root  = new SceneGroup(this);
     Index = new BoundingBoxTree <SceneNode> ();
 }
Beispiel #9
0
        public static void TestBEPU(TestCollidableBEPU[] leaves, BEPUutilities.BoundingBox[] queries, int queryCount, int selfTestCount, int refitCount)
        {
            GC.Collect();
            {
                var warmLeaves = GetLeavesBEPU(2, 2, 2, 10, 10);
                BoundingBoxTree<TestCollidableBEPU> tree = new BoundingBoxTree<TestCollidableBEPU>(warmLeaves);
                Console.WriteLine($"BEPU Cachewarm Build, root AABB: {tree.BoundingBox}");

                tree.Refit();

                RawList<TestCollidableBEPU> results = new RawList<TestCollidableBEPU>();
                BEPUutilities.BoundingBox aabb = new BEPUutilities.BoundingBox { Min = new BEPUutilities.Vector3(0, 0, 0), Max = new BEPUutilities.Vector3(1, 1, 1) };

                results.Count = 0;
                tree.GetOverlaps(aabb, results);

                var overlaps = new List<TreeOverlapPair<TestCollidableBEPU, TestCollidableBEPU>>(100);
                for (int i = 0; i < selfTestCount; ++i)
                {
                    tree.GetOverlaps(tree, overlaps);
                }
            }
            GC.Collect();

            {

                var startTime = Stopwatch.GetTimestamp() / (double)Stopwatch.Frequency;
                BoundingBoxTree<TestCollidableBEPU> tree = new BoundingBoxTree<TestCollidableBEPU>(leaves);
                var endTime = Stopwatch.GetTimestamp() / (double)Stopwatch.Frequency;
                Console.WriteLine($"BEPU Build Time: {endTime - startTime}, root AABB: {tree.BoundingBox}");

                startTime = Stopwatch.GetTimestamp() / (double)Stopwatch.Frequency;
                for (int i = 0; i < refitCount; ++i)
                {
                    tree.Refit();
                }
                endTime = Stopwatch.GetTimestamp() / (double)Stopwatch.Frequency;
                Console.WriteLine($"BEPU Refit Time: {endTime - startTime}");

                RawList<TestCollidableBEPU> results = new RawList<TestCollidableBEPU>();
                var queryMask = queries.Length - 1;
                startTime = Stopwatch.GetTimestamp() / (double)Stopwatch.Frequency;
                for (int i = 0; i < queryCount; ++i)
                {
                    results.Count = 0;
                    tree.GetOverlaps(queries[i & queryMask], results);
                }
                endTime = Stopwatch.GetTimestamp() / (double)Stopwatch.Frequency;
                Console.WriteLine($"BEPU Query Time: {endTime - startTime}, overlaps: {results.Count}");

                //var overlaps = new RawList<TreeOverlapPair<TestCollidableBEPU, TestCollidableBEPU>>(280000);
                //startTime = Stopwatch.GetTimestamp() / (double)Stopwatch.Frequency;
                //for (int i = 0; i < selfTestCount; ++i)
                //{
                //    overlaps.Count = 0;
                //    tree.GetOverlaps(tree, overlaps);
                //}
                //endTime = Stopwatch.GetTimestamp() / (double)Stopwatch.Frequency;
                //Console.WriteLine($"BEPU SelfTree Time: {endTime - startTime}, overlaps: {overlaps.Count}");
            }
        }