public DepositDeferredFace ( |
||
face | ||
리턴 | void |
/// <summary> /// Commits a cone and adds a vertex to the convex hull. /// </summary> private void CommitCone() { // Fill the adjacency. for (var i = 0; i < ConeFaceBuffer.Count; i++) { var face = ConeFaceBuffer[i]; var newFace = face.Face; var adjacentFace = face.Pivot; var oldFace = face.OldFace; var orderedPivotIndex = face.FaceIndex; newFace.AdjacentFaces[orderedPivotIndex] = adjacentFace.Index; adjacentFace.AdjacentFaces[face.PivotIndex] = newFace.Index; // let there be a connection. for (var j = 0; j < NumOfDimensions; j++) { if (j == orderedPivotIndex) continue; var connector = ObjectManager.GetConnector(); connector.Update(newFace, j, NumOfDimensions); ConnectFace(connector); } // the id adjacent face on the hull? If so, we can use simple method to find beyond vertices. if (adjacentFace.VerticesBeyond.Count == 0) FindBeyondVertices(newFace, oldFace.VerticesBeyond); // it is slightly more effective if the face with the lower number of beyond vertices comes first. else if (adjacentFace.VerticesBeyond.Count < oldFace.VerticesBeyond.Count) FindBeyondVertices(newFace, adjacentFace.VerticesBeyond, oldFace.VerticesBeyond); else FindBeyondVertices(newFace, oldFace.VerticesBeyond, adjacentFace.VerticesBeyond); // This face will definitely lie on the hull if (newFace.VerticesBeyond.Count == 0) { ConvexFaces.Add(newFace.Index); UnprocessedFaces.Remove(newFace); ObjectManager.DepositVertexBuffer(newFace.VerticesBeyond); newFace.VerticesBeyond = EmptyBuffer; } else // Add the face to the list { UnprocessedFaces.Add(newFace); } // recycle the object. ObjectManager.DepositDeferredFace(face); } // Recycle the affected faces. for (var fIndex = 0; fIndex < AffectedFaceBuffer.Count; fIndex++) { var face = AffectedFaceBuffer[fIndex]; UnprocessedFaces.Remove(FacePool[face]); ObjectManager.DepositFace(face); } }
private void CommitCone() { for (int i = 0; i < ConeFaceBuffer.Count; i++) { DeferredFace deferredFace = ConeFaceBuffer[i]; ConvexFaceInternal face = deferredFace.Face; ConvexFaceInternal pivot = deferredFace.Pivot; ConvexFaceInternal oldFace = deferredFace.OldFace; int faceIndex = deferredFace.FaceIndex; face.AdjacentFaces[faceIndex] = pivot.Index; pivot.AdjacentFaces[deferredFace.PivotIndex] = face.Index; for (int j = 0; j < NumOfDimensions; j++) { if (j != faceIndex) { FaceConnector connector = ObjectManager.GetConnector(); connector.Update(face, j, NumOfDimensions); ConnectFace(connector); } } if (pivot.VerticesBeyond.Count == 0) { FindBeyondVertices(face, oldFace.VerticesBeyond); } else if (pivot.VerticesBeyond.Count < oldFace.VerticesBeyond.Count) { FindBeyondVertices(face, pivot.VerticesBeyond, oldFace.VerticesBeyond); } else { FindBeyondVertices(face, oldFace.VerticesBeyond, pivot.VerticesBeyond); } if (face.VerticesBeyond.Count == 0) { ConvexFaces.Add(face.Index); UnprocessedFaces.Remove(face); ObjectManager.DepositVertexBuffer(face.VerticesBeyond); face.VerticesBeyond = EmptyBuffer; } else { UnprocessedFaces.Add(face); } ObjectManager.DepositDeferredFace(deferredFace); } for (int k = 0; k < AffectedFaceBuffer.Count; k++) { int num = AffectedFaceBuffer[k]; UnprocessedFaces.Remove(FacePool[num]); ObjectManager.DepositFace(num); } }
/// <summary> /// Commits a cone and adds a vertex to the convex hull. /// </summary> void CommitCone() { // Add the current vertex. ConvexHull.Add(CurrentVertex); // Fill the adjacency. for (int i = 0; i < ConeFaceBuffer.Count; i++) { var face = ConeFaceBuffer[i]; var newFace = face.Face; var adjacentFace = face.Pivot; var oldFace = face.OldFace; var orderedPivotIndex = face.FaceIndex; newFace.AdjacentFaces[orderedPivotIndex] = adjacentFace; adjacentFace.AdjacentFaces[face.PivotIndex] = newFace; // let there be a connection. for (int j = 0; j < Dimension; j++) { if (j == orderedPivotIndex) { continue; } var connector = ObjectManager.GetConnector(); connector.Update(newFace, j, Dimension); ConnectFace(connector); } // This could slightly help... if (adjacentFace.VerticesBeyond.Count < oldFace.VerticesBeyond.Count) { FindBeyondVertices(newFace, adjacentFace.VerticesBeyond, oldFace.VerticesBeyond); } else { FindBeyondVertices(newFace, oldFace.VerticesBeyond, adjacentFace.VerticesBeyond); } // This face will definitely lie on the hull if (newFace.VerticesBeyond.Count == 0) { ConvexFaces.Add(newFace); UnprocessedFaces.Remove(newFace); ObjectManager.DepositVertexBuffer(newFace.VerticesBeyond); newFace.VerticesBeyond = EmptyBuffer; } else // Add the face to the list { UnprocessedFaces.Add(newFace); } // recycle the object. ObjectManager.DepositDeferredFace(face); } // Recycle the affected faces. for (int fIndex = 0; fIndex < AffectedFaceBuffer.Count; fIndex++) { var face = AffectedFaceBuffer[fIndex]; UnprocessedFaces.Remove(face); ObjectManager.DepositFace(face); } }