MeshEditRestore::MeshEditRestore (EditMeshData* md, EditMeshMod *mod, MeshDelta & changer) { meshData = md; this->mod = mod; mapChanges.SetCount (NUM_HIDDENMAPS + changer.GetMapNum()); changeFlags = changer.ChangeFlags (&mapChanges); updateMD = md->updateMD; if (updateMD) changeFlags = MDELTA_ALL; omdelta.CopyMDChannels (meshData->mdelta, changeFlags, &mapChanges); }
////////////////////////////////// MESH WELDER //////////////////// static void WeldMesh(Mesh *mesh, float thresh) { if (thresh == 0.0f) thresh = (float)1e-30; // find only the coincident ones BitArray vset, eset; BitArray vset; vset.SetSize(mesh->numVerts); vset.SetAll(); MeshDelta md; md.WeldByThreshold(*mesh, vset, thresh); md.Apply(*mesh); }
void EChamferMod::ModifyTriObject (TimeValue t, ModContext &mc, TriObject *tobj) { Mesh &mesh = tobj->GetMesh(); Interval iv = FOREVER; float amount; int i, j; m_pblock->GetValue (kEchAmount, t, amount, iv); // Convert existing selection (at whatever level) to edge selection: BitArray targetEdges; targetEdges.SetSize (mesh.numFaces*3); targetEdges.ClearAll (); switch (mesh.selLevel) { case MESH_OBJECT: targetEdges.SetAll (); break; case MESH_VERTEX: for (i=0; i<mesh.numFaces; i++) { for (j=0; j<3; j++) { if (!mesh.vertSel[mesh.faces[i].v[j]]) continue; // Don't select invisible edges: if (mesh.faces[i].getEdgeVis(j)) targetEdges.Set (i*3+j); if (mesh.faces[i].getEdgeVis((j+2)%3)) targetEdges.Set (i*3+(j+2)%3); } } break; case MESH_EDGE: targetEdges = mesh.edgeSel; break; case MESH_FACE: for (i=0; i<mesh.numFaces; i++) { if (!mesh.faceSel[i]) continue; for (j=0; j<3; j++) { // Don't select invisible edges: if (mesh.faces[i].getEdgeVis(j)) targetEdges.Set (i*3+j); } } break; } // Chamfer the edges -- this just does the topological operation. MeshDelta tmd; tmd.InitToMesh (mesh); MeshTempData temp; temp.SetMesh (&mesh); MeshChamferData *mcd = temp.ChamferData(); AdjEdgeList *ae = temp.AdjEList(); tmd.ChamferEdges (mesh, targetEdges, *mcd, ae); tmd.Apply (mesh); // Reset the meshdelta, temp data to deal with the post-chamfered topology: tmd.InitToMesh (mesh); temp.Invalidate (TOPO_CHANNEL); // Generates a new edge list, but preserves chamfer data temp.SetMesh (&mesh); tmd.ChamferMove (mesh, *temp.ChamferData(), amount, temp.AdjEList()); tmd.Apply (mesh); tobj->UpdateValidity(GEOM_CHAN_NUM,iv); }
void SymmetryMod::SliceTriObject (Mesh & mesh, Point3 & N, float offset) { // Steve Anderson 9/14/2002 // Using the new "MESH_TEMP_1" flag to override Slice selection behavior, // which is undesirable here. mesh.SetFlag (MESH_TEMP_1); MeshDelta slicemd; slicemd.Slice (mesh, N, offset, false, true); slicemd.Apply (mesh); mesh.ClearFlag (MESH_TEMP_1); // We need to strip out faces on the mirror plane itself. // (These aren't always removed by slice.) // Mark vertices at the plane boundary: BitArray targetVerts; targetVerts.SetSize (mesh.numVerts); targetVerts.ClearAll (); for (int i=0; i<mesh.numVerts; i++) { float dist = DotProd (N, mesh.verts[i]) - offset; if (fabsf(dist) > MNEPS) continue; targetVerts.Set (i); } BitArray delFaces, delVerts; delFaces.SetSize (mesh.numFaces); for (int i=0; i<mesh.numFaces; i++) { int j; for (j=0; j<3; j++) { if (!targetVerts[mesh.faces[i].v[j]]) break; } if (j<3) continue; // Face needs to be deleted. delFaces.Set (i); } mesh.DeleteFaceSet (delFaces, &delVerts); mesh.DeleteVertSet (delVerts); }
void bhkRigidBodyModifier::BuildColStrips(Mesh& mesh) { MeshDelta tmd (mesh); tmd.Apply(mesh); }