/// <summary> /// Check if a vertex can be merged with another vertex. /// /// This is *not* Equals(). We want default Equals()/GetHashCode() behaviour /// to keep EditVertex instances distinct in dictionaries and hash sets. /// </summary> /// <param name="other"></param> /// <returns></returns> public bool CanBeMergedWith(EditVertex other) { return((Position - other.Position).LengthSquared() < MergeVectorEpsilon && AreNullableVectorsApproxEqual(Normal, other.Normal) && AreNullableVectorsApproxEqual(Tangent, other.Tangent) && AreNullableVectorsApproxEqual(Bitangent, other.Bitangent) && TexCoord.Zip(other.TexCoord, AreNullableVectorsApproxEqual).All(_ => _) && Color.Zip(other.Color, AreNullableColorsApproxEqual).All(_ => _)); }
/// <summary> /// Construct an EditMesh from a given Mesh. Call this only if you hold the monitor on /// the mesh or can otherwise ensure mutual exclusion /// /// The EditMesh is independent and retains no reference to the original /// data, use ApplyToMesh() to propagate changes back. /// </summary> /// <param name="mesh"></param> public EditMesh(Mesh mesh) { Faces = new List <EditFace>(mesh.FaceCount); Vertices = new List <EditVertex>(mesh.FaceCount * 3); for (int i = 0; i < mesh.FaceCount; ++i) { var srcFace = mesh.Faces[i]; var destFace = new EditFace(); for (int j = 0; j < srcFace.IndexCount; ++j) { var vert = new EditVertex(mesh, srcFace.Indices[j]); Vertices.Add(vert); destFace.AddVertex(vert); } Faces.Add(destFace); } ComputeAdjacentVertices(); }
public void AddVertex(EditVertex vertex) { Vertices.Add(vertex); vertex.Face = this; }
public bool IsApproximatelySamePosition(EditVertex other) { return((Position - other.Position).LengthSquared() < MergeVectorEpsilon); }
/// <summary> /// Check if a vertex can be merged with another vertex. /// /// This is *not* Equals(). We want default Equals()/GetHashCode() behaviour /// to keep EditVertex instances distinct in dictionaries and hash sets. /// </summary> /// <param name="other"></param> /// <returns></returns> public bool CanBeMergedWith(EditVertex other) { return (Position - other.Position).LengthSquared() < MergeVectorEpsilon && AreNullableVectorsApproxEqual(Normal, other.Normal) && AreNullableVectorsApproxEqual(Tangent, other.Tangent) && AreNullableVectorsApproxEqual(Bitangent, other.Bitangent) && TexCoord.Zip(other.TexCoord, AreNullableVectorsApproxEqual).All(_ => _) && Color.Zip(other.Color, AreNullableColorsApproxEqual).All(_ => _); }
/// <summary> /// Construct an EditMesh from a given Mesh. Call this only if you hold the monitor on /// the mesh or can otherwise ensure mutual exclusion /// /// The EditMesh is independent and retains no reference to the original /// data, use ApplyToMesh() to propagate changes back. /// </summary> /// <param name="mesh"></param> public EditMesh(Mesh mesh) { Faces = new List<EditFace>(mesh.FaceCount); Vertices = new List<EditVertex>(mesh.FaceCount * 3); for (int i = 0; i < mesh.FaceCount; ++i) { var srcFace = mesh.Faces[i]; var destFace = new EditFace(); for (int j = 0; j < srcFace.IndexCount; ++j) { var vert = new EditVertex(mesh, srcFace.Indices[j]); Vertices.Add(vert); destFace.AddVertex(vert); } Faces.Add(destFace); } ComputeAdjacentVertices(); }
public bool IsApproximatelySamePosition(EditVertex other) { return (Position - other.Position).LengthSquared() < MergeVectorEpsilon; }