/// <summary> /// Builds the progressive mesh with the specified number of levels. /// </summary> public void Build(ushort numLevels, List <IndexData> lodFaceList, VertexReductionQuota quota, float reductionValue) { ComputeAllCosts(); // Init this.currNumIndexes = (uint)this.indexData.indexCount; // Use COMMON vert count, not original vert count // Since collapsing 1 common vert position is equivalent to collapsing them all var numVerts = this.numCommonVertices; uint numCollapses = 0; var abandon = false; while (numLevels-- != 0) { // NB if 'abandon' is set, we stop reducing // However, we still bake the number of LODs requested, even if it // means they are the same if (!abandon) { if (quota == VertexReductionQuota.Proportional) { numCollapses = (uint)(numVerts * reductionValue); } else { numCollapses = (uint)reductionValue; } // Minimum 3 verts! if ((numVerts - numCollapses) < 3) { numCollapses = numVerts - 3; } // Store new number of verts numVerts = numVerts - numCollapses; Debug.Assert(numVerts >= 3); while (numCollapses-- != 0 && !abandon) { var nextIndex = GetNextCollapser(); // Collapse on every buffer foreach (var data in this.workingDataList) { var collapser = data.vertList[nextIndex]; // This will reduce currNumIndexes and recalc costs as required if (collapser.collapseTo == null) { // Must have run out of valid collapsables abandon = true; break; } Debug.Assert(collapser.collapseTo.removed == false); Collapse(collapser); } } } // Bake a new LOD and add it to the list var newLod = new IndexData(); BakeNewLOD(newLod); lodFaceList.Add(newLod); } }
/// <summary> /// Builds the progressive mesh with the specified number of levels. /// </summary> public void Build(ushort numLevels, List<IndexData> lodFaceList, VertexReductionQuota quota, float reductionValue) { ComputeAllCosts(); // Init currNumIndexes = (uint)indexData.indexCount; // Use COMMON vert count, not original vert count // Since collapsing 1 common vert position is equivalent to collapsing them all uint numVerts = numCommonVertices; uint numCollapses = 0; bool abandon = false; while (numLevels-- != 0) { // NB if 'abandon' is set, we stop reducing // However, we still bake the number of LODs requested, even if it // means they are the same if (!abandon) { if (quota == VertexReductionQuota.Proportional) numCollapses = (uint)(numVerts * reductionValue); else numCollapses = (uint)reductionValue; // Minimum 3 verts! if ((numVerts - numCollapses) < 3) numCollapses = numVerts - 3; // Store new number of verts numVerts = numVerts - numCollapses; Debug.Assert(numVerts >= 3); while (numCollapses-- != 0 && !abandon) { int nextIndex = GetNextCollapser(); // Collapse on every buffer foreach (PMWorkingData data in workingDataList) { PMVertex collapser = data.vertList[nextIndex]; // This will reduce currNumIndexes and recalc costs as required if (collapser.collapseTo == null) { // Must have run out of valid collapsables abandon = true; break; } Debug.Assert(collapser.collapseTo.removed == false); Collapse(collapser); } } } // Bake a new LOD and add it to the list IndexData newLod = new IndexData(); BakeNewLOD(newLod); lodFaceList.Add(newLod); } }
public void Build(ushort numLevels, List <IndexData> lodFaceList, VertexReductionQuota quota) { Build(numLevels, lodFaceList, quota, 0.5f); }
public void Build(ushort numLevels, List<IndexData> lodFaceList, VertexReductionQuota quota) { Build(numLevels, lodFaceList, quota, 0.5f); }