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