Пример #1
0
void EditPatchMod::RecordTopologyTags() 
{
	ModContextList mcList;		
	INodeTab nodes;
	TimeValue t = ip->GetTime();
	ip->GetModContexts(mcList, nodes);
	ClearPatchDataFlag(mcList, EPD_BEENDONE);
	
	for (int i = 0; i < mcList.Count(); i++)
	{
		EditPatchData *patchData =(EditPatchData*)mcList[i]->localData;
		if (!patchData)
			continue;
		if (patchData->GetFlag(EPD_BEENDONE))
			continue;
		
		// If the mesh isn't yet cache, this will cause it to get cached.
		RPatchMesh *rpatch;
		PatchMesh *patch = patchData->TempData(this)->GetPatch(t, rpatch);
		if (!patch)
			continue;
		patch->RecordTopologyTags();
		patchData->SetFlag(EPD_BEENDONE, TRUE);
	}
	
	nodes.DisposeTemporary();
	ClearPatchDataFlag(mcList, EPD_BEENDONE);
}
Пример #2
0
void EditPatchMod::ChangeSelVerts(int type) 
{
	ModContextList mcList;		
	INodeTab nodes;
	TimeValue t = ip->GetTime();
	BOOL holdNeeded = FALSE;
	BOOL hadSelected = FALSE;
	
	if (!ip)
		return;
	
	ip->GetModContexts(mcList, nodes);
	ClearPatchDataFlag(mcList, EPD_BEENDONE);
	
	theHold.Begin();
	for (int i = 0; i < mcList.Count(); i++)
	{
		BOOL altered = FALSE;
		EditPatchData *patchData =(EditPatchData*)mcList[i]->localData;
		if (!patchData)
			continue;
		if (patchData->GetFlag(EPD_BEENDONE))
			continue;
		
		// If the mesh isn't yet cache, this will cause it to get cached.
		RPatchMesh *rpatch;
		PatchMesh *patch = patchData->TempData(this)->GetPatch(t, rpatch);
		if (!patch)
			continue;
		
		// If this is the first edit, then the delta arrays will be allocated
		patchData->BeginEdit(t);
		
		// If any bits are set in the selection set, let's DO IT!!
		if (patch->vertSel.NumberSet())
		{
			altered = holdNeeded = TRUE;
			if (theHold.Holding())
				theHold.Put(new PatchRestore(patchData, this, patch, rpatch, "ChangeSelVerts"));
			// Call the vertex type change function
			patch->ChangeVertType(-1, type);
			patchData->UpdateChanges(patch, rpatch, FALSE);
			patchData->TempData(this)->Invalidate(PART_TOPO);
		}
		patchData->SetFlag(EPD_BEENDONE, TRUE);
	}
	
	if (holdNeeded)
		theHold.Accept(GetString(IDS_TH_VERTCHANGE));
	else 
	{
		ip->DisplayTempPrompt(GetString(IDS_TH_NOVERTSSEL), PROMPT_TIME);
		theHold.End();
	}
	
	nodes.DisposeTemporary();
	ClearPatchDataFlag(mcList, EPD_BEENDONE);
	NotifyDependents(FOREVER, PART_TOPO, REFMSG_CHANGE);
	ip->RedrawViews(ip->GetTime(), REDRAW_NORMAL);
}
Пример #3
0
void EditPatchMod::DoVertReset ()
{
	ModContextList mcList;		
	INodeTab nodes;
	TimeValue t = ip->GetTime();
	int holdNeeded = 0;
	BOOL hadSel = FALSE;

	if (!ip)
		return;

	ip->GetModContexts(mcList, nodes);
	ClearPatchDataFlag(mcList, EPD_BEENDONE);

	theHold.Begin();
	RecordTopologyTags();
	for (int i = 0; i < mcList.Count(); i++)
	{
		BOOL altered = FALSE;
		EditPatchData *patchData =(EditPatchData*)mcList[i]->localData;
		if (!patchData)
			continue;
		if (patchData->GetFlag(EPD_BEENDONE))
			continue;

		
		// If the mesh isn't yet cache, this will cause it to get cached.
		RPatchMesh *rpatch;
		PatchMesh *patch = patchData->TempData(this)->GetPatch(t, rpatch);
		if (!patch)
			continue;
		patchData->RecordTopologyTags(patch);
		
		// If this is the first edit, then the delta arrays will be allocated
		patchData->BeginEdit(t);

		// If any bits are set in the selection set, let's DO IT!!
		if (patch->vertSel.NumberSet() > 0)
		{
			hadSel = TRUE;
			if (theHold.Holding())
				theHold.Put(new PatchRestore(patchData, this, patch, rpatch, "DoVertReset"));
			// Call the patch weld function
			ResetVert (patch);
			patchData->UpdateChanges(patch, rpatch);
			patchData->TempData(this)->Invalidate(PART_GEOM);
			/*if (patch->Weld(weldThreshold))
			{
				rpatch->Weld (patch);
				altered = holdNeeded = TRUE;
				patchData->UpdateChanges(patch, rpatch);
				patchData->TempData(this)->Invalidate(PART_TOPO);
			}*/
		}
		patchData->SetFlag(EPD_BEENDONE, TRUE);
	}
	
	ResolveTopoChanges();
	theHold.Accept("Reset Vertex");
	/*if (holdNeeded)
	{
		ResolveTopoChanges();
		theHold.Accept(GetString(IDS_TH_VERTWELD));
	}
	else 
	{
		if (!hadSel)
			ip->DisplayTempPrompt(GetString(IDS_TH_NOVERTSSEL), PROMPT_TIME);
		else
			ip->DisplayTempPrompt(GetString(IDS_TH_NOWELDPERFORMED), PROMPT_TIME);
		theHold.End();
	}*/

	nodes.DisposeTemporary();
	ClearPatchDataFlag(mcList, EPD_BEENDONE);
	NotifyDependents(FOREVER, PART_GEOM, REFMSG_CHANGE);
	ip->RedrawViews(ip->GetTime(), REDRAW_NORMAL);
}
Пример #4
0
// Selection set, misc fixup utility function
// This depends on PatchMesh::RecordTopologyTags being called prior to the topo changes
void EditPatchMod::ResolveTopoChanges() 
{
	ModContextList mcList;		
	INodeTab nodes;
	TimeValue t = ip->GetTime();
	ip->GetModContexts(mcList, nodes);
	ClearPatchDataFlag(mcList, EPD_BEENDONE);
	
	for (int i = 0; i < mcList.Count(); i++)
	{
		EditPatchData *patchData =(EditPatchData*)mcList[i]->localData;
		if (!patchData)
			continue;
		if (patchData->GetFlag(EPD_BEENDONE))
			continue;
		
		// If the mesh isn't yet cache, this will cause it to get cached.
		RPatchMesh *rpatch;
		PatchMesh *patch = patchData->TempData(this)->GetPatch(t, rpatch);
		if (!patch)
			continue;
		// First, the vertex selections
		int set;
		for (set = 0; set < patchData->vselSet.Count(); ++set)
		{
			BitArray *oldVS = &patchData->vselSet[set];
			BitArray newVS;
			newVS.SetSize(patch->numVerts);
			for (int vert = 0; vert < patch->numVerts; ++vert)
			{
				// Get the knot's previous location, then copy that selection into the new set
				int tag = patch->verts[vert].aux1;
				if (tag >= 0)
					newVS.Set(vert, (*oldVS)[tag]);
				else
					newVS.Clear(vert);
			}
			if (theHold.Holding())
				theHold.Put(new ChangeNamedSetRestore(&patchData->vselSet, set, oldVS));
			patchData->vselSet[set] = newVS;
		}
		// Now the edge selections
		for (set = 0; set < patchData->eselSet.Count(); ++set)
		{
			BitArray *oldES = &patchData->eselSet[set];
			BitArray newES;
			newES.SetSize(patch->numEdges);
			for (int edge = 0; edge < patch->numEdges; ++edge)
			{
				// Get the knot's previous location, then copy that selection into the new set
				int tag = patch->edges[edge].aux1;
				if (tag >= 0)
					newES.Set(edge, (*oldES)[tag]);
				else
					newES.Clear(edge);
			}
			if (theHold.Holding())
				theHold.Put(new ChangeNamedSetRestore(&patchData->eselSet, set, oldES));
			patchData->eselSet[set] = newES;
		}
		// Now the patch selections
		for (set = 0; set < patchData->pselSet.Count(); ++set)
		{
			BitArray *oldPS = &patchData->pselSet[set];
			BitArray newPS;
			newPS.SetSize(patch->numPatches);
			for (int p = 0; p < patch->numPatches; ++p)
			{
				// Get the knot's previous location, then copy that selection into the new set
				int tag = patch->patches[p].aux1;
				if (tag >= 0)
					newPS.Set(p, (*oldPS)[tag]);
				else
					newPS.Clear(p);
			}
			if (theHold.Holding())
				theHold.Put(new ChangeNamedSetRestore(&patchData->pselSet, set, oldPS));
			patchData->pselSet[set] = newPS;
		}
		
		// watje 4-16-99
		patch->HookFixTopology();
		
		patchData->SetFlag(EPD_BEENDONE, TRUE);
	}
	
	nodes.DisposeTemporary();
	ClearPatchDataFlag(mcList, EPD_BEENDONE);
}
Пример #5
0
void EditPatchMod::SelectionChanged() 
{
	if (hSelectPanel)
	{
		UpdateSelectDisplay();
		InvalidateRect(hSelectPanel, NULL, FALSE);
	}
	// Now see if the selection set matches one of the named selections!
	if (ip &&(selLevel != EP_OBJECT)&&(selLevel != EP_TILE))
	{
		ModContextList mcList;		
		INodeTab nodes;
		TimeValue t = ip->GetTime();
		ip->GetModContexts(mcList, nodes);
		int sublevel = selLevel - 1;
		int dataSet;
		for (int set = 0; set < namedSel[sublevel].Count(); ++set)
		{
			ClearPatchDataFlag(mcList, EPD_BEENDONE);
			BOOL gotMatch = FALSE;
			for (int i = 0; i < mcList.Count(); i++)
			{
				EditPatchData *patchData =(EditPatchData*)mcList[i]->localData;
				if (!patchData)
					continue;
				if (patchData->GetFlag(EPD_BEENDONE))
					continue;
				RPatchMesh *rpatch;
				PatchMesh *patch = patchData->TempData(this)->GetPatch(t, rpatch);
				if (!patch)
					continue;
				// See if this patch has the named selection set
				switch (selLevel)
				{
				case EP_VERTEX: 
					for (dataSet = 0; dataSet < patchData->vselSet.Count(); ++dataSet)
					{
						if (*(patchData->vselSet.names[dataSet]) == *namedSel[sublevel][set])
						{
							if (!(*patchData->vselSet.sets[set] == patch->vertSel))
								goto next_set;
							gotMatch = TRUE;
							break;
						}
					}
					break;
				case EP_EDGE:
					for (dataSet = 0; dataSet < patchData->eselSet.Count(); ++dataSet)
					{
						if (*(patchData->eselSet.names[dataSet]) == *namedSel[sublevel][set])
						{
							if (!(*patchData->eselSet.sets[set] == patch->edgeSel))
								goto next_set;
							gotMatch = TRUE;
							break;
						}
					}
					break;
				case EP_PATCH:
					for (dataSet = 0; dataSet < patchData->pselSet.Count(); ++dataSet)
					{
						if (*(patchData->pselSet.names[dataSet]) == *namedSel[sublevel][set])
						{
							if (!(*patchData->pselSet.sets[set] == patch->patchSel))
								goto next_set;
							gotMatch = TRUE;
							break;
						}
					}
					break;
				}
				patchData->SetFlag(EPD_BEENDONE, TRUE);
			}
			// If we reach here, we might have a set that matches
			if (gotMatch)
			{
				ip->SetCurNamedSelSet(*namedSel[sublevel][set]);
				goto namedSelUpdated;
			}
next_set:;
		}
		// No set matches, clear the named selection
		ip->ClearCurNamedSelSet();
		
		
namedSelUpdated:
		nodes.DisposeTemporary();
		ClearPatchDataFlag(mcList, EPD_BEENDONE);
	}
}
Пример #6
0
void EditPatchMod::DoAddHook(PatchMesh *pMesh, int vert0, int vert1, int vert2, int seg, int config)
{
	ModContextList mcList;		
	INodeTab nodes;
	TimeValue t = ip->GetTime();
	BOOL holdNeeded = FALSE;
	BOOL hadSelected = FALSE;

	if (!ip)
		return;

	ip->GetModContexts(mcList, nodes);


	if (mcList.Count() != 1)
		return;

	ClearPatchDataFlag(mcList, EPD_BEENDONE);

	theHold.Begin();
//	RecordTopologyTags();
	for (int i = 0; i < mcList.Count(); i++)
	{
		BOOL altered = FALSE;
		EditPatchData *patchData =(EditPatchData*)mcList[i]->localData;
		if (!patchData)
			continue;
		if (patchData->GetFlag(EPD_BEENDONE))
			continue;

		// If the mesh isn't yet cache, this will cause it to get cached.
		RPatchMesh *rpatch;
		PatchMesh *patch = patchData->TempData(this)->GetPatch(t, rpatch);
		if ((!patch) ||(patch != pMesh))
			continue;		
//		patchData->RecordTopologyTags(patch);
		// If this is the first edit, then the delta arrays will be allocated
		patchData->BeginEdit(t);

		// If any bits are set in the selection set, let's DO IT!!
//		if(patch->vertSel.NumberSet()) {

		altered = holdNeeded = TRUE;
		if (theHold.Holding())
			theHold.Put(new PatchRestore(patchData, this, patch, rpatch));
			// Call the vertex type change function
		
		// ** Hulud bug hack for hooking my way  \\\\\\\\\///////////

		//patch->AddHook(vert1, seg);

		// Config 0
		switch (config)
		{
		case 0:
			rpatch->AddHook (vert1, seg, *patch);
			break;
		case 1:
			rpatch->AddHook (vert0, vert1, vert2, seg, *patch);
			break;
		default:
			nlassert (0);
		}

		// ** //////////\\\\\\\\\\

//		patch->UpdateHooks();
//			InvalidateMesh();

		patchData->UpdateChanges(patch, rpatch);
		patchData->TempData(this)->Invalidate(PART_TOPO);
//			}
		patchData->SetFlag(EPD_BEENDONE, TRUE);
		}
	
	if (holdNeeded)
	{
//		ResolveTopoChanges();
		theHold.Accept(GetString(IDS_TH_PATCHCHANGE));
		}
	else 
	{
		ip->DisplayTempPrompt(GetString(IDS_TH_NOPATCHESSEL), PROMPT_TIME);
		theHold.End();
		}

	nodes.DisposeTemporary();
	ClearPatchDataFlag(mcList, EPD_BEENDONE);
	NotifyDependents(FOREVER, PART_TOPO, REFMSG_CHANGE);
	ip->RedrawViews(ip->GetTime(), REDRAW_NORMAL);

/*	// If any bits are set in the selection set, let's DO IT!!
	if (!ip)
	return;
	theHold.Begin();
	POPatchGenRecord *rec = new POPatchGenRecord(this);
	if (theHold.Holding())
		theHold.Put(new PatchObjectRestore(this, rec));
		// Call the patch type change function

	patch.AddHook();
	patch.InvalidateGeomCache();
	InvalidateMesh();
	theHold.Accept(GetResString(IDS_TH_PATCHCHANGE));

	NotifyDependents(FOREVER, PART_TOPO, REFMSG_CHANGE);
	ip->RedrawViews(ip->GetTime(), REDRAW_NORMAL);
*/
	}
Пример #7
0
void EditPatchMod::DoPatchDelete() 
{
	ModContextList mcList;		
	INodeTab nodes;
	TimeValue t = ip->GetTime();
	int holdNeeded = 0;
	
	if (!ip)
		return;
	
	ip->GetModContexts(mcList, nodes);
	ClearPatchDataFlag(mcList, EPD_BEENDONE);
	
	theHold.Begin();
	RecordTopologyTags();
	for (int i = 0; i < mcList.Count(); i++)
	{
		int altered = 0;
		EditPatchData *patchData =(EditPatchData*)mcList[i]->localData;
		if (!patchData)
			continue;
		if (patchData->GetFlag(EPD_BEENDONE))
			continue;
		
		// If the mesh isn't yet cache, this will cause it to get cached.
		RPatchMesh *rpatch;
		PatchMesh *patch = patchData->TempData(this)->GetPatch(t, rpatch);
		if (!patch)
			continue;
		patchData->RecordTopologyTags(patch);
		
		// If this is the first edit, then the delta arrays will be allocated
		patchData->BeginEdit(t);

		// If any bits are set in the selection set, let's DO IT!!
		if (patch->patchSel.NumberSet())
		{
			altered = holdNeeded = 1;
			if (theHold.Holding())
				theHold.Put(new PatchRestore(patchData, this, patch, rpatch, "DoPatchDelete"));
			// Call the patch delete function
			DeleteSelPatches(patch, rpatch);
			patchData->UpdateChanges(patch, rpatch);
			patchData->TempData(this)->Invalidate(PART_TOPO);
		}
		patchData->SetFlag(EPD_BEENDONE, TRUE);
	}
	
	if (holdNeeded)
	{
		ResolveTopoChanges();
		theHold.Accept(GetString(IDS_TH_PATCHDELETE));
	}
	else 
	{
		ip->DisplayTempPrompt(GetString(IDS_TH_NOPATCHESSEL), PROMPT_TIME);
		theHold.End();
	}
	
	nodes.DisposeTemporary();
	ClearPatchDataFlag(mcList, EPD_BEENDONE);
	NotifyDependents(FOREVER, PART_TOPO, REFMSG_CHANGE);
	ip->RedrawViews(ip->GetTime(), REDRAW_NORMAL);
}
Пример #8
0
// Edger Delete modifier method
void EditPatchMod::DoEdgeDelete() 
{
	ModContextList mcList;		
	INodeTab nodes;
	TimeValue t = ip->GetTime();
	int holdNeeded = 0;
	
	if (!ip)
		return;
	
	ip->GetModContexts(mcList, nodes);
	ClearPatchDataFlag(mcList, EPD_BEENDONE);
	
	theHold.Begin();
	RecordTopologyTags();
	for (int i = 0; i < mcList.Count(); i++)
	{
		int altered = 0;
		EditPatchData *patchData =(EditPatchData*)mcList[i]->localData;
		if (!patchData)
			continue;
		if (patchData->GetFlag(EPD_BEENDONE))
			continue;
		
		// If the mesh isn't yet cache, this will cause it to get cached.
		RPatchMesh *rpatch;
		PatchMesh *patch = patchData->TempData(this)->GetPatch(t, rpatch);
		if (!patch)
			continue;
		patchData->RecordTopologyTags(patch);
		
		// If this is the first edit, then the delta arrays will be allocated
		patchData->BeginEdit(t);
		
		// If any bits are set in the selection set, let's DO IT!!
		if (patch->edgeSel.NumberSet())
		{
			altered = holdNeeded = 1;
			if (theHold.Holding())
				theHold.Put(new PatchRestore(patchData, this, patch, rpatch, "DoEdgeDelete"));
			int edges = patch->getNumEdges();
			int patches = patch->getNumPatches();
			int verts = patch->getNumVerts();
			
			// Tag the patches that are attached to selected edges
			BitArray delPatches(patches);
			delPatches.ClearAll();
			
			for (int i = 0; i < edges; ++i)
			{
				if (patch->edgeSel[i])
				{
#if (MAX_RELEASE < 4000)
					if (patch->edges[i].patch1 >= 0)
						delPatches.Set(patch->edges[i].patch1);
					if (patch->edges[i].patch2 >= 0)
						delPatches.Set(patch->edges[i].patch2);
#else // (MAX_RELEASE < 4000)
					if (patch->edges[i].patches[0] >= 0)
						delPatches.Set(patch->edges[i].patches[0]);
					if (patch->edges[i].patches[1] >= 0)
						delPatches.Set(patch->edges[i].patches[1]);
#endif // (MAX_RELEASE < 4000)
				}
			}
			
			BitArray delVerts(verts);
			delVerts.ClearAll();
			
			DeletePatchParts(patch, rpatch, delVerts, delPatches);
			patch->computeInteriors();
			
			patchData->UpdateChanges(patch, rpatch);
			patchData->TempData(this)->Invalidate(PART_TOPO);
		}
		patchData->SetFlag(EPD_BEENDONE, TRUE);
	}
	
	if (holdNeeded)
	{
		ResolveTopoChanges();
		theHold.Accept(GetString(IDS_TH_EDGEDELETE));
	}
	else 
	{
		ip->DisplayTempPrompt(GetString(IDS_TH_NOEDGESSEL), PROMPT_TIME);
		theHold.End();
	}
	
	nodes.DisposeTemporary();
	ClearPatchDataFlag(mcList, EPD_BEENDONE);
	NotifyDependents(FOREVER, PART_TOPO, REFMSG_CHANGE);
	ip->RedrawViews(ip->GetTime(), REDRAW_NORMAL);
}