Пример #1
0
 // Token: 0x06003080 RID: 12416 RVA: 0x000CE040 File Offset: 0x000CC240
 public void CombineMeshes(MeshCombiner meshCombiner, int lodParentIndex)
 {
     if (this.level != this.maxLevels)
     {
         for (int i = 0; i < 8; i++)
         {
             if (this.cellsUsed[i])
             {
                 this.cells[i].CombineMeshes(meshCombiner, lodParentIndex);
             }
         }
         return;
     }
     ObjectOctree.LODParent lodparent = ((ObjectOctree.MaxCell) this).lodParents[lodParentIndex];
     if (lodparent == null)
     {
         return;
     }
     lodparent.cellGO         = new GameObject(meshCombiner.useCells ? ("Cell " + this.bounds.center) : "Combined Objects");
     lodparent.cellT          = lodparent.cellGO.transform;
     lodparent.cellT.position = this.bounds.center;
     lodparent.cellT.parent   = meshCombiner.lodParentHolders[lodParentIndex].t;
     if (lodParentIndex > 0)
     {
         lodparent.lodGroup = lodparent.cellGO.AddComponent <LODGroup>();
         lodparent.lodGroup.localReferencePoint = (lodparent.cellT.position = this.bounds.center);
     }
     ObjectOctree.LODLevel[] lodLevels = lodparent.lodLevels;
     for (int j = 0; j < lodLevels.Length; j++)
     {
         ObjectOctree.LODLevel lodlevel = lodparent.lodLevels[j];
         if (lodlevel == null || lodlevel.meshObjectsHoldersLookup == null)
         {
             return;
         }
         Transform transform = null;
         if (lodParentIndex > 0)
         {
             transform        = new GameObject("LOD" + j).transform;
             transform.parent = lodparent.cellT;
         }
         foreach (MeshObjectsHolder meshObjectsHolder in lodlevel.meshObjectsHoldersLookup.Values)
         {
             meshObjectsHolder.lodParent = lodparent;
             meshObjectsHolder.lodLevel  = j;
             MeshCombineJobManager.instance.AddJob(meshCombiner, meshObjectsHolder, (lodParentIndex > 0) ? transform : lodparent.cellT, this.bounds.center);
         }
     }
 }
Пример #2
0
        void SelectOrDeselect(Vector3 position, MeshRenderer mr, Material mat, bool select)
        {
            var octree = meshCombiner.octree;

            if (octree == null)
            {
                return;
            }

            ObjectOctree.MaxCell cell = octree.GetCell(position);

            if (cell == null)
            {
                return;
            }

            mr.sharedMaterial = mat;

            if (meshCombiner.activeOriginal)
            {
                return;
            }

            ObjectOctree.LODParent[] lodParents = cell.lodParents;

            for (int i = 0; i < lodParents.Length; i++)
            {
                ObjectOctree.LODParent lodParent = lodParents[i];
                if (lodParent == null)
                {
                    continue;
                }

                ObjectOctree.LODLevel[] lodLevels = lodParent.lodLevels;

                for (int j = 0; j < lodLevels.Length; j++)
                {
                    ObjectOctree.LODLevel lodLevel = lodLevels[j];

                    if (lodLevel == null)
                    {
                        continue;
                    }

                    Methods.SetMeshRenderersActive(lodLevel.newMeshRenderers, !select);
                    Methods.SetCachedGOSActive(lodLevel.cachedGOs, select);
                }
            }
        }
Пример #3
0
            // Token: 0x0600307D RID: 12413 RVA: 0x000CDCEC File Offset: 0x000CBEEC
            private void AddObjectInternal(MeshCombiner meshCombiner, CachedGameObject cachedGO, Vector3 position, int lodParentIndex, int lodLevel, bool isChangeMode)
            {
                if (this.level == this.maxLevels)
                {
                    ObjectOctree.MaxCell maxCell = (ObjectOctree.MaxCell) this;
                    if (maxCell.lodParents == null)
                    {
                        maxCell.lodParents = new ObjectOctree.LODParent[10];
                    }
                    if (maxCell.lodParents[lodParentIndex] == null)
                    {
                        maxCell.lodParents[lodParentIndex] = new ObjectOctree.LODParent(lodParentIndex + 1);
                    }
                    ObjectOctree.LODParent lodparent = maxCell.lodParents[lodParentIndex];
                    ObjectOctree.LODLevel  lodlevel  = lodparent.lodLevels[lodLevel];
                    lodlevel.cachedGOs.Add(cachedGO);
                    if (isChangeMode && this.SortObject(meshCombiner, lodlevel, cachedGO, false))
                    {
                        if (!maxCell.hasChanged)
                        {
                            maxCell.hasChanged = true;
                            if (meshCombiner.changedCells == null)
                            {
                                meshCombiner.changedCells = new List <ObjectOctree.MaxCell>();
                            }
                            meshCombiner.changedCells.Add(maxCell);
                        }
                        if (!lodparent.hasChanged)
                        {
                            lodparent.hasChanged = true;
                            maxCell.changedLodParents.Add(lodparent);
                        }
                    }
                    lodlevel.objectCount++;
                    lodlevel.vertCount += cachedGO.mesh.vertexCount;
                    return;
                }
                bool flag;
                int  num = base.AddCell <ObjectOctree.Cell, ObjectOctree.MaxCell>(ref this.cells, position, out flag);

                if (flag)
                {
                    ObjectOctree.MaxCell.maxCellCount++;
                }
                this.cells[num].AddObjectInternal(meshCombiner, cachedGO, position, lodParentIndex, lodLevel, isChangeMode);
            }