doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
optimize_gcc.cpp
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 crazy gcc 3.3.5 optimization bug
30 happens even at -O1
31 if you remove the 'return NULL;' after Error(), it only happens at -O3 / release
32 see dmap.gcc.zip test map and .proc outputs
33 */
34 
35 #include "../../../idlib/precompiled.h"
36 #pragma hdrstop
37 
38 #include "dmap.h"
39 
40 extern idBounds optBounds;
41 
42 #define MAX_OPT_VERTEXES 0x10000
43 extern int numOptVerts;
45 
46 /*
47 ================
48 FindOptVertex
49 ================
50 */
52  int i;
53  float x, y;
54  optVertex_t *vert;
55 
56  // deal with everything strictly as 2D
57  x = v->xyz * opt->axis[0];
58  y = v->xyz * opt->axis[1];
59 
60  // should we match based on the t-junction fixing hash verts?
61  for ( i = 0 ; i < numOptVerts ; i++ ) {
62  if ( optVerts[i].pv[0] == x && optVerts[i].pv[1] == y ) {
63  return &optVerts[i];
64  }
65  }
66 
67  if ( numOptVerts >= MAX_OPT_VERTEXES ) {
68  common->Error( "MAX_OPT_VERTEXES" );
69  return NULL;
70  }
71 
72  numOptVerts++;
73 
74  vert = &optVerts[i];
75  memset( vert, 0, sizeof( *vert ) );
76  vert->v = *v;
77  vert->pv[0] = x;
78  vert->pv[1] = y;
79  vert->pv[2] = 0;
80 
81  optBounds.AddPoint( vert->pv );
82 
83  return vert;
84 }
const GLdouble * v
Definition: glext.h:2936
idVec3 xyz
Definition: DrawVert.h:42
GLenum GLint GLint y
Definition: glext.h:2849
optVertex_t * FindOptVertex(idDrawVert *v, optimizeGroup_t *opt)
optVertex_t optVerts[MAX_OPT_VERTEXES]
Definition: optimize.cpp:54
int numOptVerts
Definition: optimize.cpp:53
GLenum GLint x
Definition: glext.h:2849
int i
Definition: process.py:33
idBounds optBounds
Definition: optimize.cpp:50
idVec3 pv
Definition: dmap.h:414
bool AddPoint(const idVec3 &v)
Definition: Bounds.h:226
idVec3 axis[2]
Definition: dmap.h:209
idCommon * common
Definition: Common.cpp:206
#define NULL
Definition: Lib.h:88
#define MAX_OPT_VERTEXES
idDrawVert v
Definition: dmap.h:413
virtual void Error(const char *fmt,...) id_attribute((format(printf