/****************************************************************************** libx42make - skinned vertex animation library (exporter utilities) Copyright (C) 2007 HermitWorks Entertainment Corporation 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. ******************************************************************************/ #include "local.h" namespace x42 { namespace make { void Adjacency::Init( const std::vector< index > &tris ) { entries.resize( tris.size() / 3 ); values.clear(); values.reserve( tris.size() ); //for each triangle for( uint t = 0; t < entries.size(); t++ ) { entries[t].begin = (uint)values.size(); //skip degenerates if( tris[t * 3 + 0] == tris[t * 3 + 1] || tris[t * 3 + 1] == tris[t * 3 + 2] || tris[t * 3 + 2] == tris[t * 3 + 0] ) continue; //for each edge for( uint e = 0; e < 3; e++ ) { uint es = tris[t * 3 + e]; uint ee = tris[t * 3 + ((e + 1) % 3)]; //for each other triangle for( uint ot = 0; ot < entries.size(); ot++ ) { if( ot == t ) continue; //skip degenerates if( tris[ot * 3 + 0] == tris[ot * 3 + 1] || tris[ot * 3 + 1] == tris[ot * 3 + 2] || tris[ot * 3 + 2] == tris[ot * 3 + 0] ) continue; //for each other edge for( uint oe = 0; oe < 3; oe++ ) { uint oes = tris[ot * 3 + oe]; uint oee = tris[ot * 3 + ((oe + 1) % 3)]; if( es == oee && ee == oes ) values.push_back( ot ); } } } entries[t].length = (uint)values.size() - entries[t].begin; } } }; };