Ejemplo n.º 1
0
void CMesh::TVertex::AddTriangle(TTriangle *pTri) 
{ 
  if (!m_pTriangles) 
    m_pTriangles = new CTriangleArray();  
  ASSERT(GetTriangleIndex(pTri) < 0);
  m_pTriangles->Append(pTri); 
}
Ejemplo n.º 2
0
void CMesh::TVertex::RemoveTriangle(TTriangle *pTri)
{
  int iInd = GetTriangleIndex(pTri);
  ASSERT(iInd >= 0);
  m_pTriangles->At(iInd) = m_pTriangles->At(m_pTriangles->m_iCount - 1);
  m_pTriangles->SetCount(m_pTriangles->m_iCount - 1);
}
Ejemplo n.º 3
0
void EEViewPort::OnMouseLeftDown(wxMouseEvent& event)
{
	SetFocus();

	Vector2 clickPos = Vector2::Create(event.GetX(), event.GetY());
	if(event.AltDown())
	{
		m_bLookingStarted = true;
	}
	else
	{
		ExplosionEditor* pEditor = static_cast<ExplosionEditor*>(wxTheApp->GetTopWindow());
		if(m_SelectedTriangleIndex < 0)
		{
			pEditor->SetSelection(-1, -1);			
		}
		else
		{
			MeshEntity* pMesh = pEditor->GetCurrentMesh();
			ExplosionVisitor* pExplosionVisitor = pMesh->GetComponent<ExplosionVisitor>();
			Array<ExplosionVisitor::ChunkGroup>& aChunkGroups = pExplosionVisitor->GetChunkGroups();
			int selectedChunk = pEditor->GetSelectedChunk();
			int selectedSubMesh = pEditor->GetSelectedSubMesh();

			if(selectedChunk >= 0
			&& selectedSubMesh == m_SelectedSubMeshIndex
			&& event.ControlDown())
			{
				// find out if the selected triangle is part of the selected chunk				
				int triangleIndexInChunk = GetTriangleIndex(aChunkGroups[selectedSubMesh].m_aChunks[selectedChunk], m_SelectedTriangleIndex);

				// flip the selected triangle status
				if(triangleIndexInChunk >= 0)
				{
					aChunkGroups[selectedSubMesh].m_aChunks[selectedChunk].aTriangleIndices.Delete(triangleIndexInChunk);
				}
				else
				{
					aChunkGroups[selectedSubMesh].m_aChunks[selectedChunk].aTriangleIndices.Add(snew uint(m_SelectedTriangleIndex));

					// make sure the triangle is removed from every other chunk
					for(uint i=0; i<aChunkGroups[selectedSubMesh].m_aChunks.GetSize(); ++i)
					{
						if(i != selectedChunk)
						{
							int triangleIndexInChunk = GetTriangleIndex(aChunkGroups[selectedSubMesh].m_aChunks[i], m_SelectedTriangleIndex);
							if(triangleIndexInChunk >= 0)
							{
								aChunkGroups[selectedSubMesh].m_aChunks[i].aTriangleIndices.Delete(triangleIndexInChunk);
							}
						}
					}
				}
				
				pEditor->OnChunksChanged();
			}
			else
			{
				int chunkIndex = GetChunkIndex(aChunkGroups[m_SelectedSubMeshIndex].m_aChunks, m_SelectedTriangleIndex);
				if(chunkIndex >= 0)
				{
					pEditor->SetSelection(chunkIndex, m_SelectedSubMeshIndex);					
				}
			}
		}
	}
}