Exemple #1
0
        public BCRBGraph(MeshTreeNode root)
        {
            LinkedList <MeshTreeNode> nodes = new LinkedList <MeshTreeNode>();

            nodes.AddLast(root);

            Fragments = new List <MeshTreeNode>();
            Edges     = new List <LinkedList <BCRBGraphEdge> >();
            while (nodes.Count != 0)
            {
                MeshTreeNode node = nodes.First.Value;
                nodes.RemoveFirst();
                if (node.IsLeaf())
                {
                    Fragments.Add(node);
                    Edges.Add(new LinkedList <BCRBGraphEdge>());
                }
                if (node.Left != null)
                {
                    nodes.AddLast(node.Left);
                }
                if (node.Right != null)
                {
                    nodes.AddLast(node.Right);
                }
            }

            int idx = 0;

            foreach (var fragment in Fragments)
            {
                foreach (var fragmentCollision in Fragments)
                {
                    if ((fragment != fragmentCollision) && fragment.Collides(fragmentCollision))
                    {
                        Edges[idx].AddLast(new BCRBGraphEdge(HIT_POINTS_MAX, fragmentCollision));
                    }
                }
                idx++;
            }
        }
 public bool Collides(MeshTreeNode meshTreeNode)
 {
     return(Mesh.bounds.Intersects(meshTreeNode.Mesh.bounds));
 }
Exemple #3
0
 public BCRBGraphEdge(float hitPoints, MeshTreeNode fragment)
 {
     _hitPoints = hitPoints;
     _fragment  = fragment;
 }