Пример #1
0
//-----------------------------------------------------------------------------
// Purpose: Determines whether a solid is good or bad.
// Input  : pSolid - Solid to check.
//			pList - List box into which to place errors.
// Output : Always returns TRUE to continue enumerating.
//-----------------------------------------------------------------------------
static BOOL _CheckSolidIntegrity(CMapSolid *pSolid, CListBox *pList)
{
	CCheckFaceInfo cfi;
	int nFaces = pSolid->GetFaceCount();
	for (int i = 0; i < nFaces; i++)
	{
		CMapFace *pFace = pSolid->GetFace(i);

		//
		// Reset the iPoint member so results from previous faces don't carry over.
		//
		cfi.iPoint = -1;

		//
		// Check the face.
		//
		if (!pFace->CheckFace(&cfi))
		{
			AddError(pList, ErrorSolidStructure, 0, pSolid);
			break;
		}
	}

	return(TRUE);
}
Пример #2
0
//-----------------------------------------------------------------------------
// Purpose: Repairs an invalid solid.
// Input  : pError - Contains information about the error.
//-----------------------------------------------------------------------------
static void FixSolidStructure(MapError *pError)
{
	CMapSolid *pSolid = (CMapSolid *)pError->pObjects[0];

	//
	// First make sure all the faces are good.
	//
	int nFaces = pSolid->GetFaceCount();
	for (int i = nFaces - 1; i >= 0; i--)
	{
		CMapFace *pFace = pSolid->GetFace(i);
		if (!pFace->CheckFace(NULL))
		{
			pFace->Fix();
		}
		//
		// If the face has no points, just remove it from the solid.
		//
		if (pFace->GetPointCount() == 0)
		{
			pSolid->DeleteFace(i);
		}
	}

	//
	// Rebuild the solid from the planes.
	//
	pSolid->CreateFromPlanes();
	pSolid->PostUpdate(Notify_Changed);
}