]> git.mxchange.org Git - flightgear.git/blob - Scenery/tile.cxx
Tweaks for building with native SGI compilers.
[flightgear.git] / Scenery / tile.cxx
1 // tile.cxx -- routines to handle a scenery tile
2 //
3 // Written by Curtis Olson, started May 1998.
4 //
5 // Copyright (C) 1998  Curtis L. Olson  - curt@infoplane.com
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21 // $Id$
22 // (Log is kept at end of this file)
23
24
25 #include <Include/compiler.h>
26
27 #include STL_FUNCTIONAL
28 #include STL_ALGORITHM
29
30 #include <Debug/logstream.hxx>
31 #include <Scenery/tile.hxx>
32 #include "Bucket/bucketutils.hxx"
33
34 #include "tile.hxx"
35
36 FG_USING_STD(for_each);
37 FG_USING_STD(mem_fun_ref);
38
39
40 // Constructor
41 fgTILE::fgTILE ( void )
42     : nodes(new double[MAX_NODES][3]),
43       ncount(0),
44       used(false)
45 {
46 }
47
48
49 // Destructor
50 fgTILE::~fgTILE ( void ) {
51 //     free(nodes);
52     delete[] nodes;
53 }
54
55 // Step through the fragment list, deleting the display list, then
56 // the fragment, until the list is empty.
57 void
58 fgTILE::release_fragments()
59 {
60     FG_LOG( FG_TERRAIN, FG_DEBUG,
61             "FREEING TILE = (" << tile_bucket << ")" );
62     for_each( begin(), end(),
63               mem_fun_ref( &fgFRAGMENT::deleteDisplayList ));
64     fragment_list.erase( begin(), end() );
65     used = false;
66 }
67
68
69 // $Log$
70 // Revision 1.15  1999/03/02 01:03:29  curt
71 // Tweaks for building with native SGI compilers.
72 //
73 // Revision 1.14  1999/02/02 20:13:40  curt
74 // MSVC++ portability changes by Bernie Bright:
75 //
76 // Lib/Serial/serial.[ch]xx: Initial Windows support - incomplete.
77 // Simulator/Astro/stars.cxx: typo? included <stdio> instead of <cstdio>
78 // Simulator/Cockpit/hud.cxx: Added Standard headers
79 // Simulator/Cockpit/panel.cxx: Redefinition of default parameter
80 // Simulator/Flight/flight.cxx: Replaced cout with FG_LOG.  Deleted <stdio.h>
81 // Simulator/Main/fg_init.cxx:
82 // Simulator/Main/GLUTmain.cxx:
83 // Simulator/Main/options.hxx: Shuffled <fg_serial.hxx> dependency
84 // Simulator/Objects/material.hxx:
85 // Simulator/Time/timestamp.hxx: VC++ friend kludge
86 // Simulator/Scenery/tile.[ch]xx: Fixed using std::X declarations
87 // Simulator/Main/views.hxx: Added a constant
88 //
89 // Revision 1.13  1998/11/09 23:40:46  curt
90 // Bernie Bright <bbright@c031.aone.net.au> writes:
91 // I've made some changes to the Scenery handling.  Basically just tidy ups.
92 // The main difference is in tile.[ch]xx where I've changed list<fgFRAGMENT> to
93 // vector<fgFRAGMENT>.  Studying our usage patterns this seems reasonable.
94 // Lists are good if you need to insert/delete elements randomly but we
95 // don't do that.  All access seems to be sequential.  Two additional
96 // benefits are smaller memory usage - each list element requires pointers
97 // to the next and previous elements, and faster access - vector iterators
98 // are smaller and faster than list iterators.  This should also help
99 // Charlie Hotchkiss' problem when compiling with Borland and STLport.
100 //
101 // ./Lib/Bucket/bucketutils.hxx
102 //   Convenience functions for fgBUCKET.
103 //
104 // ./Simulator/Scenery/tile.cxx
105 // ./Simulator/Scenery/tile.hxx
106 //   Changed fragment list to a vector.
107 //   Added some convenience member functions.
108 //
109 // ./Simulator/Scenery/tilecache.cxx
110 // ./Simulator/Scenery/tilecache.hxx
111 //   use const fgBUCKET& instead of fgBUCKET* where appropriate.
112 //
113 // ./Simulator/Scenery/tilemgr.cxx
114 // ./Simulator/Scenery/tilemgr.hxx
115 //   uses all the new convenience functions.
116 //
117 // Revision 1.12  1998/10/16 00:55:45  curt
118 // Converted to Point3D class.
119 //
120 // Revision 1.11  1998/09/02 14:37:08  curt
121 // Use erase() instead of while ( size() ) pop_front();
122 //
123 // Revision 1.10  1998/08/25 16:52:42  curt
124 // material.cxx material.hxx obj.cxx obj.hxx texload.c texload.h moved to
125 //   ../Objects
126 //
127 // Revision 1.9  1998/08/24 20:11:39  curt
128 // Tweaks ...
129 //
130 // Revision 1.8  1998/08/22  14:49:58  curt
131 // Attempting to iron out seg faults and crashes.
132 // Did some shuffling to fix a initialization order problem between view
133 // position, scenery elevation.
134 //
135 // Revision 1.7  1998/08/20 15:12:05  curt
136 // Used a forward declaration of classes fgTILE and fgMATERIAL to eliminate
137 // the need for "void" pointers and casts.
138 // Quick hack to count the number of scenery polygons that are being drawn.
139 //
140 // Revision 1.6  1998/08/12 21:13:05  curt
141 // material.cxx: don't load textures if they are disabled
142 // obj.cxx: optimizations from Norman Vine
143 // tile.cxx: minor tweaks
144 // tile.hxx: addition of num_faces
145 // tilemgr.cxx: minor tweaks
146 //
147 // Revision 1.5  1998/07/24 21:42:08  curt
148 // material.cxx: whups, double method declaration with no definition.
149 // obj.cxx: tweaks to avoid errors in SGI's CC.
150 // tile.cxx: optimizations by Norman Vine.
151 // tilemgr.cxx: optimizations by Norman Vine.
152 //
153 // Revision 1.4  1998/07/22 21:41:42  curt
154 // Add basic fgFACE methods contributed by Charlie Hotchkiss.
155 // intersect optimization from Norman Vine.
156 //
157 // Revision 1.3  1998/07/16 17:34:24  curt
158 // Ground collision detection optimizations contributed by Norman Vine.
159 //
160 // Revision 1.2  1998/07/12 03:18:28  curt
161 // Added ground collision detection.  This involved:
162 // - saving the entire vertex list for each tile with the tile records.
163 // - saving the face list for each fragment with the fragment records.
164 // - code to intersect the current vertical line with the proper face in
165 //   an efficient manner as possible.
166 // Fixed a bug where the tiles weren't being shifted to "near" (0,0,0)
167 //
168 // Revision 1.1  1998/05/23 14:09:21  curt
169 // Added tile.cxx and tile.hxx.
170 // Working on rewriting the tile management system so a tile is just a list
171 // fragments, and the fragment record contains the display list for that fragment.
172 //