doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PlaneSet.h
Go to the documentation of this file.
1 /*
2 ===========================================================================
3 
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
8 
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
21 
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
23 
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
25 
26 ===========================================================================
27 */
28 
29 #ifndef __PLANESET_H__
30 #define __PLANESET_H__
31 
32 /*
33 ===============================================================================
34 
35  Plane Set
36 
37 ===============================================================================
38 */
39 
40 class idPlaneSet : public idList<idPlane> {
41 public:
42 
43  void Clear( void ) { idList<idPlane>::Clear(); hash.Free(); }
44 
45  int FindPlane( const idPlane &plane, const float normalEps, const float distEps );
46 
47 private:
49 };
50 
51 ID_INLINE int idPlaneSet::FindPlane( const idPlane &plane, const float normalEps, const float distEps ) {
52  int i, border, hashKey;
53 
54  assert( distEps <= 0.125f );
55 
56  hashKey = (int)( idMath::Fabs( plane.Dist() ) * 0.125f );
57  for ( border = -1; border <= 1; border++ ) {
58  for ( i = hash.First( hashKey + border ); i >= 0; i = hash.Next( i ) ) {
59  if ( (*this)[i].Compare( plane, normalEps, distEps ) ) {
60  return i;
61  }
62  }
63  }
64 
65  if ( plane.Type() >= PLANETYPE_NEGX && plane.Type() < PLANETYPE_TRUEAXIAL ) {
66  Append( -plane );
67  hash.Add( hashKey, Num()-1 );
68  Append( plane );
69  hash.Add( hashKey, Num()-1 );
70  return ( Num() - 1 );
71  }
72  else {
73  Append( plane );
74  hash.Add( hashKey, Num()-1 );
75  Append( -plane );
76  hash.Add( hashKey, Num()-1 );
77  return ( Num() - 2 );
78  }
79 }
80 
81 #endif /* !__PLANESET_H__ */
assert(prefInfo.fullscreenBtn)
int Next(const int index) const
Definition: HashIndex.h:247
case const int
Definition: Callbacks.cpp:52
#define PLANETYPE_NEGX
Definition: Plane.h:62
int i
Definition: process.py:33
void Free(void)
Definition: HashIndex.cpp:75
int FindPlane(const idPlane &plane, const float normalEps, const float distEps)
Definition: PlaneSet.h:51
int Type(void) const
Definition: Plane.cpp:39
int First(const int key) const
Definition: HashIndex.h:238
void Clear(void)
Definition: PlaneSet.h:43
idHashIndex hash
Definition: PlaneSet.h:48
static float Fabs(float f)
Definition: Math.h:779
Definition: Plane.h:71
GLint GLint GLsizei GLsizei GLsizei GLint border
Definition: glext.h:2878
int Append(const idPlane &obj)
tuple f
Definition: idal.py:89
int Num(void) const
#define PLANETYPE_TRUEAXIAL
Definition: Plane.h:65
void Add(const int key, const int index)
Definition: HashIndex.h:193
Definition: List.h:84
float Dist(void) const
Definition: Plane.h:271
void Clear(void)
Definition: List.h:184