void sortIntoBakeGroups2(bool useFilters, Dictionary <Shader, List <_GameObjectAndWarning> > shader2GameObjects, Dictionary <_GameObjectAndWarning, List <_GameObjectAndWarning> > gs2bakeGroupMap, List <_GameObjectAndWarning> objsNotAddedToBaker) { foreach (Shader m in shader2GameObjects.Keys) { List <_GameObjectAndWarning> gos = shader2GameObjects[m]; gos.Sort(); List <_GameObjectAndWarning> l = null; _GameObjectAndWarning key = gos[0]; for (int i = 0; i < gos.Count; i++) { //exclude objects that should not be included bool includeThisGameObject = true; if (useFilters && generate_IncludeStaticObjects && !gos[i].isStatic) { includeThisGameObject = false; } if (useFilters && gos[i].submeshesOverlap) { includeThisGameObject = false; } if (useFilters && gos[i].numMaterials > 1) { includeThisGameObject = false; } if (!includeThisGameObject) { objsNotAddedToBaker.Add(gos[i]); continue; } //compare with key and decide if we need a new list if (key.lightmapIndex != gos[i].lightmapIndex) { l = null; } if (gos[i].outOfBoundsUVs && !MaterialsAreTheSame(key, gos[i])) { l = null; } if (key.outOfBoundsUVs && !MaterialsAreTheSame(key, gos[i])) { l = null; } if (l == null) { l = new List <_GameObjectAndWarning>(); gs2bakeGroupMap.Add(gos[i], l); key = gos[i]; } l.Add(gos[i]); } } }
bool ShadersAreTheSame(_GameObjectAndWarning a, _GameObjectAndWarning b) { HashSet <Shader> aMats = new HashSet <Shader>(); for (int i = 0; i < a.shaders.Length; i++) { aMats.Add(a.shaders[i]); } HashSet <Shader> bMats = new HashSet <Shader>(); for (int i = 0; i < b.shaders.Length; i++) { bMats.Add(b.shaders[i]); } return(aMats.SetEquals(bMats)); }
bool MaterialsAreTheSame(_GameObjectAndWarning a, _GameObjectAndWarning b) { HashSet <Material> aMats = new HashSet <Material>(); for (int i = 0; i < a.materials.Length; i++) { aMats.Add(a.materials[i]); } HashSet <Material> bMats = new HashSet <Material>(); for (int i = 0; i < b.materials.Length; i++) { bMats.Add(b.materials[i]); } return(aMats.SetEquals(bMats)); }
public int CompareTo(System.Object obj) { if (obj is _GameObjectAndWarning) { _GameObjectAndWarning gobj = (_GameObjectAndWarning)obj; //compare lightmap settings int lightmapCompare = gobj.lightmapIndex - lightmapIndex; if (lightmapCompare != 0) { return(lightmapCompare); } //compare shaders int shaderCompare = (shader == null ? "null" : shader.ToString()).CompareTo(gobj.shader == null ? "null" : gobj.shader.ToString()); if (shaderCompare != 0) { return(shaderCompare); } //compare materials int materialCompare = (material == null ? "null" : material.ToString()).CompareTo(gobj.material.ToString()); if (materialCompare != 0) { return(materialCompare); } // //compare shaders // int shaderCompare = shader.ToString().CompareTo(gobj.shader.ToString()); // if (shaderCompare != 0){ // return shaderCompare; // } // // //compare materials // int materialCompare = material.ToString().CompareTo(gobj.material.ToString()); // if (materialCompare != 0){ // return materialCompare; // } //obUV compaer int obUVCompare = Convert.ToInt32(gobj.outOfBoundsUVs) - Convert.ToInt32(outOfBoundsUVs); return(obUVCompare); } return(0); }
void sortIntoBakeGroups(bool useFilters, Dictionary <Shader, List <_GameObjectAndWarning> > shader2GameObjects, Dictionary <_GameObjectAndWarning, List <_GameObjectAndWarning> > gs2bakeGroupMap, List <_GameObjectAndWarning> objsNotAddedToBaker) { foreach (Shader m in shader2GameObjects.Keys) { List <_GameObjectAndWarning> gos = shader2GameObjects[m]; gos.Sort(); for (int i = 0; i < gos.Count; i++) { //exclude objects that should not be included bool includeThisGameObject = true; if (useFilters && generate_IncludeStaticObjects && !gos[i].isStatic) { includeThisGameObject = false; } if (useFilters && gos[i].submeshesOverlap) { includeThisGameObject = false; } if (useFilters && gos[i].numMaterials > 1) { includeThisGameObject = false; } if (!includeThisGameObject) { objsNotAddedToBaker.Add(gos[i]); continue; } //try to find a group that this game object belongs to _GameObjectAndWarning key = null; foreach (_GameObjectAndWarning consider in gs2bakeGroupMap.Keys) { if (generate_LightmapOption == LightMapOption.preserveLightmapping && consider.lightmapIndex != gos[i].lightmapIndex) { continue; } if (gos[i].submeshesOverlap) { continue; } if (gos[i].outOfBoundsUVs == true) { if (consider.outOfBoundsUVs == true && MaterialsAreTheSame(consider, gos[i])) { //materials needs to be the same key = consider; break; } } else { //shader needs to be the same if (ShadersAreTheSame(consider, gos[i])) { key = consider; break; } } } List <_GameObjectAndWarning> l = null; if (key == null) { l = new List <_GameObjectAndWarning>(); gs2bakeGroupMap.Add(gos[i], l); } else { l = gs2bakeGroupMap[key]; } l.Add(gos[i]); } } }
void sortIntoBakeGroups2(bool useFilters, Dictionary <Shader, List <_GameObjectAndWarning> > shader2GameObjects, Dictionary <_GameObjectAndWarning, List <_GameObjectAndWarning> > gs2bakeGroupMap, List <_GameObjectAndWarning> objsNotAddedToBaker) { foreach (Shader m in shader2GameObjects.Keys) { List <_GameObjectAndWarning> gos = shader2GameObjects[m]; gos.Sort(); List <_GameObjectAndWarning> l = null; _GameObjectAndWarning key = gos[0]; for (int i = 0; i < gos.Count; i++) { //exclude objects that should not be included bool includeThisGameObject = true; if (useFilters && generate_IncludeStaticObjects && !gos[i].isStatic) { includeThisGameObject = false; } if (useFilters && gos[i].submeshesOverlap) { includeThisGameObject = false; } if (useFilters && gos[i].numMaterials > 1) { includeThisGameObject = false; } if (!includeThisGameObject) { objsNotAddedToBaker.Add(gos[i]); continue; } //compare with key and decide if we need a new list if (key.lightmapIndex != gos[i].lightmapIndex) { l = null; } if (gos[i].outOfBoundsUVs && !MaterialsAreTheSame(key, gos[i])) { l = null; } if (key.outOfBoundsUVs && !MaterialsAreTheSame(key, gos[i])) { l = null; } /* * _GameObjectAndWarning key = null; * foreach(_GameObjectAndWarning consider in gs2bakeGroupMap.Keys){ * if (generate_LightmapOption == LightMapOption.preserveLightmapping && * consider.lightmapIndex != gos[i].lightmapIndex) continue; * if (gos[i].submeshesOverlap) continue; * * if (gos[i].outOfBoundsUVs == true){ * if (consider.outOfBoundsUVs == true && MaterialsAreTheSame(consider, gos[i])){ * //materials needs to be the same * key = consider; * break; * } * } else { * //shader needs to be the same * if (ShadersAreTheSame(consider, gos[i])){ * key = consider; * break; * } * } * } */ if (l == null) { l = new List <_GameObjectAndWarning>(); gs2bakeGroupMap.Add(gos[i], l); key = gos[i]; } l.Add(gos[i]); } } }
bool ShadersAreTheSame(_GameObjectAndWarning a, _GameObjectAndWarning b){ HashSet<Shader> aMats = new HashSet<Shader>(); for(int i = 0; i < a.shaders.Length; i++) aMats.Add(a.shaders[i]); HashSet<Shader> bMats = new HashSet<Shader>(); for(int i = 0; i < b.shaders.Length; i++) bMats.Add(b.shaders[i]); return aMats.SetEquals(bMats); }
bool MaterialsAreTheSame(_GameObjectAndWarning a, _GameObjectAndWarning b){ HashSet<Material> aMats = new HashSet<Material>(); for(int i = 0; i < a.materials.Length; i++) aMats.Add(a.materials[i]); HashSet<Material> bMats = new HashSet<Material>(); for(int i = 0; i < b.materials.Length; i++) bMats.Add(b.materials[i]); return aMats.SetEquals(bMats); }