#pragma region License /****************************************************************************** This file is part of the PolyVox library Copyright (C) 2006 David Williams This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ******************************************************************************/ #pragma endregion #include "PolyVoxCore/IndexedSurfacePatch.h" using namespace std; namespace PolyVox { IndexedSurfacePatch::IndexedSurfacePatch() { } IndexedSurfacePatch::~IndexedSurfacePatch() { } const std::vector& IndexedSurfacePatch::getIndices(void) const { return m_vecTriangleIndices; } uint32 IndexedSurfacePatch::getNoOfIndices(void) const { return m_vecTriangleIndices.size(); } uint32 IndexedSurfacePatch::getNoOfNonUniformTrianges(void) const { uint32 result = 0; for(uint32 i = 0; i < m_vecTriangleIndices.size() - 2; i += 3) { if((m_vecVertices[m_vecTriangleIndices[i]].getMaterial() == m_vecVertices[m_vecTriangleIndices[i+1]].getMaterial()) && (m_vecVertices[m_vecTriangleIndices[i]].getMaterial() == m_vecVertices[m_vecTriangleIndices[i+2]].getMaterial())) { } else { result++; } } return result; } uint32 IndexedSurfacePatch::getNoOfUniformTrianges(void) const { uint32 result = 0; for(uint32 i = 0; i < m_vecTriangleIndices.size() - 2; i += 3) { if((m_vecVertices[m_vecTriangleIndices[i]].getMaterial() == m_vecVertices[m_vecTriangleIndices[i+1]].getMaterial()) && (m_vecVertices[m_vecTriangleIndices[i]].getMaterial() == m_vecVertices[m_vecTriangleIndices[i+2]].getMaterial())) { result++; } } return result; } uint32 IndexedSurfacePatch::getNoOfVertices(void) const { return m_vecVertices.size(); } std::vector& IndexedSurfacePatch::getRawVertexData(void) { return m_vecVertices; } const std::vector& IndexedSurfacePatch::getVertices(void) const { return m_vecVertices; } void IndexedSurfacePatch::addTriangle(uint32 index0, uint32 index1, uint32 index2) { m_vecTriangleIndices.push_back(index0); m_vecTriangleIndices.push_back(index1); m_vecTriangleIndices.push_back(index2); } uint32 IndexedSurfacePatch::addVertex(const SurfaceVertex& vertex) { m_vecVertices.push_back(vertex); return m_vecVertices.size() - 1; } void IndexedSurfacePatch::clear(void) { m_vecVertices.clear(); m_vecTriangleIndices.clear(); } const bool IndexedSurfacePatch::isEmpty(void) const { return (getNoOfVertices() == 0) || (getNoOfIndices() == 0); } }