/* Copyright (C) 2017 Eric Wasylishen 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA See file, 'COPYING', for details. */ #ifndef __COMMON_MESH_HH__ #define __COMMON_MESH_HH__ #include #include #include #include using facenum_t = int; using vertnum_t = int; using meshface_t = std::vector; #define TJUNC_DIST_EPSILON 0.01 class mesh_t { public: std::vector verts; std::vector faces; // this is redundant data with the verts, but we know the planes in advance // and this saves having to estimate them from the verts std::vector faceplanes; }; // Welds vertices at exactly the same position mesh_t buildMesh(const std::vector> &faces); mesh_t buildMeshFromBSP(const bsp2_t *bsp); std::vector> meshToFaces(const mesh_t &mesh); aabb3f mesh_face_bbox(const mesh_t &mesh, facenum_t facenum); // Preserves the number and order of faces. // doesn't merge verts. // adds verts to fix t-juncs void cleanupMesh(mesh_t &mesh); #endif /* __COMMON_MESH_HH__ */