routing.h

Go to the documentation of this file.
00001 
00006 /*
00007 All original material Copyright (C) 2002-2010 UFO: Alien Invasion.
00008 
00009 Copyright (C) 1997-2001 Id Software, Inc.
00010 
00011 This program is free software; you can redistribute it and/or
00012 modify it under the terms of the GNU General Public License
00013 as published by the Free Software Foundation; either version 2
00014 of the License, or (at your option) any later version.
00015 
00016 This program is distributed in the hope that it will be useful,
00017 but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00019 
00020 See the GNU General Public License for more details.
00021 
00022 You should have received a copy of the GNU General Public License
00023 along with this program; if not, write to the Free Software
00024 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00025 
00026 */
00027 
00028 /*==============================================================
00029 GLOBAL TYPES
00030 ==============================================================*/
00031 #if defined(COMPILE_MAP)
00032   #define RT_COMPLETEBOXTRACE_SIZE(mapTiles,s,e,b,list)     TR_SingleTileBoxTrace((mapTiles), (s),(e),(b),TRACING_ALL_VISIBLE_LEVELS, MASK_ALL, 0)
00033   #define RT_COMPLETEBOXTRACE_PASSAGE(mapTiles,s,e,b,list)  TR_SingleTileBoxTrace((mapTiles), (s),(e),(b),TRACING_ALL_VISIBLE_LEVELS, MASK_IMPASSABLE, MASK_PASSABLE)
00034 
00035 #elif defined(COMPILE_UFO)
00036   #define RT_COMPLETEBOXTRACE_SIZE(mapTiles,s,e,b,list)     CM_EntCompleteBoxTrace((mapTiles), (s),(e),(b),TRACING_ALL_VISIBLE_LEVELS, MASK_ALL, 0, (list))
00037   #define RT_COMPLETEBOXTRACE_PASSAGE(mapTiles,s,e,b,list)  CM_EntCompleteBoxTrace((mapTiles), (s),(e),(b),TRACING_ALL_VISIBLE_LEVELS, MASK_IMPASSABLE, MASK_PASSABLE, (list))
00038 
00039 #else
00040   #error Either COMPILE_MAP or COMPILE_UFO must be defined in order for tracing.c to work.
00041 #endif
00042 
00043 /* Decide whether we are doing uni- or bidirectional conclusions from our traces.
00044  * This constant is used in both a boolean and an integer way,
00045  * so it must only be set to 0 or 1 ! */
00046 #define RT_IS_BIDIRECTIONAL 0
00047 
00048 /*==============================================================
00049 MACROS
00050 ==============================================================*/
00055 /* route - Used by Grid_* only  */
00057 #define RT_CONN(map, actorSize, x, y, z, dir)           map[(actorSize) - 1].route[(z)][(y)][(x)][(dir)]
00058 #define RT_CONN_TEST(map, actorSize, x, y, z, dir)      assert((actorSize) > ACTOR_SIZE_INVALID); assert((actorSize) <= ACTOR_MAX_SIZE); \
00059                                                             assert((z) >= 0); assert((z) < PATHFINDING_HEIGHT);\
00060                                                             assert((y) >= 0); assert((y) < PATHFINDING_WIDTH);\
00061                                                             assert((x) >= 0); assert((x) < PATHFINDING_WIDTH);\
00062                                                             assert((dir) >= 0); assert((dir) < CORE_DIRECTIONS);
00063 
00064 #define RT_CONN_PX(map, actorSize, x, y, z)     (RT_CONN(map, actorSize, x, y, z, 0))
00065 #define RT_CONN_NX(map, actorSize, x, y, z)     (RT_CONN(map, actorSize, x, y, z, 1))
00066 #define RT_CONN_PY(map, actorSize, x, y, z)     (RT_CONN(map, actorSize, x, y, z, 2))
00067 #define RT_CONN_NY(map, actorSize, x, y, z)     (RT_CONN(map, actorSize, x, y, z, 3))
00068 
00069 #define RT_CONN_PX_PY(map, actorSize, x, y, z)      (RT_CONN(map, actorSize, x, y, z, 4))
00070 #define RT_CONN_PX_NY(map, actorSize, x, y, z)      (RT_CONN(map, actorSize, x, y, z, 7))
00071 #define RT_CONN_NX_PY(map, actorSize, x, y, z)      (RT_CONN(map, actorSize, x, y, z, 6))
00072 #define RT_CONN_NX_NY(map, actorSize, x, y, z)      (RT_CONN(map, actorSize, x, y, z, 5))
00073 
00074 #define RT_STEPUP(map, actorSize, x, y, z, dir) map[(actorSize) - 1].stepup[(z)][(y)][(x)][(dir)]
00075 
00076 #define RT_STEPUP_PX(map, actorSize, x, y, z)       (RT_STEPUP(map, actorSize, x, y, z, 0))
00077 #define RT_STEPUP_NX(map, actorSize, x, y, z)       (RT_STEPUP(map, actorSize, x, y, z, 1))
00078 #define RT_STEPUP_PY(map, actorSize, x, y, z)       (RT_STEPUP(map, actorSize, x, y, z, 2))
00079 #define RT_STEPUP_NY(map, actorSize, x, y, z)       (RT_STEPUP(map, actorSize, x, y, z, 3))
00080 
00081 #define RT_STEPUP_PX_PY(map, actorSize, x, y, z)        (RT_STEPUP(map, actorSize, x, y, z, 4))
00082 #define RT_STEPUP_PX_NY(map, actorSize, x, y, z)        (RT_STEPUP(map, actorSize, x, y, z, 7))
00083 #define RT_STEPUP_NX_PY(map, actorSize, x, y, z)        (RT_STEPUP(map, actorSize, x, y, z, 6))
00084 #define RT_STEPUP_NX_NY(map, actorSize, x, y, z)        (RT_STEPUP(map, actorSize, x, y, z, 5))
00085 
00086 #define RT_FLOOR(map, actorSize, x, y, z)           map[(actorSize) - 1].floor[(z)][(y)][(x)]
00087 #define RT_CEILING(map, actorSize, x, y, z)         map[(actorSize) - 1].ceil[(z)][(y)][(x)]
00088 #define RT_FILLED(map, actorSize, x, y, z)          (RT_CEILING(map, actorSize, x, y, z) - RT_FLOOR(map, actorSize, x, y, z) < PATHFINDING_MIN_OPENING)
00089 
00090 /* area - Used by Grid_* only */
00091 #define RT_AREA(path, x, y, z, state)               ((path)->area[(state)][(z)][(y)][(x)])
00092 #define RT_AREA_FROM(path, x, y, z, state)          ((path)->areaFrom[(state)][(z)][(y)][(x)])
00093 #define RT_SAREA(path, x, y, z, state)              ((path)->areaStored[(state)][(z)][(y)][(x)])
00094 #define RT_AREA_TEST(path, x, y, z, state)          assert((z) >= 0); assert((z) < PATHFINDING_HEIGHT);\
00095                                                         assert((y) >= 0); assert((y) < PATHFINDING_WIDTH);\
00096                                                         assert((x) >= 0); assert((x) < PATHFINDING_WIDTH);\
00097                                                         assert((state) == 0 || (state) == 1);
00098 
00099 
00101 /* Surfaces used as floors are rounded up. */
00102 #define ModelFloorToQuant(x)    (ceil((x) / QUANT))
00103 /* Surfaces used as ceilings are rounded down. */
00104 #define ModelCeilingToQuant(x)  (floor((x) / QUANT))
00105 /* Going from QUANT units back to model units returns the approximation of the QUANT unit. */
00106 #define QuantToModel(x)         ((x) * QUANT)
00107 
00111 #define SizedPosToVec(p, actorSize, v) { \
00112     assert(actorSize > ACTOR_SIZE_INVALID); \
00113     assert(actorSize <= ACTOR_MAX_SIZE); \
00114     v[0] = ((int)p[0] - 128) * UNIT_SIZE   + (UNIT_SIZE * actorSize)  / 2; \
00115     v[1] = ((int)p[1] - 128) * UNIT_SIZE   + (UNIT_SIZE * actorSize)  / 2; \
00116     v[2] =  (int)p[2]        * UNIT_HEIGHT + UNIT_HEIGHT / 2;  \
00117 }
00118 
00119 
00120 /*
00121 ===============================================================================
00122 SHARED EXTERNS (cmodel.c and ufo2map/routing.c)
00123 ===============================================================================
00124 */
00125 
00126 extern qboolean debugTrace;
00127 
00128 /*
00129 ===============================================================================
00130 GAME RELATED TRACING
00131 ===============================================================================
00132 */
00133 
00134 
00135 int RT_CheckCell(mapTiles_t *mapTiles, routing_t * map, const int actorSize, const int x, const int y, const int z, const char **list);
00136 void RT_UpdateConnectionColumn(mapTiles_t *mapTiles, routing_t * map, const int actorSize, const int x, const int y, const int dir, const char **list);
00137 qboolean RT_AllCellsBelowAreFilled(const routing_t * map, const int actorSize, const pos3_t pos);
00138 void RT_GetMapSize(mapTiles_t *mapTiles, vec3_t map_min, vec3_t map_max);
00139 
00140 
00141 /*
00142 ==========================================================
00143 DEBUGGING CODE
00144 ==========================================================
00145 */
00146 
00147 #ifdef DEBUG
00148 void RT_DumpWholeMap(mapTiles_t *mapTiles, const routing_t *map);
00149 #endif
00150 void RT_WriteCSVFiles(const routing_t *map, const char* baseFilename, const ipos3_t mins, const ipos3_t maxs);

Generated by  doxygen 1.6.2