]> git.mxchange.org Git - flightgear.git/blob - Simulator/Scenery/tile.cxx
Merge Include as subdirectory
[flightgear.git] / Simulator / 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/newbucket.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.16  1999/03/25 19:03:24  curt
71 // Converted to use new bucket routines.
72 //
73 // Revision 1.15  1999/03/02 01:03:29  curt
74 // Tweaks for building with native SGI compilers.
75 //
76 // Revision 1.14  1999/02/02 20:13:40  curt
77 // MSVC++ portability changes by Bernie Bright:
78 //
79 // Lib/Serial/serial.[ch]xx: Initial Windows support - incomplete.
80 // Simulator/Astro/stars.cxx: typo? included <stdio> instead of <cstdio>
81 // Simulator/Cockpit/hud.cxx: Added Standard headers
82 // Simulator/Cockpit/panel.cxx: Redefinition of default parameter
83 // Simulator/Flight/flight.cxx: Replaced cout with FG_LOG.  Deleted <stdio.h>
84 // Simulator/Main/fg_init.cxx:
85 // Simulator/Main/GLUTmain.cxx:
86 // Simulator/Main/options.hxx: Shuffled <fg_serial.hxx> dependency
87 // Simulator/Objects/material.hxx:
88 // Simulator/Time/timestamp.hxx: VC++ friend kludge
89 // Simulator/Scenery/tile.[ch]xx: Fixed using std::X declarations
90 // Simulator/Main/views.hxx: Added a constant
91 //
92 // Revision 1.13  1998/11/09 23:40:46  curt
93 // Bernie Bright <bbright@c031.aone.net.au> writes:
94 // I've made some changes to the Scenery handling.  Basically just tidy ups.
95 // The main difference is in tile.[ch]xx where I've changed list<fgFRAGMENT> to
96 // vector<fgFRAGMENT>.  Studying our usage patterns this seems reasonable.
97 // Lists are good if you need to insert/delete elements randomly but we
98 // don't do that.  All access seems to be sequential.  Two additional
99 // benefits are smaller memory usage - each list element requires pointers
100 // to the next and previous elements, and faster access - vector iterators
101 // are smaller and faster than list iterators.  This should also help
102 // Charlie Hotchkiss' problem when compiling with Borland and STLport.
103 //
104 // ./Lib/Bucket/bucketutils.hxx
105 //   Convenience functions for fgBUCKET.
106 //
107 // ./Simulator/Scenery/tile.cxx
108 // ./Simulator/Scenery/tile.hxx
109 //   Changed fragment list to a vector.
110 //   Added some convenience member functions.
111 //
112 // ./Simulator/Scenery/tilecache.cxx
113 // ./Simulator/Scenery/tilecache.hxx
114 //   use const fgBUCKET& instead of fgBUCKET* where appropriate.
115 //
116 // ./Simulator/Scenery/tilemgr.cxx
117 // ./Simulator/Scenery/tilemgr.hxx
118 //   uses all the new convenience functions.
119 //
120 // Revision 1.12  1998/10/16 00:55:45  curt
121 // Converted to Point3D class.
122 //
123 // Revision 1.11  1998/09/02 14:37:08  curt
124 // Use erase() instead of while ( size() ) pop_front();
125 //
126 // Revision 1.10  1998/08/25 16:52:42  curt
127 // material.cxx material.hxx obj.cxx obj.hxx texload.c texload.h moved to
128 //   ../Objects
129 //
130 // Revision 1.9  1998/08/24 20:11:39  curt
131 // Tweaks ...
132 //
133 // Revision 1.8  1998/08/22  14:49:58  curt
134 // Attempting to iron out seg faults and crashes.
135 // Did some shuffling to fix a initialization order problem between view
136 // position, scenery elevation.
137 //
138 // Revision 1.7  1998/08/20 15:12:05  curt
139 // Used a forward declaration of classes fgTILE and fgMATERIAL to eliminate
140 // the need for "void" pointers and casts.
141 // Quick hack to count the number of scenery polygons that are being drawn.
142 //
143 // Revision 1.6  1998/08/12 21:13:05  curt
144 // material.cxx: don't load textures if they are disabled
145 // obj.cxx: optimizations from Norman Vine
146 // tile.cxx: minor tweaks
147 // tile.hxx: addition of num_faces
148 // tilemgr.cxx: minor tweaks
149 //
150 // Revision 1.5  1998/07/24 21:42:08  curt
151 // material.cxx: whups, double method declaration with no definition.
152 // obj.cxx: tweaks to avoid errors in SGI's CC.
153 // tile.cxx: optimizations by Norman Vine.
154 // tilemgr.cxx: optimizations by Norman Vine.
155 //
156 // Revision 1.4  1998/07/22 21:41:42  curt
157 // Add basic fgFACE methods contributed by Charlie Hotchkiss.
158 // intersect optimization from Norman Vine.
159 //
160 // Revision 1.3  1998/07/16 17:34:24  curt
161 // Ground collision detection optimizations contributed by Norman Vine.
162 //
163 // Revision 1.2  1998/07/12 03:18:28  curt
164 // Added ground collision detection.  This involved:
165 // - saving the entire vertex list for each tile with the tile records.
166 // - saving the face list for each fragment with the fragment records.
167 // - code to intersect the current vertical line with the proper face in
168 //   an efficient manner as possible.
169 // Fixed a bug where the tiles weren't being shifted to "near" (0,0,0)
170 //
171 // Revision 1.1  1998/05/23 14:09:21  curt
172 // Added tile.cxx and tile.hxx.
173 // Working on rewriting the tile management system so a tile is just a list
174 // fragments, and the fragment record contains the display list for that fragment.
175 //