HQPolygonList::~HQPolygonList() { ClearPolyList(); }
void HQBSPTreeNode::Clear() { SafeDelete(frontNode); SafeDelete(backNode); ClearPolyList(); }
BOOL CRVTrackerTextureWrap::OnEnd() { // If we're getting OnEnd because the dialog got displayed, skip out if (m_bShowingDialog) return TRUE; // Show the options dialog m_bShowingDialog = TRUE; CAutoTextureOptionsDlg cDlg; // Load the options from the registry cDlg.LoadOptionsFromReg(); //if the skip tracker is active, just avoid the dialog int nModalResult; if(m_pSkipTracker && m_pSkipTracker->GetActive()) nModalResult = IDOK; else nModalResult = cDlg.DoModal(); m_bShowingDialog = FALSE; // Get the wrapping direction CVector vWrapDir = m_pView->DrawingBrush().m_Points[1] - m_pView->DrawingBrush().m_Points[0]; // Clear the drawing brush (so it doesn't hang around if they cancel) m_pView->DrawingBrush().Term(); // Jump out if they cancelled if (nModalResult != IDOK) return TRUE; // Get the style.. m_nWrapStyle = cDlg.m_nStyle; if (m_nWrapStyle >= k_WrapInvalid) return TRUE; // Save the options to the registry cDlg.SaveOptionsToReg(); // Get the options m_bScaleToFit = cDlg.m_bScale; m_bAdjustOffset = cDlg.m_bOffset; m_bRestrictWalkDir = cDlg.m_bRestrictDir; // This might take a while... m_pView->BeginWaitCursor(); // Select the brushes with selected faces in geometry mode so this can be undone if (m_pView->GetEditMode() == GEOMETRY_EDITMODE) { CPolyRefArray &rTaggedPolies = m_pView->TaggedPolies(); for (uint32 nFindBaseLoop = 0; nFindBaseLoop < rTaggedPolies.GetSize(); ++nFindBaseLoop) { if (!rTaggedPolies[nFindBaseLoop].IsValid()) continue; m_pView->GetRegion()->SelectNode(rTaggedPolies[nFindBaseLoop]()->m_pBrush->AsNode()); } m_pView->GetRegionDoc()->NotifySelectionChange(); } // They'll probably want to be able to undo this... m_pView->GetRegionDoc()->SetupUndoForSelections(); // If we didn't move, try and figure out a wrap direction if (vWrapDir.MagSqr() <= 0.01f) { // Try going to the right vWrapDir = m_pView->Nav().Right(); // Make sure we're actually still on the poly... CEditPlane *pPlane = &(m_rBasePoly()->m_Plane); vWrapDir -= pPlane->m_Normal * vWrapDir.Dot(pPlane->m_Normal); // If that doesn't work.. if (vWrapDir.MagSqr() <= 0.01f) { // Try going forward vWrapDir = m_pView->Nav().Forward(); vWrapDir -= pPlane->m_Normal * vWrapDir.Dot(pPlane->m_Normal); } } vWrapDir.Norm(); // Build the polygon set CTWPolyList aPolyList; BuildPolyList(aPolyList); // Find our base poly uint32 nBasePolyIndex = FindPolyIndex(aPolyList, m_rBasePoly()); // Wrap the textures, starting at the base poly index CTextExtents cExtents; WrapTexture(aPolyList[nBasePolyIndex], vWrapDir, cExtents); // Scale the textures to an even multiple if (m_bScaleToFit) ScaleToMultiple(aPolyList, cExtents); // Offset the textures to fit at the top/left if (m_bAdjustOffset) AlignToTopLeft(aPolyList, cExtents); // Clear the polygon set ClearPolyList(aPolyList); // Redraw the views POSITION pos = m_pView->GetDocument()->GetFirstViewPosition(); while (pos) { CView *pView = m_pView->GetDocument()->GetNextView(pos); pView->Invalidate(FALSE); } // This might take a while... m_pView->EndWaitCursor(); return TRUE; }