public void UpdateLods(MeshCombiner meshCombiner, int lodAmount) { if (lods != null && lods.Length == lodAmount) { return; } lods = new LOD[lodAmount]; float[] newDistances = new float[lodAmount]; for (int i = 0; i < lods.Length; i++) { lods[i] = new LOD(); if (lodDistanceMode == LodDistanceMode.Automatic) { newDistances[i] = meshCombiner.cellSize * i; } else if (distances != null && i < distances.Length) { newDistances[i] = distances[i]; } } distances = newDistances; }
public void CombineMeshes(MeshCombiner meshCombiner, int lodLevel) { if (level == maxLevels) { MaxCell thisCell = (MaxCell)this; LOD lod = thisCell.lods[lodLevel]; if (lod == null) { return; } for (int i = 0; i < lod.sortedMeshes.Count; ++i) { meshCombiner.CombineMeshes(lod.sortedMeshes[i], bounds.center); } } else { for (int i = 0; i < 8; ++i) { if (cellsUsed[i]) { cells[i].CombineMeshes(meshCombiner, lodLevel); } } } }
void Awake() { instance = this; meshCombiner = GetComponent <MeshCombiner>(); meshCombinerList.Add(meshCombiner); QualitySettings.vSyncCount = 0; }
void OnEnable() { if (thisInstance == null) { instances.Add(this); thisInstance = this; } }
// Token: 0x06003076 RID: 12406 RVA: 0x000CDC20 File Offset: 0x000CBE20 public void ApplyChanges(MeshCombiner meshCombiner) { for (int i = 0; i < this.changedMeshObjectsHolders.Count; i++) { this.changedMeshObjectsHolders.items[i].hasChanged = false; } this.changedMeshObjectsHolders.Clear(); }
public void ApplyChanges(MeshCombiner meshCombiner) { for (int i = 0; i < lodLevels.Length; i++) { lodLevels[i].ApplyChanges(meshCombiner); } hasChanged = false; }
public CachedGameObject AddObject(Vector3 position, MeshCombiner meshCombiner, CachedGameObject cachedGO, int lodParentIndex, int lodLevel, bool isChangeMode = false) { if (InsideBounds(position)) { AddObjectInternal(meshCombiner, cachedGO, position, lodParentIndex, lodLevel, isChangeMode); return(cachedGO); } return(null); }
public void ApplyChanges(MeshCombiner meshCombiner) { for (int i = 0; i < changedMeshObjectsHolders.Count; i++) { MeshObjectsHolder meshObjectHolder = changedMeshObjectsHolders.items[i]; meshObjectHolder.hasChanged = false; } changedMeshObjectsHolders.Clear(); }
public void ApplyChanges(MeshCombiner meshCombiner) { for (int i = 0; i < changedLodParents.Count; i++) { changedLodParents[i].ApplyChanges(meshCombiner); } changedLodParents.Clear(); hasChanged = false; }
void OnCombineReady(MeshCombiner meshCombiner) { foreach (var goLayer in gos) { goLayer.RestoreLayer(); } gos.Clear(); }
void AddObjectInternal(MeshCombiner meshCombiner, CachedGameObject cachedGO, Vector3 position, int lodParentIndex, int lodLevel, bool isChangeMode) { if (level == maxLevels) { MaxCell thisCell = (MaxCell)this; if (thisCell.lodParents == null) { thisCell.lodParents = new LODParent[10]; } if (thisCell.lodParents[lodParentIndex] == null) { thisCell.lodParents[lodParentIndex] = new LODParent(lodParentIndex + 1); } LODParent lodParent = thisCell.lodParents[lodParentIndex]; LODLevel lod = lodParent.lodLevels[lodLevel]; lod.cachedGOs.Add(cachedGO); if (isChangeMode) { if (SortObject(meshCombiner, lod, cachedGO)) { if (!thisCell.hasChanged) { thisCell.hasChanged = true; if (meshCombiner.changedCells == null) { meshCombiner.changedCells = new List <MaxCell>(); } meshCombiner.changedCells.Add(thisCell); } if (!lodParent.hasChanged) { lodParent.hasChanged = true; thisCell.changedLodParents.Add(lodParent); } } } lod.objectCount++; lod.vertCount += cachedGO.mesh.vertexCount; return; } else { bool maxCellCreated; int index = AddCell <Cell, MaxCell>(ref cells, position, out maxCellCreated); if (maxCellCreated) { MaxCell.maxCellCount++; } cells[index].AddObjectInternal(meshCombiner, cachedGO, position, lodParentIndex, lodLevel, isChangeMode); } }
public void Draw(MeshCombiner meshCombiner, bool onlyMaxLevel, bool drawLevel0) { if (!onlyMaxLevel || level == maxLevels || (drawLevel0 && level == 0)) { Gizmos.DrawWireCube(bounds.center, bounds.size); if (level == maxLevels) { if (meshCombiner.drawMeshBounds) { MaxCell thisCell = (MaxCell)this; LODParent[] lodParents = thisCell.lodParents; for (int i = 0; i < lodParents.Length; i++) { if (lodParents[i] == null) { continue; } LODLevel[] lods = lodParents[i].lodLevels; Gizmos.color = meshCombiner.activeOriginal ? Color.blue : Color.green; for (int j = 0; j < lods.Length; j++) { for (int k = 0; k < lods[j].cachedGOs.Count; k++) { if (lods[j].cachedGOs.items[k].mr == null) { continue; } Bounds meshBounds = lods[j].cachedGOs.items[k].mr.bounds; Gizmos.DrawWireCube(meshBounds.center, meshBounds.size); } } Gizmos.color = Color.white; } return; } } } if (cells == null || cellsUsed == null) { return; } for (int i = 0; i < 8; i++) { if (cellsUsed[i]) { cells[i].Draw(meshCombiner, onlyMaxLevel, drawLevel0); } } }
public LogEntry(string logString, string stackTrace, LogType logType, bool unityLog = false, int commandType = 0, GameObject go = null, MeshCombiner meshCombiner = null) { this.logString = logString; this.stackTrace = stackTrace; this.logType = logType; this.unityLog = unityLog; this.commandType = commandType; this.go = go; this.meshCombiner = meshCombiner; // tStamp = Time.time; }
// Token: 0x060024BA RID: 9402 RVA: 0x000B4028 File Offset: 0x000B2228 public void UpdateDistances(MeshCombiner meshCombiner) { if (this.lodDistanceMode != CombinedLODManager.LodDistanceMode.Automatic) { return; } for (int i = 0; i < this.distances.Length; i++) { this.distances[i] = (float)(meshCombiner.cellSize * i); } }
// Token: 0x060024A6 RID: 9382 RVA: 0x000B3507 File Offset: 0x000B1707 public void Init(MeshCombiner meshCombiner, int lodGroupParentIndex) { this.meshCombiner = meshCombiner; this.lodGroupParentIndex = lodGroupParentIndex; this.lodCount = lodGroupParentIndex + 1; if (this.lodGroup == null) { this.lodGroup = base.gameObject.AddComponent <LODGroup>(); } this.GetSetup(); }
public void UpdateDistances(MeshCombiner meshCombiner) { if (lodDistanceMode != LodDistanceMode.Automatic) { return; } for (int i = 0; i < distances.Length; i++) { distances[i] = meshCombiner.cellSize * i; } }
// Token: 0x0600307F RID: 12415 RVA: 0x000CDF0C File Offset: 0x000CC10C public bool SortObject(MeshCombiner meshCombiner, ObjectOctree.LODLevel lod, CachedGameObject cachedGO, bool isChangeMode = false) { if (cachedGO.mr == null) { return(false); } if (lod.meshObjectsHoldersLookup == null) { lod.meshObjectsHoldersLookup = new Dictionary <CombineCondition, MeshObjectsHolder>(); } CombineConditionSettings combineConditionSettings = meshCombiner.combineConditionSettings; Material[] sharedMaterials = cachedGO.mr.sharedMaterials; int num = Mathf.Min(cachedGO.mesh.subMeshCount, sharedMaterials.Length); int i = 0; while (i < num) { Material material; if (!combineConditionSettings.sameMaterial) { material = combineConditionSettings.material; goto IL_75; } material = sharedMaterials[i]; if (!(material == null)) { goto IL_75; } IL_119: i++; continue; IL_75: CombineCondition combineCondition = default(CombineCondition); combineCondition.ReadFromGameObject(combineConditionSettings, meshCombiner.copyBakedLighting && meshCombiner.validCopyBakedLighting, cachedGO.go, cachedGO.mr, material); MeshObjectsHolder meshObjectsHolder; if (!lod.meshObjectsHoldersLookup.TryGetValue(combineCondition, out meshObjectsHolder)) { meshCombiner.foundCombineConditions.combineConditions.Add(combineCondition); meshObjectsHolder = new MeshObjectsHolder(ref combineCondition, material); lod.meshObjectsHoldersLookup.Add(combineCondition, meshObjectsHolder); } meshObjectsHolder.meshObjects.Add(new MeshObject(cachedGO, i)); if (isChangeMode && !meshObjectsHolder.hasChanged) { meshObjectsHolder.hasChanged = true; lod.changedMeshObjectsHolders.Add(meshObjectsHolder); goto IL_119; } goto IL_119; } return(true); }
public bool SortObject(MeshCombiner meshCombiner, LODLevel lod, CachedGameObject cachedGO, bool isChangeMode = false) { if (cachedGO.mr == null) { return(false); } if (lod.meshObjectsHolders == null) { lod.meshObjectsHolders = new List <MeshObjectsHolder>(); } Material[] mats = cachedGO.mr.sharedMaterials; // TODO check submeshes and material int length = Mathf.Min(cachedGO.mesh.subMeshCount, mats.Length); for (int l = 0; l < length; l++) { Material mat = mats[l]; if (mat == null) { continue; } bool shadowCastingModeTwoSided = (cachedGO.mr.shadowCastingMode == UnityEngine.Rendering.ShadowCastingMode.TwoSided); int lightmapIndex = meshCombiner.validCopyBakedLighting ? cachedGO.mr.lightmapIndex : -1; int index = lod.GetSortMeshIndex(mat, shadowCastingModeTwoSided, lightmapIndex); MeshObjectsHolder meshObjectHolder; if (index == -1) { meshObjectHolder = new MeshObjectsHolder(cachedGO, mat, l, shadowCastingModeTwoSided, lightmapIndex); lod.meshObjectsHolders.Add(meshObjectHolder); } else { meshObjectHolder = lod.meshObjectsHolders[index]; meshObjectHolder.meshObjects.Add(new MeshObject(cachedGO, l)); } if (isChangeMode && !meshObjectHolder.hasChanged) { meshObjectHolder.hasChanged = true; lod.changedMeshObjectsHolders.Add(meshObjectHolder); } } return(true); }
// Token: 0x0600251C RID: 9500 RVA: 0x000B7634 File Offset: 0x000B5834 private void ReportMeshCombiner(MeshCombiner meshCombiner, bool foundText = false) { Console.Log(string.Concat(new object[] { foundText ? "Found MCS -> " : "", meshCombiner.name, " (", meshCombiner.combined ? "*color-green#Combined" : "*color-blue#Uncombined", ") -> Cell Size ", meshCombiner.cellSize, meshCombiner.searchOptions.useMaxBoundsFactor ? (" | Max Bounds Factor " + meshCombiner.searchOptions.maxBoundsFactor) : "", meshCombiner.searchOptions.useVertexInputLimit ? (" | Vertex Input Limit " + (meshCombiner.searchOptions.useVertexInputLimit ? meshCombiner.searchOptions.vertexInputLimit : 65534)) : "" }), 0, null, meshCombiner); }
// 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); } } }
public void AssignLODGroup(MeshCombiner meshCombiner) { LOD[] lods = new LOD[lodLevels.Length]; int lodGroupParentIndex = lods.Length - 1; for (int i = 0; i < lodLevels.Length; i++) { LODLevel lodLevel = lodLevels[i]; // Debug.Log(i + " " + lodLevel.newMeshRenderers.Count); lods[i] = new LOD(meshCombiner.lodGroupsSettings[lodGroupParentIndex].lodSettings[i].screenRelativeTransitionHeight, lodLevel.newMeshRenderers.ToArray()); } lodGroup.SetLODs(lods); lodGroup.size = meshCombiner.cellSize; }
// ========================================================================================================================== void OnDestroy() { RestoreOriginalRenderersAndLODGroups(); thisInstance = null; instances.Remove(this); // if (!Application.isPlaying && Application.isEditor) return; if (instances.Count == 0 && MeshCombineJobManager.instance != null) { Methods.Destroy(MeshCombineJobManager.instance.gameObject); MeshCombineJobManager.instance = null; } }
public void SortObjects(MeshCombiner meshCombiner) { if (level == maxLevels) { MaxCell thisCell = (MaxCell)this; LODParent[] lodParents = thisCell.lodParents; for (int i = 0; i < lodParents.Length; i++) { LODParent lodParent = lodParents[i]; if (lodParent == null) { continue; } for (int j = 0; j < lodParent.lodLevels.Length; j++) { LODLevel lod = lodParent.lodLevels[j]; if (lod == null || lod.cachedGOs.Count == 0) { return; } for (int k = 0; k < lod.cachedGOs.Count; ++k) { CachedGameObject cachedGO = lod.cachedGOs.items[k]; if (!SortObject(meshCombiner, lod, cachedGO)) { lod.cachedGOs.RemoveAt(k--); } } } } } else { for (int i = 0; i < 8; ++i) { if (cellsUsed[i]) { cells[i].SortObjects(meshCombiner); } } } }
void ApplyCombinedLock() { meshCombiner = (MeshCombiner)target; if (meshCombiner.transform.childCount == 0) { meshCombiner.combined = false; } if (!meshCombiner.combined) { return; } meshCombiner.transform.position = meshCombiner.oldPosition; meshCombiner.transform.localScale = meshCombiner.oldScale; }
// 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); }
// Token: 0x06003074 RID: 12404 RVA: 0x000CDB5C File Offset: 0x000CBD5C public void AssignLODGroup(MeshCombiner meshCombiner) { LOD[] array = new LOD[this.lodLevels.Length]; int num = array.Length - 1; for (int i = 0; i < this.lodLevels.Length; i++) { ObjectOctree.LODLevel lodlevel = this.lodLevels[i]; LOD[] array2 = array; int num2 = i; float screenRelativeTransitionHeight = meshCombiner.lodGroupsSettings[num].lodSettings[i].screenRelativeTransitionHeight; Renderer[] renderers = lodlevel.newMeshRenderers.ToArray(); array2[num2] = new LOD(screenRelativeTransitionHeight, renderers); } this.lodGroup.SetLODs(array); this.lodGroup.size = (float)meshCombiner.cellSize; }
public int SelectMeshCombiner(string name) { if (meshCombiners == null && meshCombiners.Length == 0) { return(0); } for (int i = 0; i < meshCombiners.Length; i++) { MeshCombiner meshCombiner = meshCombiners[i]; if (meshCombiner.name == name) { Log("Selected MCS -> " + meshCombiner.name + " (" + (meshCombiner.combined ? "*color-green#Combined" : "*color-blue#Uncombined") + ")", 0, null, meshCombiner); selectedMeshCombiner = meshCombiner; return(2); } } return(0); }
// Token: 0x06003081 RID: 12417 RVA: 0x000CE228 File Offset: 0x000CC428 public void Draw(MeshCombiner meshCombiner, bool onlyMaxLevel, bool drawLevel0) { if (!onlyMaxLevel || this.level == this.maxLevels || (drawLevel0 && this.level == 0)) { Gizmos.DrawWireCube(this.bounds.center, this.bounds.size); if (this.level == this.maxLevels && meshCombiner.drawMeshBounds) { ObjectOctree.LODParent[] lodParents = ((ObjectOctree.MaxCell) this).lodParents; for (int i = 0; i < lodParents.Length; i++) { if (lodParents[i] != null) { ObjectOctree.LODLevel[] lodLevels = lodParents[i].lodLevels; Gizmos.color = (meshCombiner.activeOriginal ? Color.blue : Color.green); for (int j = 0; j < lodLevels.Length; j++) { for (int k = 0; k < lodLevels[j].cachedGOs.Count; k++) { if (!(lodLevels[j].cachedGOs.items[k].mr == null)) { Bounds bounds = lodLevels[j].cachedGOs.items[k].mr.bounds; Gizmos.DrawWireCube(bounds.center, bounds.size); } } } Gizmos.color = Color.white; } } return; } } if (this.cells == null || this.cellsUsed == null) { return; } for (int l = 0; l < 8; l++) { if (this.cellsUsed[l]) { this.cells[l].Draw(meshCombiner, onlyMaxLevel, drawLevel0); } } }
void Unregister() { if (!hasRegistered) { return; } hasRegistered = false; OnCombineReady(null); MeshCombiner.onInit -= Init; for (int i = 0; i < MeshCombiner.instances.Count; i++) { MeshCombiner meshCombiner = MeshCombiner.instances[i]; meshCombiner.onCombiningStart -= OnCombine; meshCombiner.onCombiningAbort -= OnCombineReady; meshCombiner.onCombiningReady -= OnCombineReady; } }
private void OnGUI() { GUI.color = Color.red; GUI.Label(new Rect(10, 10, 200, 20), "Toggle with '" + meshCombiner.combineSwapKey.ToString() + "' key."); for (int i = 0; i < meshCombinerList.Count; i++) { MeshCombiner meshCombiner = meshCombinerList[i]; if (meshCombiner.combinedActive) { GUI.Label(new Rect(10, 30 + (i * 20), 300, 20), meshCombiner.gameObject.name + " is Enabled."); } else { GUI.Label(new Rect(10, 30 + (i * 20), 300, 20), meshCombiner.gameObject.name + " is Disabled."); } } GUI.color = Color.white; }