Ejemplo n.º 1
0
        public void BuildUnitedCluster(int tolerance)
        {
            List <PVSVoxel> procVoxels = new List <PVSVoxel>();

            procVoxels.AddRange(Voxels);

            while (procVoxels.Count > 0)
            {
                var cur = procVoxels[0];
                procVoxels.RemoveAt(0);
                CombineVoxel cmb = new CombineVoxel(cur);
                UnitedCluster.Add(cmb);
                ProcNeighbour(cmb, cur, procVoxels, tolerance);
            }

            mCombinedBitSets = new List <Support.BitSet>(UnitedCluster.Count);
            int totalVis = 0;
            int maxVis   = 0;

            for (int i = 0; i < UnitedCluster.Count; i++)
            {
                UnitedCluster[i].CmbIndex = mCombinedBitSets.Count;
                mCombinedBitSets.Add(UnitedCluster[i].CombineBits);

                var num = UnitedCluster[i].CombineBits.FlagNumber;
                totalVis += num;
                if (num > maxVis)
                {
                    maxVis = num;
                }
            }
            totalVis /= UnitedCluster.Count;

            Profiler.Log.WriteLine(Profiler.ELogTag.Info, "PVSBuilder", $"平均每个Volume可见对象个数:{totalVis},最大可见:{maxVis}");
        }
Ejemplo n.º 2
0
 private void ProcNeighbour(CombineVoxel cmb, PVSVoxel vx, List <PVSVoxel> procVoxels, int tolerance)
 {
     cmb.Voxels.Add(vx);
     for (Agent.GeoBox.BoxFace i = Agent.GeoBox.BoxFace.StartIndex; i < Agent.GeoBox.BoxFace.Number; i++)
     {
         int index = vx.LinkedVoxels[(int)i];
         if (index < 0)
         {
             continue;
         }
         if (cmb.TryCombine(Voxels[index], tolerance))
         {
             vx.FaceType |= (Graphics.Mesh.CGfxMeshCooker.EBoxFace)(1 << (int)i);
             var oppositeFace = (int)GetOppositeFace(i);
             Voxels[index].FaceType |= (Graphics.Mesh.CGfxMeshCooker.EBoxFace)(1 << oppositeFace);
             if (false == Remove(procVoxels, Voxels[index]))
             {
                 //System.Diagnostics.Debug.Assert(cmb.FindVoxel(Voxels[index]));
             }
             else
             {
                 ProcNeighbour(cmb, Voxels[index], procVoxels, tolerance);
             }
         }
     }
 }
Ejemplo n.º 3
0
 public BoxVolume(CombineVoxel cmb)
 {
     Combine = cmb;
 }