示例#1
0
 private void BuildVisibilityList(BspTreeLeaf bspTreeLeaf, dleaf_t leaf, int v)
 {
     if (v < 0)
         return;
     // Suppose Leaf is the leaf the player is in.
     for (int L = 1; L < dleaves.Count && v<visilist.Length; v++)
     {
         if (visilist[v] == 0)           // value 0, leaves invisible
         {
             L += 8 * visilist[v + 1];    // skip some leaves
             v++;
         }
         else                          // tag 8 leaves, if needed
         {                           // examine bits right to left
             for (byte bit = 1; bit != 0 && L < dleaves.Count; bit = (byte)(bit << 1), ++L)
             {
                 if (0 != (visilist[v] & bit))
                 {
                     if (L >= leaves.Count)
                         throw new ApplicationException(string.Format("leaf index {0} is out of {1}",L,leaves.Count));
                     bspTreeLeaf.VisibleLeaves.Add(leaves[L]);
                     leaf.VisibleLeaves.Add(L);
                 }
             }
         }
     }
 }
示例#2
0
 private void BuilFaceToLeafMap(FaceToLeafMap faceMap, int i, dleaf_t dleaf)
 {
     if (dleaf.lface_num >= 0)
         for (int j = dleaf.lface_id; j < dleaf.lface_id + dleaf.lface_num; ++j)
             faceMap.Faces[listOfFaces[j]].AddLeaf(i);
 }
示例#3
0
 private BspTreeLeaf BuildLeaf(dleaf_t dleaf)
 {
     var res = new BspTreeLeaf();
     res.Mins = new Vector3(dleaf.box.mins[0], dleaf.box.mins[1], dleaf.box.mins[2]);
     res.Maxs = new Vector3(dleaf.box.maxs[0], dleaf.box.maxs[1], dleaf.box.maxs[2]);
     if (dleaf.lface_num > 0)
         res.Colliders.Add(BuildFaceSoup(dleaf.lface_id, dleaf.lface_num));
     return res;
 }