Planeshift

ChunkyTriMesh.h

Go to the documentation of this file.
00001 //
00002 // Copyright (c) 2009-2010 Mikko Mononen [email protected]
00003 //
00004 // This software is provided 'as-is', without any express or implied
00005 // warranty.  In no event will the authors be held liable for any damages
00006 // arising from the use of this software.
00007 // Permission is granted to anyone to use this software for any purpose,
00008 // including commercial applications, and to alter it and redistribute it
00009 // freely, subject to the following restrictions:
00010 // 1. The origin of this software must not be misrepresented; you must not
00011 //    claim that you wrote the original software. If you use this software
00012 //    in a product, an acknowledgment in the product documentation would be
00013 //    appreciated but is not required.
00014 // 2. Altered source versions must be plainly marked as such, and must not be
00015 //    misrepresented as being the original software.
00016 // 3. This notice may not be removed or altered from any source distribution.
00017 //
00018 
00019 #ifndef CHUNKYTRIMESH_H
00020 #define CHUNKYTRIMESH_H
00021 
00022 struct rcChunkyTriMeshNode
00023 {
00024         float bmin[2], bmax[2];
00025         int i, n;
00026 };
00027 
00028 struct rcChunkyTriMesh
00029 {
00030         inline rcChunkyTriMesh() : nodes(0), tris(0) {};
00031         inline ~rcChunkyTriMesh() { delete [] nodes; delete [] tris; }
00032 
00033         rcChunkyTriMeshNode* nodes;
00034         int nnodes;
00035         int* tris;
00036         int ntris;
00037         int maxTrisPerChunk;
00038 };
00039 
00042 bool rcCreateChunkyTriMesh(const float* verts, const int* tris, int ntris,
00043                                                    int trisPerChunk, rcChunkyTriMesh* cm);
00044 
00046 int rcGetChunksOverlappingRect(const rcChunkyTriMesh* cm, float bmin[2], float bmax[2], int* ids, const int maxIds);
00047 
00049 int rcGetChunksOverlappingSegment(const rcChunkyTriMesh* cm, float p[2], float q[2], int* ids, const int maxIds);
00050 
00051 
00052 #endif // CHUNKYTRIMESH_H